diff options
-rw-r--r-- | src/server/LV2Info.cpp | 6 | ||||
-rw-r--r-- | src/server/LV2Node.cpp | 2 | ||||
-rw-r--r-- | src/shared/LV2Features.cpp | 32 | ||||
-rw-r--r-- | src/shared/LV2Features.hpp | 22 | ||||
-rw-r--r-- | src/shared/World.cpp | 4 |
5 files changed, 30 insertions, 36 deletions
diff --git a/src/server/LV2Info.cpp b/src/server/LV2Info.cpp index 1ff351b6..6d13644e 100644 --- a/src/server/LV2Info.cpp +++ b/src/server/LV2Info.cpp @@ -51,11 +51,11 @@ LV2Info::LV2Info(Ingen::Shared::World* world) { assert(world); - world->lv2_features()->add_feature(LV2_EVENT_URI, + world->lv2_features()->add_feature( SharedPtr<Shared::LV2Features::Feature>(new EventFeature())); - world->lv2_features()->add_feature(LV2_RESIZE_PORT_URI, + world->lv2_features()->add_feature( SharedPtr<Shared::LV2Features::Feature>(new ResizeFeature())); - world->lv2_features()->add_feature(LV2_CONTEXTS_URI "#RequestRunFeature", + world->lv2_features()->add_feature( SharedPtr<Shared::LV2Features::Feature>(new RequestRunFeature())); } diff --git a/src/server/LV2Node.cpp b/src/server/LV2Node.cpp index 125beaee..76837c88 100644 --- a/src/server/LV2Node.cpp +++ b/src/server/LV2Node.cpp @@ -152,7 +152,7 @@ LV2Node::instantiate(BufferFactory& bufs) uint32_t port_buffer_size = 0; LilvNode* ctx_ext_uri = lilv_new_uri(info->lv2_world(), - LV2_CONTEXTS_URI "#MessageContext"); + LV2_CONTEXTS_URI "#MessageContext"); for (uint32_t i = 0; i < _polyphony; ++i) { (*_instances)[i] = SharedPtr<void>( diff --git a/src/shared/LV2Features.cpp b/src/shared/LV2Features.cpp index 83c817eb..ea5cdd8a 100644 --- a/src/shared/LV2Features.cpp +++ b/src/shared/LV2Features.cpp @@ -16,7 +16,7 @@ */ #include <cstdlib> -#include <cstring> + #include "LV2Features.hpp" #include "LV2URIMap.hpp" @@ -29,20 +29,25 @@ LV2Features::LV2Features() { } -SharedPtr<LV2Features::Feature> -LV2Features::feature(const std::string& uri) +void +LV2Features::add_feature(SharedPtr<Feature> feature) { - Features::const_iterator i = _features.find(uri); - if (i != _features.end()) - return i->second; - else - return SharedPtr<Feature>(); + _features.push_back(feature); } -void -LV2Features::add_feature(const std::string& uri, SharedPtr<Feature> feature) +LV2Features::FeatureArray::FeatureArray(FeatureVector& features) + : _features(features) +{ + _array = (LV2_Feature**)malloc(sizeof(LV2_Feature) * (features.size() + 1)); + _array[features.size()] = NULL; + for (size_t i = 0; i < features.size(); ++i) { + _array[i] = features[i].get(); + } +} + +LV2Features::FeatureArray::~FeatureArray() { - _features.insert(make_pair(uri, feature)); + free(_array); } SharedPtr<LV2Features::FeatureArray> @@ -50,9 +55,10 @@ LV2Features::lv2_features(Shared::World* world, Node* node) const { FeatureArray::FeatureVector vec; for (Features::const_iterator f = _features.begin(); f != _features.end(); ++f) { - SharedPtr<LV2_Feature> fptr = f->second->feature(world, node); - if (fptr) + SharedPtr<LV2_Feature> fptr = (*f)->feature(world, node); + if (fptr) { vec.push_back(fptr); + } } return SharedPtr<FeatureArray>(new FeatureArray(vec)); } diff --git a/src/shared/LV2Features.hpp b/src/shared/LV2Features.hpp index 75bbcda3..f33cc605 100644 --- a/src/shared/LV2Features.hpp +++ b/src/shared/LV2Features.hpp @@ -18,8 +18,6 @@ #ifndef INGEN_SHARED_LV2FEATURES_HPP #define INGEN_SHARED_LV2FEATURES_HPP -#include <map> -#include <string> #include <vector> #include "lv2/lv2plug.in/ns/lv2core/lv2.h" @@ -43,6 +41,7 @@ public: class Feature { public: virtual ~Feature() {} + virtual SharedPtr<LV2_Feature> feature(Shared::World* world, Node* node) = 0; }; @@ -51,18 +50,9 @@ public: public: typedef std::vector< SharedPtr<LV2_Feature> > FeatureVector; - explicit FeatureArray(FeatureVector& features) - : _features(features) - { - _array = (LV2_Feature**)malloc(sizeof(LV2_Feature) * (features.size() + 1)); - _array[features.size()] = NULL; - for (size_t i = 0; i < features.size(); ++i) - _array[i] = features[i].get(); - } + explicit FeatureArray(FeatureVector& features); - ~FeatureArray() { - free(_array); - } + ~FeatureArray(); LV2_Feature** array() { return _array; } @@ -71,15 +61,13 @@ public: LV2_Feature** _array; }; - SharedPtr<Feature> feature(const std::string& uri); - - void add_feature(const std::string& uri, SharedPtr<Feature> feature); + void add_feature(SharedPtr<Feature> feature); SharedPtr<FeatureArray> lv2_features(Shared::World* world, Node* node) const; private: - typedef std::map< std::string, SharedPtr<Feature> > Features; + typedef std::vector< SharedPtr<Feature> > Features; Features _features; }; diff --git a/src/shared/World.cpp b/src/shared/World.cpp index 92d7a03f..c70b9196 100644 --- a/src/shared/World.cpp +++ b/src/shared/World.cpp @@ -107,8 +107,8 @@ public: , lilv_world(lilv_world_new()) { lv2_features = new Ingen::Shared::LV2Features(); - lv2_features->add_feature(LV2_URI_MAP_URI, uris); - lv2_features->add_feature(LV2_URI_UNMAP_URI, uris->unmap_feature()); + lv2_features->add_feature(uris); + lv2_features->add_feature(uris->unmap_feature()); lilv_world_load_all(lilv_world); // Set up RDF namespaces |