diff options
-rw-r--r-- | include/ingen/URIMap.hpp | 23 | ||||
-rw-r--r-- | src/AtomWriter.cpp | 2 | ||||
-rw-r--r-- | src/Configuration.cpp | 4 | ||||
-rw-r--r-- | src/Forge.cpp | 2 | ||||
-rw-r--r-- | src/Parser.cpp | 2 | ||||
-rw-r--r-- | src/Serialiser.cpp | 4 | ||||
-rw-r--r-- | src/SocketReader.cpp | 2 | ||||
-rw-r--r-- | src/TurtleWriter.cpp | 4 | ||||
-rw-r--r-- | src/URIMap.cpp | 29 | ||||
-rw-r--r-- | src/server/ControlBindings.cpp | 3 | ||||
-rw-r--r-- | src/server/JackDriver.cpp | 3 | ||||
-rw-r--r-- | src/server/LV2Block.cpp | 16 | ||||
-rw-r--r-- | src/server/UndoStack.cpp | 4 | ||||
-rw-r--r-- | tests/ingen_test.cpp | 2 |
14 files changed, 58 insertions, 42 deletions
diff --git a/include/ingen/URIMap.hpp b/include/ingen/URIMap.hpp index 7efef8d1..890917f1 100644 --- a/include/ingen/URIMap.hpp +++ b/include/ingen/URIMap.hpp @@ -63,19 +63,36 @@ public: struct URIDMapFeature : public Feature { URIDMapFeature(URIMap* map, LV2_URID_Map* impl, Log& log); + LV2_URID map(const char* uri); static LV2_URID default_map(LV2_URID_Map_Handle h, const char* c_uri); - LV2_URID_Map urid_map; - Log& log; + + LV2_URID_Map& data() { return _urid_map; } + const LV2_URID_Map& data() const { return _urid_map; } + + private: + LV2_URID_Map _urid_map; + Log& _log; }; struct URIDUnmapFeature : public Feature { URIDUnmapFeature(URIMap* map, LV2_URID_Unmap* impl); + const char* unmap(LV2_URID urid) const; static const char* default_unmap(LV2_URID_Map_Handle h, LV2_URID urid); - LV2_URID_Unmap urid_unmap; + + LV2_URID_Unmap& data() { return _urid_unmap; } + const LV2_URID_Unmap& data() const { return _urid_unmap; } + + private: + LV2_URID_Unmap _urid_unmap; }; + const LV2_URID_Map& urid_map() const { return _urid_map_feature->data(); } + LV2_URID_Map& urid_map() { return _urid_map_feature->data(); } + const LV2_URID_Unmap& urid_unmap() const { return _urid_unmap_feature->data(); } + LV2_URID_Unmap& urid_unmap() { return _urid_unmap_feature->data(); } + SPtr<URIDMapFeature> urid_map_feature() { return _urid_map_feature; } SPtr<URIDUnmapFeature> urid_unmap_feature() { return _urid_unmap_feature; } diff --git a/src/AtomWriter.cpp b/src/AtomWriter.cpp index 365c955d..fe4f686e 100644 --- a/src/AtomWriter.cpp +++ b/src/AtomWriter.cpp @@ -78,7 +78,7 @@ AtomWriter::AtomWriter(URIMap& map, URIs& uris, AtomSink& sink) : _map(map) , _uris(uris) , _sink(sink) - , _forge(map.urid_map_feature()->urid_map) + , _forge(map.urid_map()) { } diff --git a/src/Configuration.cpp b/src/Configuration.cpp index 6ddec134..5b5d75bd 100644 --- a/src/Configuration.cpp +++ b/src/Configuration.cpp @@ -319,7 +319,7 @@ Configuration::save(URIMap& uri_map, writer); // Create an atom serialiser and connect it to the Turtle writer - Sratom* sratom = sratom_new(&uri_map.urid_map_feature()->urid_map); + Sratom* sratom = sratom_new(&uri_map.urid_map()); sratom_set_pretty_numbers(sratom, true); sratom_set_sink(sratom, reinterpret_cast<const char*>(base.buf), @@ -340,7 +340,7 @@ Configuration::save(URIMap& uri_map, const std::string key(std::string("ingen:") + o.second.key); SerdNode pred = serd_node_from_string( SERD_CURIE, reinterpret_cast<const uint8_t*>(key.c_str())); - sratom_write(sratom, &uri_map.urid_unmap_feature()->urid_unmap, 0, + sratom_write(sratom, &uri_map.urid_unmap(), 0, &base, &pred, value.type(), value.size(), value.get_body()); } diff --git a/src/Forge.cpp b/src/Forge.cpp index cc1b12c8..db6d8ebf 100644 --- a/src/Forge.cpp +++ b/src/Forge.cpp @@ -29,7 +29,7 @@ Forge::Forge(URIMap& map) : LV2_Atom_Forge() , _map(map) { - lv2_atom_forge_init(this, &map.urid_map_feature()->urid_map); + lv2_atom_forge_init(this, &map.urid_map()); } Atom diff --git a/src/Parser.cpp b/src/Parser.cpp index 0f5adb0c..ec188e35 100644 --- a/src/Parser.cpp +++ b/src/Parser.cpp @@ -110,7 +110,7 @@ get_properties(ingen::World& world, Resource::Graph ctx, const boost::optional<Properties>& data = {}) { - AtomForge forge(world.uri_map().urid_map_feature()->urid_map); + AtomForge forge(world.uri_map().urid_map()); const Sord::Node nil; Properties props; diff --git a/src/Serialiser.cpp b/src/Serialiser.cpp index 96bc7f7c..6632a2e7 100644 --- a/src/Serialiser.cpp +++ b/src/Serialiser.cpp @@ -59,7 +59,7 @@ struct Serialiser::Impl { , _mode(Mode::TO_FILE) , _world(world) , _model(nullptr) - , _sratom(sratom_new(&_world.uri_map().urid_map_feature()->urid_map)) + , _sratom(sratom_new(&_world.uri_map().urid_map())) {} ~Impl() { @@ -555,7 +555,7 @@ void Serialiser::Impl::serialise_properties(Sord::Node id, const Properties& props) { - LV2_URID_Unmap* unmap = &_world.uri_map().urid_unmap_feature()->urid_unmap; + LV2_URID_Unmap* unmap = &_world.uri_map().urid_unmap(); SerdNode base = serd_node_from_string(SERD_URI, reinterpret_cast<const uint8_t*>( _base_uri.c_str())); diff --git a/src/SocketReader.cpp b/src/SocketReader.cpp index bdb2a36e..7e6b9782 100644 --- a/src/SocketReader.cpp +++ b/src/SocketReader.cpp @@ -120,7 +120,7 @@ void SocketReader::run() { Sord::World* world = _world.rdf_world(); - LV2_URID_Map& map = _world.uri_map().urid_map_feature()->urid_map; + LV2_URID_Map& map = _world.uri_map().urid_map(); // Set up a forge to build LV2 atoms from model SordNode* base_uri = nullptr; diff --git a/src/TurtleWriter.cpp b/src/TurtleWriter.cpp index 4e0e55da..53af79f0 100644 --- a/src/TurtleWriter.cpp +++ b/src/TurtleWriter.cpp @@ -40,7 +40,7 @@ write_prefix(void* handle, const SerdNode* name, const SerdNode* uri) TurtleWriter::TurtleWriter(URIMap& map, URIs& uris, URI uri) : AtomWriter(map, uris, *this) , _map(map) - , _sratom(sratom_new(&map.urid_map_feature()->urid_map)) + , _sratom(sratom_new(&map.urid_map())) , _base(SERD_NODE_NULL) , _base_uri(SERD_URI_NULL) , _uri(std::move(uri)) @@ -96,7 +96,7 @@ TurtleWriter::write(const LV2_Atom* msg, int32_t) _wrote_prefixes = true; } - sratom_write(_sratom, &_map.urid_unmap_feature()->urid_unmap, 0, + sratom_write(_sratom, &_map.urid_unmap(), 0, nullptr, nullptr, msg->type, msg->size, LV2_ATOM_BODY_CONST(msg)); serd_writer_finish(_writer); return true; diff --git a/src/URIMap.cpp b/src/URIMap.cpp index 5f1ea43f..1f627e1e 100644 --- a/src/URIMap.cpp +++ b/src/URIMap.cpp @@ -35,15 +35,15 @@ URIMap::URIMap(Log& log, LV2_URID_Map* map, LV2_URID_Unmap* unmap) URIMap::URIDMapFeature::URIDMapFeature(URIMap* map, LV2_URID_Map* impl, Log& log) - : Feature(LV2_URID__map, &urid_map) - , urid_map() - , log(log) + : Feature(LV2_URID__map, &_urid_map) + , _urid_map() + , _log(log) { if (impl) { - urid_map = *impl; + _urid_map = *impl; } else { - urid_map.map = default_map; - urid_map.handle = map; + _urid_map.map = default_map; + _urid_map.handle = map; } } @@ -69,22 +69,23 @@ LV2_URID URIMap::URIDMapFeature::map(const char* uri) { if (!URI::is_valid(uri)) { - log.error("Attempt to map invalid URI <%1%>\n", uri); + _log.error("Attempt to map invalid URI <%1%>\n", uri); return 0; } - return urid_map.map(urid_map.handle, uri); + + return _urid_map.map(_urid_map.handle, uri); } URIMap::URIDUnmapFeature::URIDUnmapFeature(URIMap* map, LV2_URID_Unmap* impl) - : Feature(LV2_URID__unmap, &urid_unmap) - , urid_unmap() + : Feature(LV2_URID__unmap, &_urid_unmap) + , _urid_unmap() { if (impl) { - urid_unmap = *impl; + _urid_unmap = *impl; } else { - urid_unmap.unmap = default_unmap; - urid_unmap.handle = map; + _urid_unmap.unmap = default_unmap; + _urid_unmap.handle = map; } } @@ -103,7 +104,7 @@ URIMap::URIDUnmapFeature::default_unmap(LV2_URID_Unmap_Handle h, const char* URIMap::URIDUnmapFeature::unmap(LV2_URID urid) const { - return urid_unmap.unmap(urid_unmap.handle, urid); + return _urid_unmap.unmap(_urid_unmap.handle, urid); } uint32_t diff --git a/src/server/ControlBindings.cpp b/src/server/ControlBindings.cpp index 75acd7b2..24d8ad54 100644 --- a/src/server/ControlBindings.cpp +++ b/src/server/ControlBindings.cpp @@ -53,8 +53,7 @@ ControlBindings::ControlBindings(Engine& engine) 4096)) // FIXME: capacity? , _forge() { - lv2_atom_forge_init( - &_forge, &engine.world().uri_map().urid_map_feature()->urid_map); + lv2_atom_forge_init(&_forge, &engine.world().uri_map().urid_map()); } ControlBindings::~ControlBindings() diff --git a/src/server/JackDriver.cpp b/src/server/JackDriver.cpp index b4594cda..b3f669ce 100644 --- a/src/server/JackDriver.cpp +++ b/src/server/JackDriver.cpp @@ -76,8 +76,7 @@ JackDriver::JackDriver(Engine& engine) , _old_rolling(false) { _midi_event_type = _engine.world().uris().midi_MidiEvent; - lv2_atom_forge_init( - &_forge, &engine.world().uri_map().urid_map_feature()->urid_map); + lv2_atom_forge_init(&_forge, &engine.world().uri_map().urid_map()); } JackDriver::~JackDriver() diff --git a/src/server/LV2Block.cpp b/src/server/LV2Block.cpp index 15c66a2c..090ae8af 100644 --- a/src/server/LV2Block.cpp +++ b/src/server/LV2Block.cpp @@ -477,7 +477,7 @@ LV2Block::save_state(const FilePath& dir) const LilvState* state = lilv_state_new_from_instance( _lv2_plugin->lilv_plugin(), const_cast<LV2Block*>(this)->instance(0), - &world.uri_map().urid_map_feature()->urid_map, + &world.uri_map().urid_map(), nullptr, dir.c_str(), dir.c_str(), dir.c_str(), nullptr, nullptr, LV2_STATE_IS_POD|LV2_STATE_IS_PORTABLE, nullptr); @@ -489,8 +489,8 @@ LV2Block::save_state(const FilePath& dir) const } lilv_state_save(lworld, - &world.uri_map().urid_map_feature()->urid_map, - &world.uri_map().urid_unmap_feature()->urid_unmap, + &world.uri_map().urid_map(), + &world.uri_map().urid_unmap(), state, nullptr, dir.c_str(), @@ -511,7 +511,7 @@ LV2Block::duplicate(Engine& engine, // Get current state LilvState* state = lilv_state_new_from_instance( _lv2_plugin->lilv_plugin(), instance(0), - &engine.world().uri_map().urid_map_feature()->urid_map, + &engine.world().uri_map().urid_map(), nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, LV2_STATE_IS_NATIVE, nullptr); // Duplicate and instantiate block @@ -625,7 +625,7 @@ LV2Block::load_preset(const URI& uri) lilv_world_load_resource(lworld, preset); // Load preset from world - LV2_URID_Map* map = &world.uri_map().urid_map_feature()->urid_map; + LV2_URID_Map* map = &world.uri_map().urid_map(); LilvState* state = lilv_state_new_from_world(lworld, map, preset); lilv_node_free(preset); @@ -641,7 +641,7 @@ LV2Block::load_state(World& world, const FilePath& path) LilvState* state = lilv_state_new_from_file( lworld, - &world.uri_map().urid_map_feature()->urid_map, + &world.uri_map().urid_map(), subject, path.c_str()); @@ -692,8 +692,8 @@ LV2Block::save_preset(const URI& uri, { World& world = parent_graph()->engine().world(); LilvWorld* lworld = world.lilv_world(); - LV2_URID_Map* lmap = &world.uri_map().urid_map_feature()->urid_map; - LV2_URID_Unmap* lunmap = &world.uri_map().urid_unmap_feature()->urid_unmap; + LV2_URID_Map* lmap = &world.uri_map().urid_map(); + LV2_URID_Unmap* lunmap = &world.uri_map().urid_unmap(); const FilePath path = FilePath(uri.path()); const FilePath dirname = path.parent_path(); diff --git a/src/server/UndoStack.cpp b/src/server/UndoStack.cpp index 40951468..7aea1ba5 100644 --- a/src/server/UndoStack.cpp +++ b/src/server/UndoStack.cpp @@ -203,7 +203,7 @@ UndoStack::write_entry(Sratom* sratom, "first")); ctx.flags = SERD_LIST_CONT; - sratom_write(sratom, &_map.urid_unmap_feature()->urid_unmap, SERD_LIST_CONT, + sratom_write(sratom, &_map.urid_unmap(), SERD_LIST_CONT, &node, &p, atom->type, atom->size, LV2_ATOM_BODY_CONST(atom)); @@ -236,7 +236,7 @@ UndoStack::save(FILE* stream, const char* name) stream); // Configure sratom to write directly to the writer (and thus the socket) - Sratom* sratom = sratom_new(&_map.urid_map_feature()->urid_map); + Sratom* sratom = sratom_new(&_map.urid_map()); sratom_set_sink(sratom, reinterpret_cast<const char*>(base.buf), reinterpret_cast<SerdStatementSink>(serd_writer_write_statement), diff --git a/tests/ingen_test.cpp b/tests/ingen_test.cpp index ec417978..3e33bfd4 100644 --- a/tests/ingen_test.cpp +++ b/tests/ingen_test.cpp @@ -124,7 +124,7 @@ main(int argc, char** argv) // Read commands - AtomForge forge(world->uri_map().urid_map_feature()->urid_map); + AtomForge forge(world->uri_map().urid_map()); sratom_set_object_mode(&forge.sratom(), SRATOM_OBJECT_MODE_BLANK_SUBJECT); |