diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/client/ClientStore.cpp | 2 | ||||
-rw-r--r-- | src/engine/QueuedEngineInterface.cpp | 24 | ||||
-rw-r--r-- | src/engine/QueuedEvent.hpp | 12 | ||||
-rw-r--r-- | src/engine/events/SetMetadataEvent.cpp | 94 | ||||
-rw-r--r-- | src/engine/events/SetMetadataEvent.hpp | 2 | ||||
-rw-r--r-- | src/gui/NodeModule.cpp | 1 | ||||
-rw-r--r-- | src/serialisation/Parser.cpp | 48 |
7 files changed, 85 insertions, 98 deletions
diff --git a/src/client/ClientStore.cpp b/src/client/ClientStore.cpp index 12bbdaf9..a8fe7c51 100644 --- a/src/client/ClientStore.cpp +++ b/src/client/ClientStore.cpp @@ -289,8 +289,8 @@ ClientStore::put(const URI& uri, const Resource::Properties& properties) SharedPtr<ObjectModel> obj = PtrCast<ObjectModel>(object(path)); if (obj) { - cerr << "OBJECT EXISTS " << path << endl; obj->set_properties(properties); + return; } bool is_patch, is_node, is_port, is_output; diff --git a/src/engine/QueuedEngineInterface.cpp b/src/engine/QueuedEngineInterface.cpp index 7c989723..30cc1072 100644 --- a/src/engine/QueuedEngineInterface.cpp +++ b/src/engine/QueuedEngineInterface.cpp @@ -166,27 +166,7 @@ QueuedEngineInterface::put(const URI& uri, cerr << "\t" << i->first << " = " << i->second << " :: " << i->second.type() << endl; cerr << "}" << endl; - bool is_patch = false, is_node = false, is_port = false, is_output = false; - DataType data_type(DataType::UNKNOWN); - ResourceImpl::type(properties, is_patch, is_node, is_port, is_output, data_type); - - // PutEvent - - if (is_patch) { - uint32_t poly = 1; - iterator p = properties.find("ingen:polyphony"); - if (p != properties.end() && p->second.is_valid() && p->second.type() == Atom::INT) - poly = p->second.get_int32(); - push_queued(new CreatePatchEvent( - _engine, _responder, now(), path, poly, properties)); - } else if (is_node) { - const iterator p = properties.find("rdf:instanceOf"); - push_queued(new CreateNodeEvent( - _engine, _responder, now(), path, p->second.get_uri(), true, properties)); - } else if (is_port) { - push_queued(new CreatePortEvent( - _engine, _responder, now(), path, data_type.uri(), is_output, this, properties)); - } + push_queued(new SetMetadataEvent(_engine, _responder, now(), this, meta, path, properties)); } @@ -271,7 +251,7 @@ QueuedEngineInterface::set_property(const URI& uri, Path path = meta ? (string("/") + path.chop_start("/")) : uri.str(); Resource::Properties properties; properties.insert(make_pair(predicate, value)); - push_queued(new SetMetadataEvent(_engine, _responder, now(), meta, path, properties)); + push_queued(new SetMetadataEvent(_engine, _responder, now(), this, meta, path, properties)); } // Requests // diff --git a/src/engine/QueuedEvent.hpp b/src/engine/QueuedEvent.hpp index 40ba9c22..6bc6a898 100644 --- a/src/engine/QueuedEvent.hpp +++ b/src/engine/QueuedEvent.hpp @@ -59,8 +59,10 @@ protected: FrameTime time, bool blocking = false, QueuedEventSource* source = NULL) - : Event(engine, responder, time) - , _pre_processed(false), _blocking(blocking), _source(source) + : Event(engine, responder, time) + , _pre_processed(false) + , _blocking(blocking) + , _source(source) { if (blocking) assert(_source); @@ -68,8 +70,10 @@ protected: // NULL event base (for internal events only!) QueuedEvent(Engine& engine) - : Event(engine, SharedPtr<Responder>(), 0) - , _pre_processed(false), _blocking(false), _source(NULL) + : Event(engine, SharedPtr<Responder>(), 0) + , _pre_processed(false) + , _blocking(false) + , _source(NULL) {} bool _pre_processed; diff --git a/src/engine/events/SetMetadataEvent.cpp b/src/engine/events/SetMetadataEvent.cpp index e04b9cea..0349ba29 100644 --- a/src/engine/events/SetMetadataEvent.cpp +++ b/src/engine/events/SetMetadataEvent.cpp @@ -18,30 +18,40 @@ #include "SetMetadataEvent.hpp" #include <string> #include <boost/format.hpp> -#include "Responder.hpp" -#include "Engine.hpp" -#include "PortImpl.hpp" +#include "interface/DataType.hpp" #include "ClientBroadcaster.hpp" +#include "Engine.hpp" +#include "EngineStore.hpp" #include "GraphObjectImpl.hpp" #include "PatchImpl.hpp" #include "PluginImpl.hpp" -#include "EngineStore.hpp" +#include "PortImpl.hpp" +#include "Responder.hpp" +#include "CreatePatchEvent.hpp" +#include "CreateNodeEvent.hpp" +#include "CreatePortEvent.hpp" + using namespace std; using namespace Raul; namespace Ingen { +using namespace Shared; +typedef Shared::Resource::Properties Properties; + SetMetadataEvent::SetMetadataEvent( - Engine& engine, - SharedPtr<Responder> responder, - SampleCount timestamp, - bool meta, - const URI& subject, - const Shared::Resource::Properties& properties) - : QueuedEvent(engine, responder, timestamp) + Engine& engine, + SharedPtr<Responder> responder, + SampleCount timestamp, + QueuedEventSource* source, + bool meta, + const URI& subject, + const Properties& properties) + : QueuedEvent(engine, responder, timestamp, false, source) , _error(NO_ERROR) + , _create_event(NULL) , _subject(subject) , _properties(properties) , _object(NULL) @@ -56,22 +66,52 @@ SetMetadataEvent::SetMetadataEvent( void SetMetadataEvent::pre_process() { - if (_subject.scheme() == Path::scheme && Path::is_valid(_subject.str())) - _object = _engine.engine_store()->find_object(Path(_subject.str())); - else - _object = _engine.node_factory()->plugin(_subject); + typedef Properties::const_iterator iterator; + + bool is_graph_object = (_subject.scheme() == Path::scheme && Path::is_valid(_subject.str())); - if (_object == NULL) { + _object = is_graph_object + ? _engine.engine_store()->find_object(Path(_subject.str())) + : _object = _engine.node_factory()->plugin(_subject); + + if (!_object && !is_graph_object) { _error = NOT_FOUND; QueuedEvent::pre_process(); return; } - /*cerr << "SET " << _object->path() << (_property ? " PROP " : " VAR ") - << _key << " :: " << _value.type() << endl;*/ + if (is_graph_object && !_object) { + Path path(_subject.str()); + cerr << "CREATE NEW GRAPH OBJECT" << endl; + bool is_patch = false, is_node = false, is_port = false, is_output = false; + DataType data_type(DataType::UNKNOWN); + ResourceImpl::type(_properties, is_patch, is_node, is_port, is_output, data_type); + if (is_patch) { + uint32_t poly = 1; + iterator p = _properties.find("ingen:polyphony"); + if (p != _properties.end() && p->second.is_valid() && p->second.type() == Atom::INT) + poly = p->second.get_int32(); + _create_event = new CreatePatchEvent(_engine, _responder, _time, + path, poly, _properties); + } else if (is_node) { + const iterator p = _properties.find("rdf:instanceOf"); + _create_event = new CreateNodeEvent(_engine, _responder, _time, + path, p->second.get_uri(), true, _properties); + } else if (is_port) { + _blocking = true; + _create_event = new CreatePortEvent(_engine, _responder, _time, + path, data_type.uri(), is_output, _source, _properties); + } + if (_create_event) + _create_event->pre_process(); + else + _error = BAD_TYPE; + QueuedEvent::pre_process(); + return; + } _types.reserve(_properties.size()); - typedef Shared::Resource::Properties Properties; + for (Properties::iterator p = _properties.begin(); p != _properties.end(); ++p) { const Raul::URI& key = p->first; const Raul::Atom& value = p->second; @@ -109,6 +149,7 @@ SetMetadataEvent::pre_process() _error = BAD_TYPE; } } else { + _object->set_property(key, value); _types.push_back(NONE); } if (_error != NO_ERROR) @@ -128,10 +169,17 @@ SetMetadataEvent::pre_process() void SetMetadataEvent::execute(ProcessContext& context) { - if (_error != NO_ERROR) + if (_error != NO_ERROR) { + QueuedEvent::execute(context); return; + } + + if (_create_event) { + QueuedEvent::execute(context); + _create_event->execute(context); + return; + } - typedef Shared::Resource::Properties Properties; std::vector<SpecialType>::const_iterator t = _types.begin(); for (Properties::iterator p = _properties.begin(); p != _properties.end(); ++p, ++t) { const Raul::Atom& value = p->second; @@ -176,6 +224,8 @@ SetMetadataEvent::post_process() case NO_ERROR: _responder->respond_ok(); _engine.broadcaster()->send_put(_subject, _properties); + if (_create_event) + _create_event->post_process(); break; case NOT_FOUND: _responder->respond_error((boost::format( @@ -184,7 +234,7 @@ SetMetadataEvent::post_process() _responder->respond_error("Internal error"); break; case BAD_TYPE: - _responder->respond_error("Bad type for predicate"); + _responder->respond_error("Bad type"); break; } } diff --git a/src/engine/events/SetMetadataEvent.hpp b/src/engine/events/SetMetadataEvent.hpp index 92b540ff..a3aadfa9 100644 --- a/src/engine/events/SetMetadataEvent.hpp +++ b/src/engine/events/SetMetadataEvent.hpp @@ -64,6 +64,7 @@ public: Engine& engine, SharedPtr<Responder> responder, SampleCount timestamp, + QueuedEventSource* source, bool meta, const Raul::URI& subject, const Shared::Resource::Properties& properties); @@ -82,6 +83,7 @@ private: POLYPHONIC }; + QueuedEvent* _create_event; std::vector<SpecialType> _types; Raul::URI _subject; Shared::Resource::Properties _properties; diff --git a/src/gui/NodeModule.cpp b/src/gui/NodeModule.cpp index a85a50b8..99ffe4e3 100644 --- a/src/gui/NodeModule.cpp +++ b/src/gui/NodeModule.cpp @@ -377,7 +377,6 @@ NodeModule::store_location() void NodeModule::set_property(const URI& key, const Atom& value) { - cerr << "SET " << key << " = " << value << " :: " << value.type() << endl; switch (value.type()) { case Atom::FLOAT: if (key.str() == "ingenuity:canvas-x") { diff --git a/src/serialisation/Parser.cpp b/src/serialisation/Parser.cpp index 4085a8fc..34d1d24c 100644 --- a/src/serialisation/Parser.cpp +++ b/src/serialisation/Parser.cpp @@ -71,52 +71,6 @@ relative_uri(Glib::ustring base, const Glib::ustring uri, bool leading_slash) } -#if 0 -static Glib::ustring -chop_uri_scheme(const Glib::ustring in) -{ - Glib::ustring out = in; - - // Remove scheme - size_t scheme_end = out.find(":"); - if (scheme_end != string::npos) - out = out.substr(scheme_end + 1); - - // Chop leading double slashes - while (out.length() > 1 && out[0] == '/' && out[1] == '/') - out = out.substr(1); - - return out; -} - - -static Glib::ustring -uri_child(const Glib::ustring base, const Glib::ustring child, bool trailing_slash) -{ - Glib::ustring ret = (base[base.length()-1] == '/' || child[0] == '/') - ? base + child - : base + '/' + child; - - if (trailing_slash && (ret == "" || ret[ret.length()-1] != '/')) - ret = ret + "/"; - else if (!trailing_slash && ret != "" && ret[ret.length()-1] == '/') - ret = ret.substr(0, ret.length()-1); - - return ret; -} - - -static Glib::ustring -dequote_uri(const Glib::ustring in) -{ - Glib::ustring out = in; - if (out[0] == '<' && out[out.length()-1] == '>') - out = out.substr(1, out.length()-2); - return out; -} -#endif - - static void normalise_uri(Glib::ustring& uri) { @@ -801,8 +755,6 @@ Parser::parse_properties( properties.insert(make_pair(key, AtomRDF::node_to_atom(val))); } - cout << "PROPERTIES: " << path << endl; - target->put(path, properties); // Set passed properties last to override any loaded values |