diff options
Diffstat (limited to 'src/shared')
-rw-r--r-- | src/shared/Builder.cpp | 4 | ||||
-rw-r--r-- | src/shared/LV2Atom.cpp | 4 | ||||
-rw-r--r-- | src/shared/LV2URIMap.cpp | 86 | ||||
-rw-r--r-- | src/shared/LV2URIMap.hpp | 73 | ||||
-rw-r--r-- | src/shared/ResourceImpl.cpp | 2 | ||||
-rw-r--r-- | src/shared/ResourceImpl.hpp | 14 | ||||
-rw-r--r-- | src/shared/URIs.cpp | 125 | ||||
-rw-r--r-- | src/shared/URIs.hpp | 103 | ||||
-rw-r--r-- | src/shared/World.cpp | 15 | ||||
-rw-r--r-- | src/shared/wscript | 1 |
10 files changed, 257 insertions, 170 deletions
diff --git a/src/shared/Builder.cpp b/src/shared/Builder.cpp index 5539e958..83c2eafc 100644 --- a/src/shared/Builder.cpp +++ b/src/shared/Builder.cpp @@ -33,7 +33,7 @@ using namespace Raul; namespace Ingen { namespace Shared { -Builder::Builder(SharedPtr<Shared::LV2URIMap> uris, CommonInterface& interface) +Builder::Builder(SharedPtr<Shared::URIs> uris, CommonInterface& interface) : _uris(uris) , _interface(interface) { @@ -42,7 +42,7 @@ Builder::Builder(SharedPtr<Shared::LV2URIMap> uris, CommonInterface& interface) void Builder::build(SharedPtr<const GraphObject> object) { - const LV2URIMap& uris = *_uris.get(); + const URIs& uris = *_uris.get(); SharedPtr<const Patch> patch = PtrCast<const Patch>(object); if (patch) { if (!object->path().is_root()) { diff --git a/src/shared/LV2Atom.cpp b/src/shared/LV2Atom.cpp index 4b4cbec5..3381b90b 100644 --- a/src/shared/LV2Atom.cpp +++ b/src/shared/LV2Atom.cpp @@ -32,7 +32,7 @@ namespace Shared { namespace LV2Atom { bool -to_atom(const Shared::LV2URIMap& uris, const LV2_Atom* object, Raul::Atom& atom) +to_atom(const Shared::URIs& uris, const LV2_Atom* object, Raul::Atom& atom) { if (object->type == uris.atom_String.id) { atom = Raul::Atom((char*)(object + 1)); @@ -54,7 +54,7 @@ to_atom(const Shared::LV2URIMap& uris, const LV2_Atom* object, Raul::Atom& atom) * object->size should be the capacity of the object (not including header) */ bool -from_atom(const Shared::LV2URIMap& uris, const Raul::Atom& atom, LV2_Atom* object) +from_atom(const Shared::URIs& uris, const Raul::Atom& atom, LV2_Atom* object) { char* str; switch (atom.type()) { diff --git a/src/shared/LV2URIMap.cpp b/src/shared/LV2URIMap.cpp index 7019f193..78d22b70 100644 --- a/src/shared/LV2URIMap.cpp +++ b/src/shared/LV2URIMap.cpp @@ -37,88 +37,8 @@ using namespace Raul; namespace Ingen { namespace Shared { -LV2URIMap::Quark::Quark(const char* c_str) - : Raul::URI(c_str) - , id(g_quark_from_string(c_str)) -{ -} - -const char* -LV2URIMap::Quark::c_str() const -{ - return g_quark_to_string(id); -} - -#define NS_CTX "http://lv2plug.in/ns/ext/contexts#" -#define NS_INGEN "http://drobilla.net/ns/ingen#" -#define NS_INGENUI "http://drobilla.net/ns/ingenuity#" -#define NS_LV2 "http://lv2plug.in/ns/lv2core#" -#define NS_MIDI "http://drobilla.net/ns/ext/midi#" -#define NS_MIDI "http://drobilla.net/ns/ext/midi#" -#define NS_RDF "http://www.w3.org/1999/02/22-rdf-syntax-ns#" -#define NS_RDFS "http://www.w3.org/2000/01/rdf-schema#" - -LV2URIMap::LV2URIMap() - : atom_AtomTransfer (LV2_ATOM_URI "#AtomTransfer") - , atom_Bool (LV2_ATOM_URI "#Bool") - , atom_Float32 (LV2_ATOM_URI "#Float32") - , atom_Int32 (LV2_ATOM_URI "#Int32") - , atom_MessagePort (LV2_ATOM_URI "#MessagePort") - , atom_String (LV2_ATOM_URI "#String") - , atom_ValuePort (LV2_ATOM_URI "#ValuePort") - , atom_Vector (LV2_ATOM_URI "#Vector") - , atom_supports (LV2_ATOM_URI "#supports") - , ctx_AudioContext (NS_CTX "AudioContext") - , ctx_MessageContext (NS_CTX "MessageContext") - , ctx_context (NS_CTX "context") - , doap_name ("http://usefulinc.com/ns/doap#name") - , ev_EventPort ("http://lv2plug.in/ns/ext/event#EventPort") - , ingen_Internal (NS_INGEN "Internal") - , ingen_Node (NS_INGEN "Node") - , ingen_Patch (NS_INGEN "Patch") - , ingen_Port (NS_INGEN "Port") - , ingen_broadcast (NS_INGEN "broadcast") - , ingen_controlBinding (NS_INGEN "controlBinding") - , ingen_document (NS_INGEN "document") - , ingen_enabled (NS_INGEN "enabled") - , ingen_engine (NS_INGEN "engine") - , ingen_nil (NS_INGEN "nil") - , ingen_node (NS_INGEN "node") - , ingen_polyphonic (NS_INGEN "polyphonic") - , ingen_polyphony (NS_INGEN "polyphony") - , ingen_sampleRate (NS_INGEN "sampleRate") - , ingen_selected (NS_INGEN "selected") - , ingen_value (NS_INGEN "value") - , ingenui_canvas_x (NS_INGENUI "canvas-x") - , ingenui_canvas_y (NS_INGENUI "canvas-y") - , lv2_AudioPort (NS_LV2 "AudioPort") - , lv2_ControlPort (NS_LV2 "ControlPort") - , lv2_InputPort (NS_LV2 "InputPort") - , lv2_OutputPort (NS_LV2 "OutputPort") - , lv2_Plugin (NS_LV2 "Plugin") - , lv2_connectionOptional(NS_LV2 "connectionOptional") - , lv2_default (NS_LV2 "default") - , lv2_index (NS_LV2 "index") - , lv2_integer (NS_LV2 "integer") - , lv2_maximum (NS_LV2 "maximum") - , lv2_minimum (NS_LV2 "minimum") - , lv2_name (NS_LV2 "name") - , lv2_portProperty (NS_LV2 "portProperty") - , lv2_sampleRate (NS_LV2 "sampleRate") - , lv2_symbol (NS_LV2 "symbol") - , lv2_toggled (NS_LV2 "toggled") - , midi_Bender (NS_MIDI "Bender") - , midi_ChannelPressure (NS_MIDI "ChannelPressure") - , midi_Controller (NS_MIDI "Controller") - , midi_MidiEvent ("http://lv2plug.in/ns/ext/midi#MidiEvent") - , midi_Note (NS_MIDI "Note") - , midi_controllerNumber (NS_MIDI "controllerNumber") - , midi_noteNumber (NS_MIDI "noteNumber") - , rdf_instanceOf (NS_RDF "instanceOf") - , rdf_type (NS_RDF "type") - , rdfs_seeAlso (NS_RDFS "seeAlso") - , ui_Events ("http://lv2plug.in/ns/extensions/ui#Events") - , wildcard (NS_INGEN "wildcard") +LV2URIMap::LV2URIMap(URIs& uris) + : _uris(uris) { uri_map_feature_data.uri_to_id = &LV2URIMap::uri_map_uri_to_id; uri_map_feature_data.callback_data = this; @@ -126,8 +46,6 @@ LV2URIMap::LV2URIMap() uri_map_feature.data = &uri_map_feature_data; } -struct null_deleter { void operator()(void const *) const {} }; - uint32_t LV2URIMap::uri_to_id(const char* map, const char* uri) diff --git a/src/shared/LV2URIMap.hpp b/src/shared/LV2URIMap.hpp index 8c126a0e..35baa9f8 100644 --- a/src/shared/LV2URIMap.hpp +++ b/src/shared/LV2URIMap.hpp @@ -28,6 +28,7 @@ #include "lv2/lv2plug.in/ns/ext/uri-map/uri-map.h" #include "LV2Features.hpp" +#include "URIs.hpp" namespace Ingen { namespace Shared { @@ -36,7 +37,7 @@ namespace Shared { */ class LV2URIMap : public boost::noncopyable, public LV2Features::Feature { public: - LV2URIMap(); + LV2URIMap(URIs& uris); SharedPtr<LV2_Feature> feature(Shared::World*, Node*) { return SharedPtr<LV2_Feature>(&uri_map_feature, NullDeleter<LV2_Feature>); @@ -56,79 +57,13 @@ private: LV2_Feature uri_map_feature; LV2_URI_Map_Feature uri_map_feature_data; -typedef std::map<uint16_t, uint32_t> EventToGlobal; + typedef std::map<uint16_t, uint32_t> EventToGlobal; typedef std::map<uint32_t, uint16_t> GlobalToEvent; EventToGlobal _event_to_global; GlobalToEvent _global_to_event; -public: - struct Quark : public Raul::URI { - Quark(const char* str); - const char* c_str() const; - uint32_t id; - }; - - const Quark atom_AtomTransfer; - const Quark atom_Bool; - const Quark atom_Float32; - const Quark atom_Int32; - const Quark atom_MessagePort; - const Quark atom_String; - const Quark atom_ValuePort; - const Quark atom_Vector; - const Quark atom_supports; - const Quark ctx_AudioContext; - const Quark ctx_MessageContext; - const Quark ctx_context; - const Quark doap_name; - const Quark ev_EventPort; - const Quark ingen_Internal; - const Quark ingen_Node; - const Quark ingen_Patch; - const Quark ingen_Port; - const Quark ingen_broadcast; - const Quark ingen_controlBinding; - const Quark ingen_document; - const Quark ingen_enabled; - const Quark ingen_engine; - const Quark ingen_nil; - const Quark ingen_node; - const Quark ingen_polyphonic; - const Quark ingen_polyphony; - const Quark ingen_sampleRate; - const Quark ingen_selected; - const Quark ingen_value; - const Quark ingenui_canvas_x; - const Quark ingenui_canvas_y; - const Quark lv2_AudioPort; - const Quark lv2_ControlPort; - const Quark lv2_InputPort; - const Quark lv2_OutputPort; - const Quark lv2_Plugin; - const Quark lv2_connectionOptional; - const Quark lv2_default; - const Quark lv2_index; - const Quark lv2_integer; - const Quark lv2_maximum; - const Quark lv2_minimum; - const Quark lv2_name; - const Quark lv2_portProperty; - const Quark lv2_sampleRate; - const Quark lv2_symbol; - const Quark lv2_toggled; - const Quark midi_Bender; - const Quark midi_ChannelPressure; - const Quark midi_Controller; - const Quark midi_MidiEvent; - const Quark midi_Note; - const Quark midi_controllerNumber; - const Quark midi_noteNumber; - const Quark rdf_instanceOf; - const Quark rdf_type; - const Quark rdfs_seeAlso; - const Quark ui_Events; - const Quark wildcard; + URIs& _uris; }; } // namespace Shared diff --git a/src/shared/ResourceImpl.cpp b/src/shared/ResourceImpl.cpp index 29b464ee..1f9662f3 100644 --- a/src/shared/ResourceImpl.cpp +++ b/src/shared/ResourceImpl.cpp @@ -103,7 +103,7 @@ ResourceImpl::get_property(const Raul::URI& uri) const } bool -ResourceImpl::type(const LV2URIMap& uris, +ResourceImpl::type(const URIs& uris, const Properties& properties, bool& patch, bool& node, diff --git a/src/shared/ResourceImpl.hpp b/src/shared/ResourceImpl.hpp index da358c0a..13f1bd8f 100644 --- a/src/shared/ResourceImpl.hpp +++ b/src/shared/ResourceImpl.hpp @@ -26,15 +26,17 @@ namespace Ingen { namespace Shared { -class LV2URIMap; +class URIs; class ResourceImpl : virtual public Resource { public: - ResourceImpl(LV2URIMap& uris, const Raul::URI& uri) - : _uris(uris), _uri(uri) {} + ResourceImpl(URIs& uris, const Raul::URI& uri) + : _uris(uris) + , _uri(uri) + {} - LV2URIMap& uris() const { return _uris; } + URIs& uris() const { return _uris; } virtual void set_uri(const Raul::URI& uri) { _uri = uri; } virtual const Raul::URI& uri() const { return _uri; } @@ -61,7 +63,7 @@ public: * If some coherent ingen type is found, true is returned and the appropriate * output parameter set to true. Otherwise false is returned. */ - static bool type(const LV2URIMap& uris, + static bool type(const URIs& uris, const Properties& properties, bool& patch, bool& node, @@ -71,7 +73,7 @@ public: protected: const Raul::Atom& set_property(const Raul::URI& uri, const Raul::Atom& value) const; - LV2URIMap& _uris; + URIs& _uris; private: Raul::URI _uri; diff --git a/src/shared/URIs.cpp b/src/shared/URIs.cpp new file mode 100644 index 00000000..a3a67cd2 --- /dev/null +++ b/src/shared/URIs.cpp @@ -0,0 +1,125 @@ +/* This file is part of Ingen. + * Copyright 2008-2011 David Robillard <http://drobilla.net> + * + * Ingen is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) any later + * version. + * + * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#define __STDC_LIMIT_MACROS 1 + +#include <assert.h> +#include <stdint.h> + +#include <glib.h> + +#include <boost/shared_ptr.hpp> + +#include "raul/log.hpp" + +#include "lv2/lv2plug.in/ns/ext/atom/atom.h" + +#include "URIs.hpp" + +using namespace std; +using namespace Raul; + +namespace Ingen { +namespace Shared { + +URIs::Quark::Quark(const char* c_str) + : Raul::URI(c_str) + , id(g_quark_from_string(c_str)) +{ +} + +const char* +URIs::Quark::c_str() const +{ + return g_quark_to_string(id); +} + +#define NS_CTX "http://lv2plug.in/ns/ext/contexts#" +#define NS_INGEN "http://drobilla.net/ns/ingen#" +#define NS_INGENUI "http://drobilla.net/ns/ingenuity#" +#define NS_LV2 "http://lv2plug.in/ns/lv2core#" +#define NS_MIDI "http://drobilla.net/ns/ext/midi#" +#define NS_MIDI "http://drobilla.net/ns/ext/midi#" +#define NS_RDF "http://www.w3.org/1999/02/22-rdf-syntax-ns#" +#define NS_RDFS "http://www.w3.org/2000/01/rdf-schema#" + +URIs::URIs() + : atom_AtomTransfer (LV2_ATOM_URI "#AtomTransfer") + , atom_Bool (LV2_ATOM_URI "#Bool") + , atom_Float32 (LV2_ATOM_URI "#Float32") + , atom_Int32 (LV2_ATOM_URI "#Int32") + , atom_MessagePort (LV2_ATOM_URI "#MessagePort") + , atom_String (LV2_ATOM_URI "#String") + , atom_ValuePort (LV2_ATOM_URI "#ValuePort") + , atom_Vector (LV2_ATOM_URI "#Vector") + , atom_supports (LV2_ATOM_URI "#supports") + , ctx_AudioContext (NS_CTX "AudioContext") + , ctx_MessageContext (NS_CTX "MessageContext") + , ctx_context (NS_CTX "context") + , doap_name ("http://usefulinc.com/ns/doap#name") + , ev_EventPort ("http://lv2plug.in/ns/ext/event#EventPort") + , ingen_Internal (NS_INGEN "Internal") + , ingen_Node (NS_INGEN "Node") + , ingen_Patch (NS_INGEN "Patch") + , ingen_Port (NS_INGEN "Port") + , ingen_broadcast (NS_INGEN "broadcast") + , ingen_controlBinding (NS_INGEN "controlBinding") + , ingen_document (NS_INGEN "document") + , ingen_enabled (NS_INGEN "enabled") + , ingen_engine (NS_INGEN "engine") + , ingen_nil (NS_INGEN "nil") + , ingen_node (NS_INGEN "node") + , ingen_polyphonic (NS_INGEN "polyphonic") + , ingen_polyphony (NS_INGEN "polyphony") + , ingen_sampleRate (NS_INGEN "sampleRate") + , ingen_selected (NS_INGEN "selected") + , ingen_value (NS_INGEN "value") + , ingenui_canvas_x (NS_INGENUI "canvas-x") + , ingenui_canvas_y (NS_INGENUI "canvas-y") + , lv2_AudioPort (NS_LV2 "AudioPort") + , lv2_ControlPort (NS_LV2 "ControlPort") + , lv2_InputPort (NS_LV2 "InputPort") + , lv2_OutputPort (NS_LV2 "OutputPort") + , lv2_Plugin (NS_LV2 "Plugin") + , lv2_connectionOptional(NS_LV2 "connectionOptional") + , lv2_default (NS_LV2 "default") + , lv2_index (NS_LV2 "index") + , lv2_integer (NS_LV2 "integer") + , lv2_maximum (NS_LV2 "maximum") + , lv2_minimum (NS_LV2 "minimum") + , lv2_name (NS_LV2 "name") + , lv2_portProperty (NS_LV2 "portProperty") + , lv2_sampleRate (NS_LV2 "sampleRate") + , lv2_symbol (NS_LV2 "symbol") + , lv2_toggled (NS_LV2 "toggled") + , midi_Bender (NS_MIDI "Bender") + , midi_ChannelPressure (NS_MIDI "ChannelPressure") + , midi_Controller (NS_MIDI "Controller") + , midi_MidiEvent ("http://lv2plug.in/ns/ext/midi#MidiEvent") + , midi_Note (NS_MIDI "Note") + , midi_controllerNumber (NS_MIDI "controllerNumber") + , midi_noteNumber (NS_MIDI "noteNumber") + , rdf_instanceOf (NS_RDF "instanceOf") + , rdf_type (NS_RDF "type") + , rdfs_seeAlso (NS_RDFS "seeAlso") + , ui_Events ("http://lv2plug.in/ns/extensions/ui#Events") + , wildcard (NS_INGEN "wildcard") +{ +} + +} // namespace Shared +} // namespace Ingen diff --git a/src/shared/URIs.hpp b/src/shared/URIs.hpp new file mode 100644 index 00000000..7083507e --- /dev/null +++ b/src/shared/URIs.hpp @@ -0,0 +1,103 @@ +/* This file is part of Ingen. + * Copyright 2008-2011 David Robillard <http://drobilla.net> + * + * Ingen is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) any later + * version. + * + * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef INGEN_SHARED_URIS_HPP +#define INGEN_SHARED_URIS_HPP + +#include <boost/utility.hpp> + +#include "raul/URI.hpp" + +namespace Ingen { +namespace Shared { + +class URIs : public boost::noncopyable { +public: + URIs(); + + struct Quark : public Raul::URI { + Quark(const char* str); + const char* c_str() const; + uint32_t id; + }; + + const Quark atom_AtomTransfer; + const Quark atom_Bool; + const Quark atom_Float32; + const Quark atom_Int32; + const Quark atom_MessagePort; + const Quark atom_String; + const Quark atom_ValuePort; + const Quark atom_Vector; + const Quark atom_supports; + const Quark ctx_AudioContext; + const Quark ctx_MessageContext; + const Quark ctx_context; + const Quark doap_name; + const Quark ev_EventPort; + const Quark ingen_Internal; + const Quark ingen_Node; + const Quark ingen_Patch; + const Quark ingen_Port; + const Quark ingen_broadcast; + const Quark ingen_controlBinding; + const Quark ingen_document; + const Quark ingen_enabled; + const Quark ingen_engine; + const Quark ingen_nil; + const Quark ingen_node; + const Quark ingen_polyphonic; + const Quark ingen_polyphony; + const Quark ingen_sampleRate; + const Quark ingen_selected; + const Quark ingen_value; + const Quark ingenui_canvas_x; + const Quark ingenui_canvas_y; + const Quark lv2_AudioPort; + const Quark lv2_ControlPort; + const Quark lv2_InputPort; + const Quark lv2_OutputPort; + const Quark lv2_Plugin; + const Quark lv2_connectionOptional; + const Quark lv2_default; + const Quark lv2_index; + const Quark lv2_integer; + const Quark lv2_maximum; + const Quark lv2_minimum; + const Quark lv2_name; + const Quark lv2_portProperty; + const Quark lv2_sampleRate; + const Quark lv2_symbol; + const Quark lv2_toggled; + const Quark midi_Bender; + const Quark midi_ChannelPressure; + const Quark midi_Controller; + const Quark midi_MidiEvent; + const Quark midi_Note; + const Quark midi_controllerNumber; + const Quark midi_noteNumber; + const Quark rdf_instanceOf; + const Quark rdf_type; + const Quark rdfs_seeAlso; + const Quark ui_Events; + const Quark wildcard; +}; + +} // namespace Shared +} // namespace Ingen + +#endif // INGEN_SHARED_LV2URIMAP_HPP diff --git a/src/shared/World.cpp b/src/shared/World.cpp index ba1e6802..4f6b279b 100644 --- a/src/shared/World.cpp +++ b/src/shared/World.cpp @@ -103,11 +103,12 @@ public: , conf(conf) , lv2_features(NULL) , rdf_world(new Sord::World()) - , uris(new Shared::LV2URIMap()) + , uris(new Shared::URIs()) + , lv2_uri_map(new Ingen::Shared::LV2URIMap(*uris.get())) , lilv_world(lilv_world_new()) { lv2_features = new Ingen::Shared::LV2Features(); - lv2_features->add_feature(uris); + lv2_features->add_feature(lv2_uri_map); lilv_world_load_all(lilv_world); // Set up RDF namespaces @@ -165,7 +166,8 @@ public: Raul::Configuration* conf; LV2Features* lv2_features; Sord::World* rdf_world; - SharedPtr<LV2URIMap> uris; + SharedPtr<URIs> uris; + SharedPtr<LV2URIMap> lv2_uri_map; SharedPtr<ServerInterface> engine; SharedPtr<EngineBase> local_engine; SharedPtr<Serialisation::Serialiser> serialiser; @@ -206,9 +208,10 @@ SharedPtr<ClientInterface> World::client() { return _impl->clien Raul::Configuration* World::conf() { return _impl->conf; } LV2Features* World::lv2_features() { return _impl->lv2_features; } -LilvWorld* World::lilv_world() { return _impl->lilv_world; } -Sord::World* World::rdf_world() { return _impl->rdf_world; } -SharedPtr<LV2URIMap> World::uris() { return _impl->uris; } +LilvWorld* World::lilv_world() { return _impl->lilv_world; } +Sord::World* World::rdf_world() { return _impl->rdf_world; } +SharedPtr<URIs> World::uris() { return _impl->uris; } +SharedPtr<LV2URIMap> World::lv2_uri_map() { return _impl->lv2_uri_map; } /** Load an Ingen module. * @return true on success, false on failure diff --git a/src/shared/wscript b/src/shared/wscript index d402a813..9ee7ba31 100644 --- a/src/shared/wscript +++ b/src/shared/wscript @@ -22,6 +22,7 @@ def build(bld): Module.cpp ResourceImpl.cpp Store.cpp + URIs.cpp World.cpp runtime_paths.cpp ''' |