diff options
Diffstat (limited to 'src/engine')
-rw-r--r-- | src/engine/ClientBroadcaster.cpp | 16 | ||||
-rw-r--r-- | src/engine/GraphObjectImpl.cpp | 38 | ||||
-rw-r--r-- | src/engine/GraphObjectImpl.hpp | 38 | ||||
-rw-r--r-- | src/engine/HTTPClientSender.cpp | 29 | ||||
-rw-r--r-- | src/engine/HTTPClientSender.hpp | 6 | ||||
-rw-r--r-- | src/engine/LADSPANode.cpp | 6 | ||||
-rw-r--r-- | src/engine/OSCClientSender.cpp | 21 | ||||
-rw-r--r-- | src/engine/OSCClientSender.hpp | 8 | ||||
-rw-r--r-- | src/engine/OSCEngineReceiver.cpp | 25 | ||||
-rw-r--r-- | src/engine/ObjectSender.cpp | 36 | ||||
-rw-r--r-- | src/engine/QueuedEngineInterface.cpp | 24 | ||||
-rw-r--r-- | src/engine/QueuedEngineInterface.hpp | 6 | ||||
-rw-r--r-- | src/engine/events/CreateNodeEvent.cpp | 2 | ||||
-rw-r--r-- | src/engine/events/CreatePatchEvent.cpp | 4 | ||||
-rw-r--r-- | src/engine/events/CreatePortEvent.cpp | 7 | ||||
-rw-r--r-- | src/engine/events/RequestMetadataEvent.cpp | 21 | ||||
-rw-r--r-- | src/engine/events/RequestMetadataEvent.hpp | 4 | ||||
-rw-r--r-- | src/engine/events/SetMetadataEvent.cpp | 77 | ||||
-rw-r--r-- | src/engine/events/SetMetadataEvent.hpp | 6 |
19 files changed, 144 insertions, 230 deletions
diff --git a/src/engine/ClientBroadcaster.cpp b/src/engine/ClientBroadcaster.cpp index c0f107de..8aaffe94 100644 --- a/src/engine/ClientBroadcaster.cpp +++ b/src/engine/ClientBroadcaster.cpp @@ -162,27 +162,15 @@ ClientBroadcaster::send_disconnection(const Path& src_port_path, const Path& dst } -/** Send notification of a variable update. - * - * Like control changes, does not send update to client that set the variable, if applicable. - */ -void -ClientBroadcaster::send_variable_change(const URI& node_path, const URI& key, const Atom& value) -{ - for (Clients::const_iterator i = _clients.begin(); i != _clients.end(); ++i) - (*i).second->set_variable(node_path, key, value); -} - - /** Send notification of a property update. * * Like control changes, does not send update to client that set the property, if applicable. */ void -ClientBroadcaster::send_property_change(const URI& node_path, const URI& key, const Atom& value) +ClientBroadcaster::send_property_change(const URI& subject, const URI& key, const Atom& value) { for (Clients::const_iterator i = _clients.begin(); i != _clients.end(); ++i) - (*i).second->set_property(node_path, key, value); + (*i).second->set_property(subject, key, value); } diff --git a/src/engine/GraphObjectImpl.cpp b/src/engine/GraphObjectImpl.cpp index ef4e2cd4..40cdc792 100644 --- a/src/engine/GraphObjectImpl.cpp +++ b/src/engine/GraphObjectImpl.cpp @@ -27,26 +27,38 @@ namespace Ingen { using namespace Shared; + +GraphObjectImpl::GraphObjectImpl(GraphObjectImpl* parent, const std::string& name, bool polyphonic) + : ResourceImpl((parent ? parent->path().base() : Raul::Path::root_uri) + name) + , _parent(parent) + , _name(name) + , _meta(std::string("meta:#") + path().chop_start("/")) + , _polyphonic(polyphonic) +{ + assert(parent == NULL || _name.length() > 0); + assert(_name.find("/") == std::string::npos); +} + + +void +GraphObjectImpl::add_meta_property(const Raul::URI& key, const Atom& value) +{ + _meta.add_property(key, value); +} + + void -GraphObjectImpl::set_variable(const Raul::URI& key, const Atom& value) +GraphObjectImpl::set_meta_property(const Raul::URI& key, const Atom& value) { - // Ignore duplicate statements - typedef Resource::Properties::const_iterator iterator; - const std::pair<iterator,iterator> range = _variables.equal_range(key); - for (iterator i = range.first; i != range.second; ++i) - if (i->second == value) - return; - - _variables.insert(make_pair(key, value)); + _meta.set_property(key, value); } const Atom& -GraphObjectImpl::get_variable(const Raul::URI& key) +GraphObjectImpl::get_property(const Raul::URI& key) const { - static const Atom null_atom; - Properties::iterator i = _variables.find(key); - return (i != _variables.end()) ? (*i).second : null_atom; + Resource::Properties::const_iterator i = properties().find(key); + return (i != properties().end()) ? i->second : _meta.get_property(key); } diff --git a/src/engine/GraphObjectImpl.hpp b/src/engine/GraphObjectImpl.hpp index a6f6b532..c8b0c13c 100644 --- a/src/engine/GraphObjectImpl.hpp +++ b/src/engine/GraphObjectImpl.hpp @@ -49,15 +49,17 @@ class GraphObjectImpl : virtual public Ingen::Shared::GraphObject public: virtual ~GraphObjectImpl() {} + const Raul::URI meta_uri() const { return _meta.uri(); } + const Raul::URI uri() const { return path(); } + const Raul::Symbol symbol() const { return _name; } + bool polyphonic() const { return _polyphonic; } virtual bool set_polyphonic(Raul::Maid& maid, bool p) { _polyphonic = p; return true; } - GraphObject* graph_parent() const { return _parent; } - - const Raul::URI uri() const { return path(); } - - inline GraphObjectImpl* parent() const { return _parent; } - const Raul::Symbol symbol() const { return _name; } + GraphObject* graph_parent() const { return _parent; } + GraphObjectImpl* parent() const { return _parent; } + Resource& meta() { return _meta; } + const Resource& meta() const { return _meta; } virtual void process(ProcessContext& context) = 0; @@ -68,18 +70,16 @@ public: assert(_name.find("/") == std::string::npos); } - const Raul::Atom& get_variable(const Raul::URI& key); - void set_variable(const Raul::URI& key, const Raul::Atom& value); - - const Properties& variables() const { return _variables; } - Properties& variables() { return _variables; } + const Raul::Atom& get_property(const Raul::URI& key) const; + void add_meta_property(const Raul::URI& key, const Raul::Atom& value); + void set_meta_property(const Raul::URI& key, const Raul::Atom& value); /** The Patch this object is a child of. */ virtual PatchImpl* parent_patch() const; /** Raul::Path is dynamically generated from parent to ease renaming */ const Raul::Path path() const { - if (_parent == NULL) + if (!_parent) return Raul::Path(std::string("/").append(_name)); else if (_parent->path().is_root()) return Raul::Path(std::string("/").append(_name)); @@ -90,22 +90,12 @@ public: SharedPtr<GraphObject> find_child(const std::string& name) const; protected: - GraphObjectImpl(GraphObjectImpl* parent, const std::string& name, bool polyphonic=false) - : ResourceImpl((parent ? parent->path().base() : Raul::Path::root_uri) + name) - , _parent(parent) - , _name(name) - , _polyphonic(polyphonic) - { - assert(parent == NULL || _name.length() > 0); - assert(_name.find("/") == std::string::npos); - } + GraphObjectImpl(GraphObjectImpl* parent, const std::string& name, bool polyphonic=false); GraphObjectImpl* _parent; std::string _name; + ResourceImpl _meta; bool _polyphonic; - -private: - Properties _variables; }; diff --git a/src/engine/HTTPClientSender.cpp b/src/engine/HTTPClientSender.cpp index 83d3f1b2..fa6421b9 100644 --- a/src/engine/HTTPClientSender.cpp +++ b/src/engine/HTTPClientSender.cpp @@ -50,7 +50,7 @@ HTTPClientSender::error(const std::string& msg) void -HTTPClientSender::put(const Path& path, +HTTPClientSender::put(const URI& path, const Shared::Resource::Properties& properties) { cerr << "HTTP CLIENT PUT " << path << endl; @@ -75,7 +75,7 @@ HTTPClientSender::clear_patch(const Path& patch_path) void HTTPClientSender::connect(const Path& src_path, const Path& dst_path) { - string msg = string( + const string msg = string( "@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .\n" "@prefix ingen: <http://drobilla.net/ns/ingen#> .\n" "@prefix lv2var: <http://lv2plug.in/ns/ext/instance-var#> .\n\n<").append( @@ -94,30 +94,15 @@ HTTPClientSender::disconnect(const Path& src_path, const Path& dst_path) void -HTTPClientSender::set_variable(const URI& path, const URI& key, const Atom& value) +HTTPClientSender::set_property(const URI& subject, const URI& key, const Atom& value) { Redland::Node node = AtomRDF::atom_to_node(*_engine.world()->rdf_world, value); - string msg = string( - "@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .\n" - "@prefix ingenuity: <http://drobilla.net/ns/ingenuity#> .\n" - "@prefix lv2var: <http://lv2plug.in/ns/ext/instance-var#> .\n\n<").append( - path.str()).append("> lv2var:variable [\n" - "rdf:predicate ").append(key.str()).append(" ;\n" - "rdf:value ").append(node.to_string()).append("\n] .\n"); - send_chunk(msg); -} - - -void -HTTPClientSender::set_property(const URI& path, const URI& key, const Atom& value) -{ - Redland::Node node = AtomRDF::atom_to_node(*_engine.world()->rdf_world, value); - string msg = string( + const string msg = string( "@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .\n" "@prefix ingen: <http://drobilla.net/ns/ingen#> .\n" "@prefix ingenuity: <http://drobilla.net/ns/ingenuity#> .\n" "@prefix lv2var: <http://lv2plug.in/ns/ext/instance-var#> .\n\n<").append( - path.str()).append("> ingen:property [\n" + subject.str()).append("> ingen:property [\n" "rdf:predicate ").append(key.str()).append(" ;\n" "rdf:value ").append(node.to_string()).append("\n] .\n"); send_chunk(msg); @@ -128,7 +113,7 @@ void HTTPClientSender::set_port_value(const Path& port_path, const Atom& value) { Redland::Node node = AtomRDF::atom_to_node(*_engine.world()->rdf_world, value); - string msg = string( + const string msg = string( "@prefix ingen: <http://drobilla.net/ns/ingen#> .\n\n<").append( port_path.str()).append("> ingen:value ").append(node.to_string()).append(" .\n"); send_chunk(msg); @@ -148,7 +133,7 @@ HTTPClientSender::set_voice_value(const Path& port_path, uint32_t voice, const A void HTTPClientSender::activity(const Path& path) { - string msg = string( + const string msg = string( "@prefix ingen: <http://drobilla.net/ns/ingen#> .\n\n<").append( path.str()).append("> ingen:activity true .\n"); send_chunk(msg); diff --git a/src/engine/HTTPClientSender.hpp b/src/engine/HTTPClientSender.hpp index fb045194..9a7948ff 100644 --- a/src/engine/HTTPClientSender.hpp +++ b/src/engine/HTTPClientSender.hpp @@ -78,7 +78,7 @@ public: const Raul::URI& type_uri, const Raul::Symbol& symbol); - virtual void put(const Raul::Path& path, + virtual void put(const Raul::URI& path, const Shared::Resource::Properties& properties); virtual void clear_patch(const Raul::Path& path); @@ -94,10 +94,6 @@ public: virtual void disconnect(const Raul::Path& src_port_path, const Raul::Path& dst_port_path); - virtual void set_variable(const Raul::URI& subject_path, - const Raul::URI& predicate, - const Raul::Atom& value); - virtual void set_property(const Raul::URI& subject_path, const Raul::URI& predicate, const Raul::Atom& value); diff --git a/src/engine/LADSPANode.cpp b/src/engine/LADSPANode.cpp index 4431065a..e761ff60 100644 --- a/src/engine/LADSPANode.cpp +++ b/src/engine/LADSPANode.cpp @@ -241,11 +241,11 @@ LADSPANode::instantiate() if (port->is_input() && port->buffer_size() == 1) { if (min) - port->set_variable("lv2:minimum", min.get()); + port->set_meta_property("lv2:minimum", min.get()); if (max) - port->set_variable("lv2:maximum", max.get()); + port->set_meta_property("lv2:maximum", max.get()); if (default_val) - port->set_variable("lv2:default", default_val.get()); + port->set_meta_property("lv2:default", default_val.get()); } } diff --git a/src/engine/OSCClientSender.cpp b/src/engine/OSCClientSender.cpp index 594266aa..5a941dc2 100644 --- a/src/engine/OSCClientSender.cpp +++ b/src/engine/OSCClientSender.cpp @@ -105,7 +105,7 @@ OSCClientSender::error(const std::string& msg) * PUT a set of properties to a path (see \ref methods). */ void -OSCClientSender::put(const Raul::Path& path, +OSCClientSender::put(const Raul::URI& path, const Shared::Resource::Properties& properties) { cerr << "OSC CLIENT PUT " << path << endl; @@ -183,25 +183,6 @@ OSCClientSender::disconnect(const Path& src_port_path, const Path& dst_port_path /** \page client_osc_namespace - * <h2>/ingen/set_variable</h2> - * \arg \b path (string) - Path of the object associated with variable (node, patch, or port) - * \arg \b key (string) - * \arg \b value (string) - * , - * Notification of a variable. - */ -void -OSCClientSender::set_variable(const URI& path, const URI& key, const Atom& value) -{ - lo_message m = lo_message_new(); - lo_message_add_string(m, path.c_str()); - lo_message_add_string(m, key.c_str()); - AtomLiblo::lo_message_add_atom(m, value); - send_message("/ingen/set_variable", m); -} - - -/** \page client_osc_namespace * <h2>/ingen/set_property</h2> * \arg \b path (string) - Path of the object associated with property (node, patch, or port) * \arg \b key (string) diff --git a/src/engine/OSCClientSender.hpp b/src/engine/OSCClientSender.hpp index 4a0742eb..333fee49 100644 --- a/src/engine/OSCClientSender.hpp +++ b/src/engine/OSCClientSender.hpp @@ -75,7 +75,7 @@ public: const Raul::URI& type_uri, const Raul::Symbol& symbol); - virtual void put(const Raul::Path& path, + virtual void put(const Raul::URI& path, const Shared::Resource::Properties& properties); virtual void clear_patch(const Raul::Path& path); @@ -91,11 +91,7 @@ public: virtual void disconnect(const Raul::Path& src_port_path, const Raul::Path& dst_port_path); - virtual void set_variable(const Raul::URI& subject_path, - const Raul::URI& predicate, - const Raul::Atom& value); - - virtual void set_property(const Raul::URI& subject_path, + virtual void set_property(const Raul::URI& subject, const Raul::URI& predicate, const Raul::Atom& value); diff --git a/src/engine/OSCEngineReceiver.cpp b/src/engine/OSCEngineReceiver.cpp index 21a9b898..6cdc4ea2 100644 --- a/src/engine/OSCEngineReceiver.cpp +++ b/src/engine/OSCEngineReceiver.cpp @@ -641,31 +641,6 @@ OSCEngineReceiver::_midi_learn_cb(const char* path, const char* types, lo_arg** /** \page engine_osc_namespace - * <h2>/ingen/set_variable</h2> - * \arg \b response-id (integer) - * \arg \b object-path (string) - Full path of object to associate variable with - * \arg \b key (string) - Key (index/predicate/ID) for new variable - * \arg \b value (string) - Value of new variable - * - * Set a variable, associated with a graph object. - */ -int -OSCEngineReceiver::_variable_set_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg) -{ - if (argc != 4 || types[0] != 'i' || types[1] != 's' || types[2] != 's') - return 1; - - const char* object_path = &argv[1]->s; - const char* key = &argv[2]->s; - - Raul::Atom value = Raul::AtomLiblo::lo_arg_to_atom(types[3], argv[3]); - - set_variable(object_path, key, value); - return 0; -} - - -/** \page engine_osc_namespace * <h2>/ingen/set_property</h2> * \arg \b response-id (integer) * \arg \b object-path (string) - Full path of object to associate variable with diff --git a/src/engine/ObjectSender.cpp b/src/engine/ObjectSender.cpp index 9bf70cbf..072d6c52 100644 --- a/src/engine/ObjectSender.cpp +++ b/src/engine/ObjectSender.cpp @@ -62,14 +62,10 @@ ObjectSender::send_patch(ClientInterface* client, const PatchImpl* patch, bool r if (bundle) client->transfer_begin(); - client->put(patch->path(), patch->properties()); + client->put(patch->meta_uri(), patch->meta().properties()); + client->put(patch->path(), patch->properties()); if (recursive) { - // Send variables - const GraphObjectImpl::Properties& data = patch->variables(); - for (GraphObjectImpl::Properties::const_iterator j = data.begin(); j != data.end(); ++j) - client->set_variable(patch->path(), (*j).first, (*j).second); - // Send nodes for (List<NodeImpl*>::const_iterator j = patch->nodes().begin(); j != patch->nodes().end(); ++j) { @@ -113,12 +109,7 @@ ObjectSender::send_node(ClientInterface* client, const NodeImpl* node, bool recu if (bundle) client->transfer_begin(); - client->put(node->path(), node->variables()); - - // Send variables - const GraphObjectImpl::Properties& prop = node->variables(); - for (GraphObjectImpl::Properties::const_iterator j = prop.begin(); j != prop.end(); ++j) - client->set_variable(node->path(), (*j).first, (*j).second); + client->put(node->path(), node->properties()); if (recursive) { // Send ports @@ -139,26 +130,19 @@ ObjectSender::send_port(ClientInterface* client, const PortImpl* port, bool bund if (bundle) client->bundle_begin(); - client->put(port->path(), port->properties()); - PatchImpl* graph_parent = dynamic_cast<PatchImpl*>(port->parent_node()); - if (graph_parent && graph_parent->internal_polyphony() > 1) - client->set_variable(port->path(), "ingen:polyphonic", bool(port->polyphonic())); - // Send variables - const GraphObjectImpl::Properties& data = port->variables(); - for (GraphObjectImpl::Properties::const_iterator j = data.begin(); j != data.end(); ++j) - client->set_variable(port->path(), (*j).first, (*j).second); + if (graph_parent) + client->put(port->meta_uri(), port->meta().properties()); + + client->put(port->path(), port->properties()); - // Send properties - const GraphObjectImpl::Properties& prop = port->properties(); - for (GraphObjectImpl::Properties::const_iterator j = prop.begin(); j != prop.end(); ++j) - client->set_property(port->path(), (*j).first, (*j).second); + if (graph_parent && graph_parent->internal_polyphony() > 1) + client->set_property(port->meta_uri(), "ingen:polyphonic", bool(port->polyphonic())); // Send control value if (port->type() == DataType::CONTROL) { - const Sample value = dynamic_cast<const AudioBuffer*>(port->buffer(0))->value_at(0); - //cerr << port->path() << " sending default value " << default_value << endl; + const Sample& value = dynamic_cast<const AudioBuffer*>(port->buffer(0))->value_at(0); client->set_port_value(port->path(), value); } diff --git a/src/engine/QueuedEngineInterface.cpp b/src/engine/QueuedEngineInterface.cpp index 7c9c2c1a..4b2926e7 100644 --- a/src/engine/QueuedEngineInterface.cpp +++ b/src/engine/QueuedEngineInterface.cpp @@ -152,11 +152,15 @@ QueuedEngineInterface::bundle_end() void -QueuedEngineInterface::put(const Path& path, +QueuedEngineInterface::put(const URI& uri, const Resource::Properties& properties) { + size_t hash = uri.find("#"); + bool meta = (hash != string::npos); + Path path(meta ? (string("/") + uri.chop_start("#")) : uri.str()); + typedef Resource::Properties::const_iterator iterator; - cerr << "ENGINE PUT " << path << " {" << endl; + cerr << "ENGINE PUT " << path << " (" << path << ") {" << endl; for (iterator i = properties.begin(); i != properties.end(); ++i) cerr << "\t" << i->first << " = " << i->second << " :: " << i->second.type() << endl; cerr << "}" << endl; @@ -255,20 +259,14 @@ QueuedEngineInterface::midi_learn(const Path& node_path) void -QueuedEngineInterface::set_variable(const URI& path, - const URI& predicate, - const Atom& value) -{ - push_queued(new SetMetadataEvent(_engine, _responder, now(), false, path, predicate, value)); -} - - -void -QueuedEngineInterface::set_property(const URI& path, +QueuedEngineInterface::set_property(const URI& uri, const URI& predicate, const Atom& value) { - push_queued(new SetMetadataEvent(_engine, _responder, now(), true, path, predicate, value)); + size_t hash = uri.find("#"); + bool meta = (hash != string::npos); + Path path = meta ? (string("/") + path.chop_start("/")) : uri.str(); + push_queued(new SetMetadataEvent(_engine, _responder, now(), meta, path, predicate, value)); } // Requests // diff --git a/src/engine/QueuedEngineInterface.hpp b/src/engine/QueuedEngineInterface.hpp index 2a94abff..43237ac8 100644 --- a/src/engine/QueuedEngineInterface.hpp +++ b/src/engine/QueuedEngineInterface.hpp @@ -71,7 +71,7 @@ public: // CommonInterface object commands - virtual void put(const Raul::Path& path, + virtual void put(const Raul::URI& path, const Shared::Resource::Properties& properties); virtual void move(const Raul::Path& old_path, @@ -83,10 +83,6 @@ public: virtual void disconnect(const Raul::Path& src_port_path, const Raul::Path& dst_port_path); - virtual void set_variable(const Raul::URI& subject_path, - const Raul::URI& predicate, - const Raul::Atom& value); - virtual void set_property(const Raul::URI& subject_path, const Raul::URI& predicate, const Raul::Atom& value); diff --git a/src/engine/events/CreateNodeEvent.cpp b/src/engine/events/CreateNodeEvent.cpp index 6f3ed834..718a94a3 100644 --- a/src/engine/events/CreateNodeEvent.cpp +++ b/src/engine/events/CreateNodeEvent.cpp @@ -89,7 +89,7 @@ CreateNodeEvent::pre_process() if (_patch && plugin) { _node = plugin->instantiate(_path.name(), _polyphonic, _patch, _engine); - _node->variables().insert(_properties.begin(), _properties.end()); + _node->properties().insert(_properties.begin(), _properties.end()); if (_node != NULL) { _node->activate(); diff --git a/src/engine/events/CreatePatchEvent.cpp b/src/engine/events/CreatePatchEvent.cpp index f4a60760..16f749a3 100644 --- a/src/engine/events/CreatePatchEvent.cpp +++ b/src/engine/events/CreatePatchEvent.cpp @@ -83,7 +83,9 @@ CreatePatchEvent::pre_process() poly = _poly; _patch = new PatchImpl(_engine, path.name(), poly, _parent, _engine.audio_driver()->sample_rate(), _engine.audio_driver()->buffer_size(), _poly); - _patch->properties().insert(_properties.begin(), _properties.end()); + _patch->meta().properties().insert(_properties.begin(), _properties.end()); + _patch->set_property("rdf:type", Atom(Atom::URI, "ingen:Node")); + _patch->set_property("rdf:instanceOf", Atom(Atom::URI, _patch->meta_uri().str())); if (_parent != NULL) { _parent->add_node(new PatchImpl::Nodes::Node(_patch)); diff --git a/src/engine/events/CreatePortEvent.cpp b/src/engine/events/CreatePortEvent.cpp index 38c3587c..e954c56d 100644 --- a/src/engine/events/CreatePortEvent.cpp +++ b/src/engine/events/CreatePortEvent.cpp @@ -15,10 +15,11 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "raul/Path.hpp" #include "raul/Array.hpp" +#include "raul/Atom.hpp" #include "raul/List.hpp" #include "raul/Maid.hpp" +#include "raul/Path.hpp" #include "Responder.hpp" #include "CreatePortEvent.hpp" #include "PatchImpl.hpp" @@ -35,6 +36,7 @@ #include "DuplexPort.hpp" using namespace std; +using namespace Raul; namespace Ingen { @@ -96,7 +98,8 @@ CreatePortEvent::pre_process() const uint32_t old_num_ports = _patch->num_ports(); _patch_port = _patch->create_port(_path.name(), _data_type, buffer_size, _is_output); - _patch_port->properties().insert(_properties.begin(), _properties.end()); + _patch_port->set_property("rdf:instanceOf", Atom(Atom::URI, _patch_port->meta_uri().str())); + _patch_port->meta().properties().insert(_properties.begin(), _properties.end()); if (_patch_port) { diff --git a/src/engine/events/RequestMetadataEvent.cpp b/src/engine/events/RequestMetadataEvent.cpp index fe1f0cab..5d0b15bc 100644 --- a/src/engine/events/RequestMetadataEvent.cpp +++ b/src/engine/events/RequestMetadataEvent.cpp @@ -37,7 +37,7 @@ using namespace Shared; RequestMetadataEvent::RequestMetadataEvent(Engine& engine, SharedPtr<Responder> responder, SampleCount timestamp, - bool is_property, + bool is_meta, const URI& subject, const URI& key) : QueuedEvent(engine, responder, timestamp) @@ -46,7 +46,7 @@ RequestMetadataEvent::RequestMetadataEvent(Engine& engine, , _uri(subject) , _key(key) , _resource(0) - , _is_property(is_property) + , _is_meta(is_meta) { } @@ -67,12 +67,17 @@ RequestMetadataEvent::pre_process() } } - if (_key.str() == "ingen:value") - _special_type = PORT_VALUE; - else if (!is_object || _is_property) + GraphObjectImpl* obj = dynamic_cast<GraphObjectImpl*>(_resource); + if (obj) { + if (_key.str() == "ingen:value") + _special_type = PORT_VALUE; + else if (_is_meta) + _value = obj->meta().get_property(_key); + else + _value = obj->get_property(_key); + } else { _value = _resource->get_property(_key); - else - _value = dynamic_cast<GraphObjectImpl*>(_resource)->get_variable(_key); + } QueuedEvent::pre_process(); } @@ -111,7 +116,7 @@ RequestMetadataEvent::post_process() _responder->respond_error(msg); } else { _responder->respond_ok(); - _responder->client()->set_variable(_uri, _key, _value); + _responder->client()->set_property(_uri, _key, _value); } } else { _responder->respond_error("Unknown client"); diff --git a/src/engine/events/RequestMetadataEvent.hpp b/src/engine/events/RequestMetadataEvent.hpp index 1445f83d..9d1c6bf0 100644 --- a/src/engine/events/RequestMetadataEvent.hpp +++ b/src/engine/events/RequestMetadataEvent.hpp @@ -39,7 +39,7 @@ public: RequestMetadataEvent(Engine& engine, SharedPtr<Responder> responder, SampleCount timestamp, - bool property, + bool meta, const Raul::URI& path, const Raul::URI& key); @@ -58,7 +58,7 @@ private: Raul::URI _key; Raul::Atom _value; Shared::ResourceImpl* _resource; - bool _is_property; + bool _is_meta; }; diff --git a/src/engine/events/SetMetadataEvent.cpp b/src/engine/events/SetMetadataEvent.cpp index af36b5d3..482656ca 100644 --- a/src/engine/events/SetMetadataEvent.cpp +++ b/src/engine/events/SetMetadataEvent.cpp @@ -37,20 +37,21 @@ SetMetadataEvent::SetMetadataEvent( Engine& engine, SharedPtr<Responder> responder, SampleCount timestamp, - bool property, + bool meta, const URI& subject, const URI& key, const Atom& value) : QueuedEvent(engine, responder, timestamp) , _error(NO_ERROR) , _special_type(NONE) - , _property(property) , _subject(subject) , _key(key) , _value(value) , _object(NULL) , _patch(NULL) , _compiled_patch(NULL) + , _is_meta(meta) + , _success(false) { } @@ -70,40 +71,45 @@ SetMetadataEvent::pre_process() } /*cerr << "SET " << _object->path() << (_property ? " PROP " : " VAR ") - << _key << " :: " << _value.type() << endl;*/ + << _key << " :: " << _value.type() << endl;*/ - if (_property || !dynamic_cast<GraphObjectImpl*>(_object)) - _object->set_property(_key, _value); - else - dynamic_cast<GraphObjectImpl*>(_object)->set_variable(_key, _value); - - _patch = dynamic_cast<PatchImpl*>(_object); - - if (_key.str() == "ingen:broadcast") { - _special_type = ENABLE_BROADCAST; - } else if (_patch) { - if (!_property && _key.str() == "ingen:enabled") { - if (_value.type() == Atom::BOOL) { - _special_type = ENABLE; - if (_value.get_bool() && !_patch->compiled_patch()) - _compiled_patch = _patch->compile(); - } else { - _error = BAD_TYPE; - } - } else if (!_property && _key.str() == "ingen:polyphonic") { - if (_value.type() == Atom::BOOL) { - _special_type = POLYPHONIC; - } else { - _error = BAD_TYPE; - } - } else if (_property && _key.str() == "ingen:polyphony") { - if (_value.type() == Atom::INT) { - _special_type = POLYPHONY; - _patch->prepare_internal_poly(_value.get_int32()); - } else { - _error = BAD_TYPE; + GraphObjectImpl* obj = dynamic_cast<GraphObjectImpl*>(_object); + if (obj) { + if (_is_meta) + obj->meta().set_property(_key, _value); + else + obj->set_property(_key, _value); + + _patch = dynamic_cast<PatchImpl*>(_object); + + if (_key.str() == "ingen:broadcast") { + _special_type = ENABLE_BROADCAST; + } else if (_patch) { + if (_key.str() == "ingen:enabled") { + if (_value.type() == Atom::BOOL) { + _special_type = ENABLE; + if (_value.get_bool() && !_patch->compiled_patch()) + _compiled_patch = _patch->compile(); + } else { + _error = BAD_TYPE; + } + } else if (_key.str() == "ingen:polyphonic") { + if (_value.type() == Atom::BOOL) { + _special_type = POLYPHONIC; + } else { + _error = BAD_TYPE; + } + } else if (_key.str() == "ingen:polyphony") { + if (_value.type() == Atom::INT) { + _special_type = POLYPHONY; + _patch->prepare_internal_poly(_value.get_int32()); + } else { + _error = BAD_TYPE; + } } } + } else { + _object->set_property(_key, _value); } QueuedEvent::pre_process(); @@ -155,10 +161,7 @@ SetMetadataEvent::post_process() switch (_error) { case NO_ERROR: _responder->respond_ok(); - if (_property) - _engine.broadcaster()->send_property_change(_subject, _key, _value); - else - _engine.broadcaster()->send_variable_change(_subject, _key, _value); + _engine.broadcaster()->send_property_change(_subject, _key, _value); break; case NOT_FOUND: _responder->respond_error((boost::format( diff --git a/src/engine/events/SetMetadataEvent.hpp b/src/engine/events/SetMetadataEvent.hpp index 944091b0..b33cc9ca 100644 --- a/src/engine/events/SetMetadataEvent.hpp +++ b/src/engine/events/SetMetadataEvent.hpp @@ -40,7 +40,7 @@ public: SetMetadataEvent(Engine& engine, SharedPtr<Responder> responder, SampleCount timestamp, - bool property, + bool meta, const Raul::URI& subject, const Raul::URI& key, const Raul::Atom& value); @@ -59,14 +59,14 @@ private: POLYPHONIC } _special_type; - bool _property; - bool _success; Raul::URI _subject; Raul::URI _key; Raul::Atom _value; Shared::ResourceImpl* _object; PatchImpl* _patch; CompiledPatch* _compiled_patch; + bool _is_meta; + bool _success; }; |