From ab2aa4d4922ab1a62b7a43013d09b2d9d144b3c5 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 15 Aug 2008 23:34:41 +0000 Subject: Push serialiser down into core ('world'). HTTP access to patches (serialised on demand). git-svn-id: http://svn.drobilla.net/lad/ingen@1393 a436a847-0d15-0410-975c-d299462d15a1 --- src/common/interface/GraphObject.hpp | 4 - src/common/interface/Makefile.am | 3 +- src/common/interface/Store.hpp | 47 ++++++++++ src/libs/client/ConnectionModel.hpp | 4 +- src/libs/client/NodeModel.cpp | 8 +- src/libs/client/NodeModel.hpp | 8 +- src/libs/client/ObjectModel.cpp | 38 +------- src/libs/client/ObjectModel.hpp | 11 +-- src/libs/client/PatchModel.cpp | 6 +- src/libs/client/PatchModel.hpp | 12 ++- src/libs/client/PortModel.hpp | 16 ++-- src/libs/client/Store.cpp | 138 +++++++++++++++++----------- src/libs/client/Store.hpp | 16 +++- src/libs/engine/Engine.cpp | 21 ++++- src/libs/engine/Engine.hpp | 4 +- src/libs/engine/GraphObjectImpl.cpp | 14 --- src/libs/engine/GraphObjectImpl.hpp | 2 - src/libs/engine/HTTPEngineReceiver.cpp | 29 +++++- src/libs/engine/Makefile.am | 1 + src/libs/engine/ObjectStore.cpp | 24 ++++- src/libs/engine/ObjectStore.hpp | 8 +- src/libs/engine/events/AllNotesOffEvent.cpp | 2 + src/libs/gui/App.cpp | 26 +++--- src/libs/gui/App.hpp | 14 +-- src/libs/gui/LoadPluginWindow.cpp | 4 +- src/libs/gui/NewSubpatchWindow.cpp | 3 +- src/libs/gui/PatchCanvas.cpp | 18 ++-- src/libs/gui/PatchTreeWindow.cpp | 2 +- src/libs/gui/PatchTreeWindow.hpp | 6 +- src/libs/gui/ThreadedLoader.cpp | 4 +- src/libs/gui/UploadPatchWindow.cpp | 2 +- src/libs/module/Makefile.am | 1 - src/libs/module/World.hpp | 8 ++ src/libs/serialisation/Serialiser.cpp | 10 +- src/libs/serialisation/Serialiser.hpp | 19 ++-- src/libs/serialisation/serialisation.cpp | 2 +- 36 files changed, 324 insertions(+), 211 deletions(-) create mode 100644 src/common/interface/Store.hpp diff --git a/src/common/interface/GraphObject.hpp b/src/common/interface/GraphObject.hpp index 88ee8df0..e5a92d48 100644 --- a/src/common/interface/GraphObject.hpp +++ b/src/common/interface/GraphObject.hpp @@ -53,10 +53,6 @@ public: // FIXME: return WeakPtr, and stupid name virtual GraphObject* graph_parent() const = 0; - - virtual const_iterator children_begin() const = 0; - virtual const_iterator children_end() const = 0; - virtual SharedPtr find_child(const std::string& name) const = 0; }; diff --git a/src/common/interface/Makefile.am b/src/common/interface/Makefile.am index 9f56791d..37884f6b 100644 --- a/src/common/interface/Makefile.am +++ b/src/common/interface/Makefile.am @@ -9,4 +9,5 @@ EXTRA_DIST = \ Patch.hpp \ Plugin.hpp \ Port.hpp \ - README + README \ + Store.hpp diff --git a/src/common/interface/Store.hpp b/src/common/interface/Store.hpp new file mode 100644 index 00000000..428945b9 --- /dev/null +++ b/src/common/interface/Store.hpp @@ -0,0 +1,47 @@ +/* This file is part of Ingen. + * Copyright (C) 2008 Dave Robillard + * + * 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 COMMON_STORE_H +#define COMMON_STORE_H + +#include +#include "interface/GraphObject.hpp" + +using Raul::PathTable; +using Raul::Path; + +namespace Ingen { +namespace Shared { + + +class Store { +public: + typedef Raul::PathTable< SharedPtr > Objects; + virtual const Objects& objects() const = 0; + + virtual Objects::iterator find(const Path& path) = 0; + virtual void add(GraphObject* o) = 0; + + virtual Objects::const_iterator children_begin(SharedPtr o) const = 0; + virtual Objects::const_iterator children_end(SharedPtr o) const = 0; +}; + + +} // namespace Shared +} // namespace Ingen + +#endif // COMMON_STORE_H diff --git a/src/libs/client/ConnectionModel.hpp b/src/libs/client/ConnectionModel.hpp index 5ace402f..91c448df 100644 --- a/src/libs/client/ConnectionModel.hpp +++ b/src/libs/client/ConnectionModel.hpp @@ -29,7 +29,7 @@ namespace Ingen { namespace Client { -class Store; +class ClientStore; /** Class to represent a port->port connection in the engine. @@ -52,7 +52,7 @@ public: const Path dst_port_path() const { return _dst_port->path(); } private: - friend class Store; + friend class ClientStore; ConnectionModel(SharedPtr src, SharedPtr dst) : _src_port(src) diff --git a/src/libs/client/NodeModel.cpp b/src/libs/client/NodeModel.cpp index 4e81d6dd..96d70663 100644 --- a/src/libs/client/NodeModel.cpp +++ b/src/libs/client/NodeModel.cpp @@ -27,8 +27,8 @@ namespace Ingen { namespace Client { -NodeModel::NodeModel(Store& store, SharedPtr plugin, const Path& path, bool polyphonic) - : ObjectModel(store, path, polyphonic) +NodeModel::NodeModel(SharedPtr plugin, const Path& path, bool polyphonic) + : ObjectModel(path, polyphonic) , _plugin_uri(plugin->uri()) , _plugin(plugin) , _min_values(0) @@ -36,8 +36,8 @@ NodeModel::NodeModel(Store& store, SharedPtr plugin, const Path& pa { } -NodeModel::NodeModel(Store& store, const string& plugin_uri, const Path& path, bool polyphonic) - : ObjectModel(store, path, polyphonic) +NodeModel::NodeModel(const string& plugin_uri, const Path& path, bool polyphonic) + : ObjectModel(path, polyphonic) , _plugin_uri(plugin_uri) , _min_values(0) , _max_values(0) diff --git a/src/libs/client/NodeModel.hpp b/src/libs/client/NodeModel.hpp index 700027b6..08e106ab 100644 --- a/src/libs/client/NodeModel.hpp +++ b/src/libs/client/NodeModel.hpp @@ -38,7 +38,7 @@ namespace Ingen { namespace Client { class PluginModel; -class Store; +class ClientStore; /** Node model class, used by the client to store engine's state. @@ -66,10 +66,10 @@ public: sigc::signal > signal_removed_port; protected: - friend class Store; + friend class ClientStore; - NodeModel(Store& store, const string& plugin_uri, const Path& path, bool polyphonic); - NodeModel(Store& store, SharedPtr plugin, const Path& path, bool polyphonic); + NodeModel(const string& plugin_uri, const Path& path, bool polyphonic); + NodeModel(SharedPtr plugin, const Path& path, bool polyphonic); NodeModel(const Path& path); void add_child(SharedPtr c); diff --git a/src/libs/client/ObjectModel.cpp b/src/libs/client/ObjectModel.cpp index b951bc6b..e83b9fe1 100644 --- a/src/libs/client/ObjectModel.cpp +++ b/src/libs/client/ObjectModel.cpp @@ -26,9 +26,8 @@ namespace Ingen { namespace Client { -ObjectModel::ObjectModel(Store& store, const Path& path, bool polyphonic) - : _store(store) - , _path(path) +ObjectModel::ObjectModel(const Path& path, bool polyphonic) + : _path(path) , _polyphonic(polyphonic) { } @@ -39,39 +38,6 @@ ObjectModel::~ObjectModel() } -ObjectModel::const_iterator -ObjectModel::children_begin() const -{ - Store::Objects::const_iterator me = _store.objects().find(_path); - assert(me != _store.objects().end()); - ++me; - return me; -} - - -ObjectModel::const_iterator -ObjectModel::children_end() const -{ - Store::Objects::const_iterator me = _store.objects().find(_path); - assert(me != _store.objects().end()); - return _store.objects().find_descendants_end(me); -} - - -SharedPtr -ObjectModel::find_child(const string& name) const -{ - const_iterator me = _store.objects().find(_path); - assert(me != _store.objects().end()); - const_iterator children_end = _store.objects().find_descendants_end(me); - const_iterator child = _store.objects().find(me, children_end, _path.base() + name); - if (child != _store.objects().end()) - return PtrCast(child->second); - else - return SharedPtr(); -} - - /** Get a piece of variable for this object. * * @return Metadata value with key @a key, empty string otherwise. diff --git a/src/libs/client/ObjectModel.hpp b/src/libs/client/ObjectModel.hpp index 5655222f..f052f1d9 100644 --- a/src/libs/client/ObjectModel.hpp +++ b/src/libs/client/ObjectModel.hpp @@ -41,7 +41,7 @@ using Raul::Symbol; namespace Ingen { namespace Client { -class Store; +class ClientStore; /** Base class for all GraphObject models (NodeModel, PatchModel, PortModel). @@ -72,10 +72,6 @@ public: GraphObject* graph_parent() const { return _parent.get(); } - const_iterator children_begin() const; - const_iterator children_end() const; - SharedPtr find_child(const string& name) const; - // Signals sigc::signal > signal_new_child; sigc::signal > signal_removed_child; @@ -85,9 +81,9 @@ public: sigc::signal signal_renamed; protected: - friend class Store; + friend class ClientStore; - ObjectModel(Store& store, const Path& path, bool polyphonic); + ObjectModel(const Path& path, bool polyphonic); virtual void set_path(const Path& p) { _path = p; signal_renamed.emit(); } virtual void set_parent(SharedPtr p) { assert(p); _parent = p; } @@ -99,7 +95,6 @@ protected: virtual void set(SharedPtr model); - Store& _store; Path _path; bool _polyphonic; SharedPtr _parent; diff --git a/src/libs/client/PatchModel.cpp b/src/libs/client/PatchModel.cpp index b47bd4f4..7f928b41 100644 --- a/src/libs/client/PatchModel.cpp +++ b/src/libs/client/PatchModel.cpp @@ -189,7 +189,9 @@ PatchModel::polyphonic() const unsigned -PatchModel::child_name_offset(const string& base_name) const +PatchModel::child_name_offset(ClientStore& store, + SharedPtr parent, + const string& base_name) { assert(Path::is_valid_name(base_name)); unsigned offset = 0; @@ -199,7 +201,7 @@ PatchModel::child_name_offset(const string& base_name) const ss << base_name; if (offset > 0) ss << "_" << offset; - if (!find_child(ss.str())) + if (store.find(parent->path().base() + ss.str()) == store.objects().end()) break; else if (offset == 0) offset = 2; diff --git a/src/libs/client/PatchModel.hpp b/src/libs/client/PatchModel.hpp index c73c60a3..62b9db44 100644 --- a/src/libs/client/PatchModel.hpp +++ b/src/libs/client/PatchModel.hpp @@ -33,7 +33,7 @@ using std::list; using std::string; namespace Ingen { namespace Client { -class Store; +class ClientStore; /** Client's model of a patch. @@ -62,7 +62,9 @@ public: signal_editable.emit(e); } } - unsigned child_name_offset(const string& base_name) const; + static unsigned child_name_offset(ClientStore& store, + SharedPtr parent, + const string& base_name); // Signals sigc::signal > signal_new_node; @@ -75,10 +77,10 @@ public: sigc::signal signal_editable; private: - friend class Store; + friend class ClientStore; - PatchModel(Store& store, const Path& patch_path, size_t internal_poly) - : NodeModel(store, "ingen:Patch", patch_path, false) // FIXME + PatchModel(const Path& patch_path, size_t internal_poly) + : NodeModel("ingen:Patch", patch_path, false) // FIXME , _enabled(false) , _poly(internal_poly) , _editable(true) diff --git a/src/libs/client/PortModel.hpp b/src/libs/client/PortModel.hpp index a452c338..3739be58 100644 --- a/src/libs/client/PortModel.hpp +++ b/src/libs/client/PortModel.hpp @@ -71,15 +71,15 @@ public: sigc::signal > signal_disconnection; private: - friend class Store; + friend class ClientStore; - PortModel(Store& store, const Path& path, uint32_t index, DataType type, Direction dir) - : ObjectModel(store, path, true), - _index(index), - _type(type), - _direction(dir), - _current_val(0.0f), - _connections(0) + PortModel(const Path& path, uint32_t index, DataType type, Direction dir) + : ObjectModel(path, true) + , _index(index) + , _type(type) + , _direction(dir) + , _current_val(0.0f) + , _connections(0) { if (_type == DataType::UNKNOWN) std::cerr << "[PortModel] Warning: Unknown port type" << std::endl; diff --git a/src/libs/client/Store.cpp b/src/libs/client/Store.cpp index 6bb3b767..47ed3719 100644 --- a/src/libs/client/Store.cpp +++ b/src/libs/client/Store.cpp @@ -32,31 +32,31 @@ namespace Ingen { namespace Client { -Store::Store(SharedPtr engine, SharedPtr emitter) +ClientStore::ClientStore(SharedPtr engine, SharedPtr emitter) : _engine(engine) , _emitter(emitter) { - emitter->signal_object_destroyed.connect(sigc::mem_fun(this, &Store::destruction_event)); - emitter->signal_object_renamed.connect(sigc::mem_fun(this, &Store::rename_event)); - emitter->signal_new_plugin.connect(sigc::mem_fun(this, &Store::new_plugin_event)); - emitter->signal_new_patch.connect(sigc::mem_fun(this, &Store::new_patch_event)); - emitter->signal_new_node.connect(sigc::mem_fun(this, &Store::new_node_event)); - emitter->signal_new_port.connect(sigc::mem_fun(this, &Store::new_port_event)); - emitter->signal_polyphonic.connect(sigc::mem_fun(this, &Store::polyphonic_event)); - emitter->signal_patch_enabled.connect(sigc::mem_fun(this, &Store::patch_enabled_event)); - emitter->signal_patch_disabled.connect(sigc::mem_fun(this, &Store::patch_disabled_event)); - emitter->signal_patch_polyphony.connect(sigc::mem_fun(this, &Store::patch_polyphony_event)); - emitter->signal_patch_cleared.connect(sigc::mem_fun(this, &Store::patch_cleared_event)); - emitter->signal_connection.connect(sigc::mem_fun(this, &Store::connection_event)); - emitter->signal_disconnection.connect(sigc::mem_fun(this, &Store::disconnection_event)); - emitter->signal_variable_change.connect(sigc::mem_fun(this, &Store::variable_change_event)); - emitter->signal_control_change.connect(sigc::mem_fun(this, &Store::control_change_event)); - emitter->signal_port_activity.connect(sigc::mem_fun(this, &Store::port_activity_event)); + emitter->signal_object_destroyed.connect(sigc::mem_fun(this, &ClientStore::destruction_event)); + emitter->signal_object_renamed.connect(sigc::mem_fun(this, &ClientStore::rename_event)); + emitter->signal_new_plugin.connect(sigc::mem_fun(this, &ClientStore::new_plugin_event)); + emitter->signal_new_patch.connect(sigc::mem_fun(this, &ClientStore::new_patch_event)); + emitter->signal_new_node.connect(sigc::mem_fun(this, &ClientStore::new_node_event)); + emitter->signal_new_port.connect(sigc::mem_fun(this, &ClientStore::new_port_event)); + emitter->signal_polyphonic.connect(sigc::mem_fun(this, &ClientStore::polyphonic_event)); + emitter->signal_patch_enabled.connect(sigc::mem_fun(this, &ClientStore::patch_enabled_event)); + emitter->signal_patch_disabled.connect(sigc::mem_fun(this, &ClientStore::patch_disabled_event)); + emitter->signal_patch_polyphony.connect(sigc::mem_fun(this, &ClientStore::patch_polyphony_event)); + emitter->signal_patch_cleared.connect(sigc::mem_fun(this, &ClientStore::patch_cleared_event)); + emitter->signal_connection.connect(sigc::mem_fun(this, &ClientStore::connection_event)); + emitter->signal_disconnection.connect(sigc::mem_fun(this, &ClientStore::disconnection_event)); + emitter->signal_variable_change.connect(sigc::mem_fun(this, &ClientStore::variable_change_event)); + emitter->signal_control_change.connect(sigc::mem_fun(this, &ClientStore::control_change_event)); + emitter->signal_port_activity.connect(sigc::mem_fun(this, &ClientStore::port_activity_event)); } void -Store::clear() +ClientStore::clear() { _objects.clear(); _plugins.clear(); @@ -64,7 +64,7 @@ Store::clear() void -Store::add_plugin_orphan(SharedPtr node) +ClientStore::add_plugin_orphan(SharedPtr node) { cerr << "WARNING: Node " << node->path() << " received, but plugin " << node->plugin_uri() << " unknown." << endl; @@ -85,7 +85,7 @@ Store::add_plugin_orphan(SharedPtr node) void -Store::resolve_plugin_orphans(SharedPtr plugin) +ClientStore::resolve_plugin_orphans(SharedPtr plugin) { Raul::Table > >::iterator n = _plugin_orphans.find(plugin->uri()); @@ -107,7 +107,7 @@ Store::resolve_plugin_orphans(SharedPtr plugin) void -Store::add_connection_orphan(std::pair orphan) +ClientStore::add_connection_orphan(std::pair orphan) { cerr << "WARNING: Orphan connection " << orphan.first << " -> " << orphan.second << " received." << endl; @@ -117,7 +117,7 @@ Store::add_connection_orphan(std::pair orphan) void -Store::resolve_connection_orphans(SharedPtr port) +ClientStore::resolve_connection_orphans(SharedPtr port) { assert(port->parent()); @@ -140,7 +140,7 @@ Store::resolve_connection_orphans(SharedPtr port) void -Store::add_orphan(SharedPtr child) +ClientStore::add_orphan(SharedPtr child) { cerr << "WARNING: Orphan object " << child->path() << " received." << endl; @@ -160,7 +160,7 @@ Store::add_orphan(SharedPtr child) void -Store::add_variable_orphan(const Path& subject_path, const string& predicate, const Atom& value) +ClientStore::add_variable_orphan(const Path& subject_path, const string& predicate, const Atom& value) { Raul::PathTable > >::iterator orphans = _variable_orphans.find(subject_path); @@ -178,7 +178,7 @@ Store::add_variable_orphan(const Path& subject_path, const string& predicate, co void -Store::resolve_variable_orphans(SharedPtr subject) +ClientStore::resolve_variable_orphans(SharedPtr subject) { Raul::PathTable > >::iterator v = _variable_orphans.find(subject->path()); @@ -199,7 +199,7 @@ Store::resolve_variable_orphans(SharedPtr subject) void -Store::resolve_orphans(SharedPtr parent) +ClientStore::resolve_orphans(SharedPtr parent) { Raul::PathTable > >::iterator c = _orphans.find(parent->path()); @@ -219,7 +219,7 @@ Store::resolve_orphans(SharedPtr parent) void -Store::add_object(SharedPtr object) +ClientStore::add_object(SharedPtr object) { // If we already have "this" object, merge the existing one into the new // one (with precedence to the new values). @@ -265,7 +265,7 @@ Store::add_object(SharedPtr object) SharedPtr -Store::remove_object(const Path& path) +ClientStore::remove_object(const Path& path) { Objects::iterator i = _objects.find(path); @@ -308,7 +308,7 @@ Store::remove_object(const Path& path) SharedPtr -Store::plugin(const string& uri) +ClientStore::plugin(const string& uri) { assert(uri.length() > 0); Plugins::iterator i = _plugins.find(uri); @@ -320,7 +320,7 @@ Store::plugin(const string& uri) SharedPtr -Store::object(const Path& path) +ClientStore::object(const Path& path) { assert(path.length() > 0); Objects::iterator i = _objects.find(path); @@ -335,7 +335,7 @@ Store::object(const Path& path) } void -Store::add_plugin(SharedPtr pm) +ClientStore::add_plugin(SharedPtr pm) { // FIXME: dupes? merge, like with objects? @@ -343,14 +343,46 @@ Store::add_plugin(SharedPtr pm) signal_new_plugin(pm); //cerr << "Plugin: " << pm->uri() << ", # plugins: " << _plugins.size() << endl; } + + +ClientStore::Objects::const_iterator +ClientStore::children_begin(SharedPtr o) const +{ + Objects::const_iterator parent = _objects.find(o->path()); + assert(parent != _objects.end()); + ++parent; + return parent; +} +ClientStore::Objects::const_iterator +ClientStore::children_end(SharedPtr o) const +{ + Objects::const_iterator parent = _objects.find(o->path()); + assert(parent != _objects.end()); + return _objects.find_descendants_end(parent); +} + + +SharedPtr +ClientStore::find_child(SharedPtr parent, const string& child_name) const +{ + Objects::const_iterator pi = _objects.find(parent->path()); + assert(pi != _objects.end()); + Objects::const_iterator children_end = _objects.find_descendants_end(pi); + Objects::const_iterator child = _objects.find(pi, children_end, parent->path().base() + child_name); + if (child != _objects.end()) + return PtrCast(child->second); + else + return SharedPtr(); +} + /* ****** Signal Handlers ******** */ void -Store::destruction_event(const Path& path) +ClientStore::destruction_event(const Path& path) { SharedPtr removed = remove_object(path); @@ -361,7 +393,7 @@ Store::destruction_event(const Path& path) } void -Store::rename_event(const Path& old_path, const Path& new_path) +ClientStore::rename_event(const Path& old_path, const Path& new_path) { Objects::iterator parent = _objects.find(old_path); if (parent == _objects.end()) { @@ -403,7 +435,7 @@ Store::rename_event(const Path& old_path, const Path& new_path) } void -Store::new_plugin_event(const string& uri, const string& type_uri, const string& symbol, const string& name) +ClientStore::new_plugin_event(const string& uri, const string& type_uri, const string& symbol, const string& name) { SharedPtr p(new PluginModel(uri, type_uri, symbol, name)); add_plugin(p); @@ -412,35 +444,35 @@ Store::new_plugin_event(const string& uri, const string& type_uri, const string& void -Store::new_patch_event(const Path& path, uint32_t poly) +ClientStore::new_patch_event(const Path& path, uint32_t poly) { - SharedPtr p(new PatchModel(*this, path, poly)); + SharedPtr p(new PatchModel(path, poly)); add_object(p); } void -Store::new_node_event(const string& plugin_uri, const Path& node_path, bool is_polyphonic, uint32_t num_ports) +ClientStore::new_node_event(const string& plugin_uri, const Path& node_path, bool is_polyphonic, uint32_t num_ports) { // FIXME: num_ports unused SharedPtr plug = plugin(plugin_uri); if (!plug) { - SharedPtr n(new NodeModel(*this, plugin_uri, node_path, is_polyphonic)); + SharedPtr n(new NodeModel(plugin_uri, node_path, is_polyphonic)); add_plugin_orphan(n); } else { - SharedPtr n(new NodeModel(*this, plug, node_path, is_polyphonic)); + SharedPtr n(new NodeModel(plug, node_path, is_polyphonic)); add_object(n); } } void -Store::new_port_event(const Path& path, uint32_t index, const string& type, bool is_output) +ClientStore::new_port_event(const Path& path, uint32_t index, const string& type, bool is_output) { PortModel::Direction pdir = is_output ? PortModel::OUTPUT : PortModel::INPUT; - SharedPtr p(new PortModel(*this, path, index, type, pdir)); + SharedPtr p(new PortModel(path, index, type, pdir)); add_object(p); if (p->parent()) resolve_connection_orphans(p); @@ -448,7 +480,7 @@ Store::new_port_event(const Path& path, uint32_t index, const string& type, bool void -Store::polyphonic_event(const Path& path, bool polyphonic) +ClientStore::polyphonic_event(const Path& path, bool polyphonic) { SharedPtr object = this->object(path); if (object) @@ -457,7 +489,7 @@ Store::polyphonic_event(const Path& path, bool polyphonic) void -Store::patch_enabled_event(const Path& path) +ClientStore::patch_enabled_event(const Path& path) { SharedPtr patch = PtrCast(object(path)); if (patch) @@ -466,7 +498,7 @@ Store::patch_enabled_event(const Path& path) void -Store::patch_disabled_event(const Path& path) +ClientStore::patch_disabled_event(const Path& path) { SharedPtr patch = PtrCast(object(path)); if (patch) @@ -475,7 +507,7 @@ Store::patch_disabled_event(const Path& path) void -Store::patch_polyphony_event(const Path& path, uint32_t poly) +ClientStore::patch_polyphony_event(const Path& path, uint32_t poly) { SharedPtr patch = PtrCast(object(path)); if (patch) @@ -484,7 +516,7 @@ Store::patch_polyphony_event(const Path& path, uint32_t poly) void -Store::patch_cleared_event(const Path& path) +ClientStore::patch_cleared_event(const Path& path) { Objects::iterator i = _objects.find(path); if (i != _objects.end()) { @@ -512,7 +544,7 @@ Store::patch_cleared_event(const Path& path) void -Store::variable_change_event(const Path& subject_path, const string& predicate, const Atom& value) +ClientStore::variable_change_event(const Path& subject_path, const string& predicate, const Atom& value) { SharedPtr subject = object(subject_path); @@ -528,7 +560,7 @@ Store::variable_change_event(const Path& subject_path, const string& predicate, void -Store::control_change_event(const Path& port_path, float value) +ClientStore::control_change_event(const Path& port_path, float value) { SharedPtr port = PtrCast(object(port_path)); if (port) @@ -539,7 +571,7 @@ Store::control_change_event(const Path& port_path, float value) void -Store::port_activity_event(const Path& port_path) +ClientStore::port_activity_event(const Path& port_path) { SharedPtr port = PtrCast(object(port_path)); if (port) @@ -550,7 +582,7 @@ Store::port_activity_event(const Path& port_path) SharedPtr -Store::connection_patch(const Path& src_port_path, const Path& dst_port_path) +ClientStore::connection_patch(const Path& src_port_path, const Path& dst_port_path) { SharedPtr patch; @@ -575,7 +607,7 @@ Store::connection_patch(const Path& src_port_path, const Path& dst_port_path) bool -Store::attempt_connection(const Path& src_port_path, const Path& dst_port_path, bool add_orphan) +ClientStore::attempt_connection(const Path& src_port_path, const Path& dst_port_path, bool add_orphan) { SharedPtr src_port = PtrCast(object(src_port_path)); SharedPtr dst_port = PtrCast(object(dst_port_path)); @@ -608,14 +640,14 @@ Store::attempt_connection(const Path& src_port_path, const Path& dst_port_path, void -Store::connection_event(const Path& src_port_path, const Path& dst_port_path) +ClientStore::connection_event(const Path& src_port_path, const Path& dst_port_path) { attempt_connection(src_port_path, dst_port_path, true); } void -Store::disconnection_event(const Path& src_port_path, const Path& dst_port_path) +ClientStore::disconnection_event(const Path& src_port_path, const Path& dst_port_path) { // Find the ports and create a ConnectionModel just to get at the parent path // finding logic in ConnectionModel. So I'm lazy. diff --git a/src/libs/client/Store.hpp b/src/libs/client/Store.hpp index 70f11142..f86c511a 100644 --- a/src/libs/client/Store.hpp +++ b/src/libs/client/Store.hpp @@ -28,6 +28,7 @@ #include #include #include "interface/EngineInterface.hpp" +#include "interface/Store.hpp" using std::string; using std::list; using Ingen::Shared::EngineInterface; using Raul::Path; @@ -52,9 +53,9 @@ class ConnectionModel; * * \ingroup IngenClient */ -class Store : public sigc::trackable { // FIXME: is trackable necessary? +class ClientStore : public Shared::Store, public sigc::trackable { // FIXME: is trackable necessary? public: - Store(SharedPtr engine, SharedPtr emitter); + ClientStore(SharedPtr engine, SharedPtr emitter); SharedPtr plugin(const string& uri); SharedPtr object(const Path& path); @@ -63,17 +64,28 @@ public: size_t num_object() { return _objects.size(); } + Objects::iterator find(const Path& path) { return _objects.find(path); } + typedef Raul::Table > Plugins; const Plugins& plugins() const { return _plugins; } typedef Raul::PathTable< SharedPtr > Objects; const Objects& objects() const { return _objects; } + Objects& objects() { return _objects; } + + Objects::const_iterator children_begin(SharedPtr o) const; + Objects::const_iterator children_end(SharedPtr o) const; + + SharedPtr find_child(SharedPtr parent, + const string& child_name) const; sigc::signal > signal_new_object; sigc::signal > signal_new_plugin; private: + void add(Shared::GraphObject* o) { throw; } + void add_object(SharedPtr object); SharedPtr remove_object(const Path& path); diff --git a/src/libs/engine/Engine.cpp b/src/libs/engine/Engine.cpp index 0a6d048a..e7c2545c 100644 --- a/src/libs/engine/Engine.cpp +++ b/src/libs/engine/Engine.cpp @@ -27,6 +27,7 @@ #include "tuning.hpp" #include "Event.hpp" #include "common/interface/EventType.hpp" +#include "common/interface/Store.hpp" #include "JackAudioDriver.hpp" #include "NodeFactory.hpp" #include "ClientBroadcaster.hpp" @@ -58,11 +59,15 @@ Engine::Engine(Ingen::Shared::World* world) , _maid(new Raul::Maid(maid_queue_size)) , _post_processor(new PostProcessor(*this, /**_maid, */post_processor_queue_size)) , _broadcaster(new ClientBroadcaster()) - , _object_store(new ObjectStore()) , _node_factory(new NodeFactory(world)) , _quit_flag(false) , _activated(false) { + if (world->store) { + assert(PtrCast(world->store)); + } else { + world->store = SharedPtr(new ObjectStore()); + } } @@ -70,13 +75,12 @@ Engine::~Engine() { deactivate(); - for (ObjectStore::Objects::iterator i = _object_store->objects().begin(); - i != _object_store->objects().end(); ++i) { + for (ObjectStore::Objects::iterator i = object_store()->objects().begin(); + i != object_store()->objects().end(); ++i) { if ( ! PtrCast(i->second)->parent() ) i->second.reset(); } - delete _object_store; delete _broadcaster; delete _node_factory; delete _osc_driver; @@ -87,6 +91,13 @@ Engine::~Engine() munlockall(); } + + +ObjectStore* +Engine::object_store() const +{ + return dynamic_cast(_world->store.get()); +} Driver* @@ -228,7 +239,7 @@ Engine::activate(size_t parallelism) PatchImpl* root_patch = new PatchImpl(*this, "", 1, NULL, _audio_driver->sample_rate(), _audio_driver->buffer_size(), 1); root_patch->activate(); - _object_store->add(root_patch); + _world->store->add(root_patch); root_patch->compiled_patch(root_patch->compile()); assert(_audio_driver->root_patch() == NULL); diff --git a/src/libs/engine/Engine.hpp b/src/libs/engine/Engine.hpp index c2a59f3e..1d3b4253 100644 --- a/src/libs/engine/Engine.hpp +++ b/src/libs/engine/Engine.hpp @@ -90,9 +90,10 @@ public: OSCDriver* osc_driver() const { return _osc_driver; } PostProcessor* post_processor() const { return _post_processor; } ClientBroadcaster* broadcaster() const { return _broadcaster; } - ObjectStore* object_store() const { return _object_store; } NodeFactory* node_factory() const { return _node_factory; } + ObjectStore* object_store() const; + /** Return the active driver for the given type */ Driver* driver(DataType type, EventType event_type); @@ -114,7 +115,6 @@ private: Raul::Maid* _maid; PostProcessor* _post_processor; ClientBroadcaster* _broadcaster; - ObjectStore* _object_store; NodeFactory* _node_factory; bool _quit_flag; diff --git a/src/libs/engine/GraphObjectImpl.cpp b/src/libs/engine/GraphObjectImpl.cpp index 62474bfc..5275261f 100644 --- a/src/libs/engine/GraphObjectImpl.cpp +++ b/src/libs/engine/GraphObjectImpl.cpp @@ -29,20 +29,6 @@ GraphObjectImpl::parent_patch() const } -GraphObjectImpl::const_iterator -GraphObjectImpl::children_begin() const -{ - throw; -} - - -GraphObjectImpl::const_iterator -GraphObjectImpl::children_end() const -{ - throw; -} - - SharedPtr GraphObjectImpl::find_child(const string& name) const { diff --git a/src/libs/engine/GraphObjectImpl.hpp b/src/libs/engine/GraphObjectImpl.hpp index f3c7286a..1eb8acc9 100644 --- a/src/libs/engine/GraphObjectImpl.hpp +++ b/src/libs/engine/GraphObjectImpl.hpp @@ -94,8 +94,6 @@ public: return Path(_parent->path() +"/"+ _name); } - const_iterator children_begin() const; - const_iterator children_end() const; SharedPtr find_child(const std::string& name) const; protected: diff --git a/src/libs/engine/HTTPEngineReceiver.cpp b/src/libs/engine/HTTPEngineReceiver.cpp index baa522ba..47da1eb1 100644 --- a/src/libs/engine/HTTPEngineReceiver.cpp +++ b/src/libs/engine/HTTPEngineReceiver.cpp @@ -22,6 +22,9 @@ #include #include #include "interface/ClientInterface.hpp" +#include "module/Module.hpp" +#include "serialisation/serialisation.hpp" +#include "serialisation/Serialiser.hpp" #include "engine/ThreadManager.hpp" #include "HTTPEngineReceiver.hpp" #include "QueuedEventSource.hpp" @@ -43,6 +46,17 @@ HTTPEngineReceiver::HTTPEngineReceiver(Engine& engine, uint16_t port) cout << "Started HTTP server on port " << soup_server_get_port(_server) << endl; Thread::set_name("HTTP receiver"); + + if (!engine.world()->serialisation_module) + engine.world()->serialisation_module = Ingen::Shared::load_module("ingen_serialisation"); + + if (engine.world()->serialisation_module) + if (!engine.world()->serialiser) + engine.world()->serialiser = SharedPtr( + Ingen::Serialisation::new_serialiser(engine.world())); + + if (!engine.world()->serialiser) + cerr << "WARNING: Failed to load ingen_serialisation module, HTTP disabled." << endl; } @@ -86,26 +100,37 @@ HTTPEngineReceiver::message_callback(SoupServer* server, SoupMessage* msg, const return; } + SharedPtr serialiser = me->_engine.world()->serialiser; + if (!serialiser) { + soup_message_set_status (msg, SOUP_STATUS_INTERNAL_SERVER_ERROR); + return; + } + // FIXME: not thread safe! - ObjectStore* store = me->_engine.object_store(); + SharedPtr store = me->_engine.world()->store; + assert(store); if (!Path::is_valid(path)) { soup_message_set_status (msg, SOUP_STATUS_BAD_REQUEST); return; } - ObjectStore::Objects::iterator start = store->find(path); + Store::Objects::const_iterator start = store->find(path); if (start == store->objects().end()) { soup_message_set_status (msg, SOUP_STATUS_NOT_FOUND); return; } +#if 0 ObjectStore::Objects::iterator end = store->objects().find_descendants_end(start); string response; for (ObjectStore::Objects::iterator i = start; i != end; ++i) response.append(i->first).append("\n"); +#endif + const string response = serialiser->to_string(start->second, + "http://example.org/whatever", GraphObject::Variables()); soup_message_set_status (msg, SOUP_STATUS_OK); soup_message_set_response (msg, "text/plain", SOUP_MEMORY_COPY, response.c_str(), response.length()); diff --git a/src/libs/engine/Makefile.am b/src/libs/engine/Makefile.am index 0f069e10..938d6817 100644 --- a/src/libs/engine/Makefile.am +++ b/src/libs/engine/Makefile.am @@ -20,6 +20,7 @@ libingen_engine_la_CXXFLAGS = \ libingen_engine_la_LDFLAGS = -no-undefined -module -avoid-version libingen_engine_la_LIBADD = \ ../shared/libingen_shared.la \ + ../module/libingen_module.la \ @GLIBMM_LIBS@ \ @JACK_LIBS@ \ @LASH_LIBS@ \ diff --git a/src/libs/engine/ObjectStore.cpp b/src/libs/engine/ObjectStore.cpp index 052200fd..3cecb338 100644 --- a/src/libs/engine/ObjectStore.cpp +++ b/src/libs/engine/ObjectStore.cpp @@ -72,11 +72,33 @@ ObjectStore::find_object(const Path& path) } +ObjectStore::Objects::const_iterator +ObjectStore::children_begin(SharedPtr o) const +{ + Objects::const_iterator parent = _objects.find(o->path()); + assert(parent != _objects.end()); + ++parent; + return parent; +} + + +ObjectStore::Objects::const_iterator +ObjectStore::children_end(SharedPtr o) const +{ + Objects::const_iterator parent = _objects.find(o->path()); + assert(parent != _objects.end()); + return _objects.find_descendants_end(parent); +} + + /** Add an object to the store. Not realtime safe. */ void -ObjectStore::add(GraphObjectImpl* o) +ObjectStore::add(GraphObject* obj) { + GraphObjectImpl* o = dynamic_cast(obj); + assert(o); + assert(ThreadManager::current_thread_id() == THREAD_PRE_PROCESS); if (_objects.find(o->path()) != _objects.end()) { diff --git a/src/libs/engine/ObjectStore.hpp b/src/libs/engine/ObjectStore.hpp index bf85d3e1..edba52f0 100644 --- a/src/libs/engine/ObjectStore.hpp +++ b/src/libs/engine/ObjectStore.hpp @@ -21,6 +21,7 @@ #include #include #include +#include "interface/Store.hpp" using std::string; using namespace Raul; @@ -44,7 +45,7 @@ class GraphObjectImpl; * Searching with find*() is fast (O(log(n)) binary search on contiguous * memory) and realtime safe, but modification (add or remove) are neither. */ -class ObjectStore +class ObjectStore : public Shared::Store { public: typedef Raul::PathTable< SharedPtr > Objects; @@ -56,7 +57,10 @@ public: Objects::iterator find(const Path& path) { return _objects.find(path); } - void add(GraphObjectImpl* o); + Objects::const_iterator children_begin(SharedPtr o) const; + Objects::const_iterator children_end(SharedPtr o) const; + + void add(Shared::GraphObject* o); void add(const Table >& family); //void add(TreeNode* o); diff --git a/src/libs/engine/events/AllNotesOffEvent.cpp b/src/libs/engine/events/AllNotesOffEvent.cpp index 2e1f45fa..a0b3360f 100644 --- a/src/libs/engine/events/AllNotesOffEvent.cpp +++ b/src/libs/engine/events/AllNotesOffEvent.cpp @@ -19,6 +19,8 @@ #include "Responder.hpp" #include "Engine.hpp" #include "ObjectStore.hpp" +#include "module/World.hpp" +#include "interface/Store.hpp" namespace Ingen { diff --git a/src/libs/gui/App.cpp b/src/libs/gui/App.cpp index a00f93a5..b558f706 100644 --- a/src/libs/gui/App.cpp +++ b/src/libs/gui/App.cpp @@ -29,6 +29,7 @@ #include "module/Module.hpp" #include "module/World.hpp" #include "interface/EngineInterface.hpp" +#include "serialisation/serialisation.hpp" #include "client/ObjectModel.hpp" #include "client/PatchModel.hpp" #include "client/Store.hpp" @@ -66,26 +67,23 @@ App* App::_instance = 0; App::App(Ingen::Shared::World* world) - : _serialisation_module(Ingen::Shared::load_module("ingen_serialisation")) - , _configuration(new Configuration()) + : _configuration(new Configuration()) , _about_dialog(NULL) , _window_factory(new WindowFactory()) , _world(world) , _enable_signal(true) { - if (_serialisation_module) { - Serialiser* (*new_serialiser)(Ingen::Shared::World*) = NULL; + // FIXME: defer loading of serialisation module until needed + if (!world->serialisation_module) + world->serialisation_module = Ingen::Shared::load_module("ingen_serialisation"); - bool found = _serialisation_module->get_symbol("new_serialiser", (void*&)new_serialiser); + if (world->serialisation_module) + if (!world->serialiser) + world->serialiser = SharedPtr( + Ingen::Serialisation::new_serialiser(world)); - if (found) - _serialiser = SharedPtr(new_serialiser(world)); - } - - if ( ! _serialiser) { + if (!world->serialiser) cerr << "WARNING: Failed to load ingen_serialisation module, save disabled." << endl; - cerr << "(If you are running from the source tree, source set_dev_environment.sh)" << endl; - } Glib::RefPtr glade_xml = GladeFactory::new_glade_reference(); @@ -176,7 +174,9 @@ App::attach(SharedPtr client) _world->engine->register_client(client.get()); _client = client; - _store = SharedPtr(new Store(_world->engine, client)); + assert(!_world->store); + _store = SharedPtr(new ClientStore(_world->engine, client)); + _world->store = _store; _loader = SharedPtr(new ThreadedLoader(_world->engine)); _patch_tree_window->init(*_store); diff --git a/src/libs/gui/App.hpp b/src/libs/gui/App.hpp index 44878925..f7a3ead1 100644 --- a/src/libs/gui/App.hpp +++ b/src/libs/gui/App.hpp @@ -29,6 +29,7 @@ #include #include #include +#include using namespace std; @@ -41,7 +42,7 @@ namespace Ingen { namespace Client { class PatchModel; class PluginModel; - class Store; + class ClientStore; class SigClientInterface; } namespace Serialisation { @@ -103,12 +104,10 @@ public: const SharedPtr engine() const { return _world->engine; } const SharedPtr& client() const { return _client; } - const SharedPtr& store() const { return _store; } + const SharedPtr& store() const { return _store; } const SharedPtr& loader() const { return _loader; } - const SharedPtr& serialiser() const { return _serialiser; } + const SharedPtr& serialiser() const { return _world->serialiser; } - SharedPtr serialisation_module() { return _serialisation_module; } - static inline App& instance() { assert(_instance); return *_instance; } static void run(int argc, char** argv, Ingen::Shared::World* world); @@ -138,12 +137,9 @@ protected: static App* _instance; - SharedPtr _serialisation_module; - SharedPtr _client; - SharedPtr _store; + SharedPtr _store; SharedPtr _loader; - SharedPtr _serialiser; Configuration* _configuration; diff --git a/src/libs/gui/LoadPluginWindow.cpp b/src/libs/gui/LoadPluginWindow.cpp index 99ab54c2..c518f25f 100644 --- a/src/libs/gui/LoadPluginWindow.cpp +++ b/src/libs/gui/LoadPluginWindow.cpp @@ -129,7 +129,7 @@ LoadPluginWindow::name_changed() if (!Path::is_valid_name(name)) { //m_message_label->set_text("Name contains invalid characters."); _add_button->property_sensitive() = false; - } else if (_patch->find_child(name)) { + } else if (App::instance().store()->find_child(_patch, name)) { //m_message_label->set_text("An object already exists with that name."); _add_button->property_sensitive() = false; } else if (name.length() == 0) { @@ -288,7 +288,7 @@ LoadPluginWindow::plugin_selection_changed() if (iter) { Gtk::TreeModel::Row row = *iter; boost::shared_ptr p = row.get_value(_plugins_columns._col_plugin_model); - _plugin_name_offset = _patch->child_name_offset(p->default_node_name()); + _plugin_name_offset = PatchModel::child_name_offset(*App::instance().store().get(), _patch, p->default_node_name()); _node_name_entry->set_text(generate_module_name(_plugin_name_offset)); } else { _plugin_name_offset = 0; diff --git a/src/libs/gui/NewSubpatchWindow.cpp b/src/libs/gui/NewSubpatchWindow.cpp index 69c8471e..def57975 100644 --- a/src/libs/gui/NewSubpatchWindow.cpp +++ b/src/libs/gui/NewSubpatchWindow.cpp @@ -71,7 +71,8 @@ NewSubpatchWindow::name_changed() if (!Path::is_valid_name(name)) { _message_label->set_text("Name contains invalid characters."); _ok_button->property_sensitive() = false; - } else if (_patch->find_child(name)) { + } else if (App::instance().store()->find(_patch->path().base() + name) + != App::instance().store()->objects().end()) { _message_label->set_text("An object already exists with that name."); _ok_button->property_sensitive() = false; } else if (name.length() == 0) { diff --git a/src/libs/gui/PatchCanvas.cpp b/src/libs/gui/PatchCanvas.cpp index a43ebcf3..d7ffd78b 100644 --- a/src/libs/gui/PatchCanvas.cpp +++ b/src/libs/gui/PatchCanvas.cpp @@ -41,7 +41,7 @@ #include "SubpatchModule.hpp" #include "GladeFactory.hpp" #include "WindowFactory.hpp" -using Ingen::Client::Store; +using Ingen::Client::ClientStore; using Ingen::Serialisation::Serialiser; using Ingen::Client::PluginModel; @@ -159,10 +159,10 @@ PatchCanvas::build_internal_menu() _menu->reorder_child(*internal_menu_item, 2); } - const Store::Plugins& plugins = App::instance().store()->plugins(); + const ClientStore::Plugins& plugins = App::instance().store()->plugins(); // Add Internal plugins - for (Store::Plugins::const_iterator i = plugins.begin(); i != plugins.end(); ++i) { + for (ClientStore::Plugins::const_iterator i = plugins.begin(); i != plugins.end(); ++i) { SharedPtr p = i->second; if (p->type() == Plugin::Internal) { _internal_menu->items().push_back(Gtk::Menu_Helpers::MenuElem(p->name(), @@ -200,10 +200,10 @@ PatchCanvas::build_plugin_class_menu(Gtk::Menu* menu, } } - const Store::Plugins& plugins = App::instance().store()->plugins(); + const ClientStore::Plugins& plugins = App::instance().store()->plugins(); // Add LV2 plugins - for (Store::Plugins::const_iterator i = plugins.begin(); i != plugins.end(); ++i) { + for (ClientStore::Plugins::const_iterator i = plugins.begin(); i != plugins.end(); ++i) { SLV2Plugin p = i->second->slv2_plugin(); if (p && slv2_plugin_get_class(p) == plugin_class) { @@ -256,8 +256,8 @@ PatchCanvas::build() boost::dynamic_pointer_cast(shared_from_this()); // Create modules for nodes - for (ObjectModel::const_iterator i = _patch->children_begin(); - i != _patch->children_end(); ++i) { + for (ObjectModel::const_iterator i = App::instance().store()->children_begin(_patch); + i != App::instance().store()->children_end(_patch); ++i) { SharedPtr node = PtrCast(i->second); if (node && node->parent() == _patch) add_node(node); @@ -539,7 +539,7 @@ PatchCanvas::destroy_selection() void PatchCanvas::copy_selection() { - Serialiser serialiser(*App::instance().world()->rdf_world); + Serialiser serialiser(*App::instance().world()); serialiser.start_to_string(""); for (list >::iterator m = _selected_items.begin(); m != _selected_items.end(); ++m) { @@ -617,7 +617,7 @@ void PatchCanvas::load_plugin(SharedPtr plugin) { string name = plugin->default_node_name(); - unsigned offset = _patch->child_name_offset(name); + unsigned offset = PatchModel::child_name_offset(*App::instance().store().get(), _patch, name); if (offset != 0) { std::stringstream ss; ss << name << "_" << offset; diff --git a/src/libs/gui/PatchTreeWindow.cpp b/src/libs/gui/PatchTreeWindow.cpp index 595c83b8..85f4f19c 100644 --- a/src/libs/gui/PatchTreeWindow.cpp +++ b/src/libs/gui/PatchTreeWindow.cpp @@ -66,7 +66,7 @@ PatchTreeWindow::PatchTreeWindow(BaseObjectType* cobject, void -PatchTreeWindow::init(Store& store) +PatchTreeWindow::init(ClientStore& store) { store.signal_new_object.connect(sigc::mem_fun(this, &PatchTreeWindow::new_object)); } diff --git a/src/libs/gui/PatchTreeWindow.hpp b/src/libs/gui/PatchTreeWindow.hpp index 534f4607..85d803cd 100644 --- a/src/libs/gui/PatchTreeWindow.hpp +++ b/src/libs/gui/PatchTreeWindow.hpp @@ -23,9 +23,9 @@ #include namespace Ingen { namespace Client { - class Store; + class ClientStore; } } -using Ingen::Client::Store; +using Ingen::Client::ClientStore; namespace Ingen { namespace GUI { @@ -43,7 +43,7 @@ class PatchTreeWindow : public Gtk::Window public: PatchTreeWindow(BaseObjectType* cobject, const Glib::RefPtr& refGlade); - void init(Store& store); + void init(ClientStore& store); void new_object(SharedPtr object); diff --git a/src/libs/gui/ThreadedLoader.cpp b/src/libs/gui/ThreadedLoader.cpp index 949cde1a..1c85d637 100644 --- a/src/libs/gui/ThreadedLoader.cpp +++ b/src/libs/gui/ThreadedLoader.cpp @@ -36,10 +36,10 @@ ThreadedLoader::ThreadedLoader(SharedPtr engine) set_name("Loader"); // FIXME: rework this so the thread is only present when it's doing something (save mem) - if (App::instance().serialisation_module()) { + if (App::instance().world()->serialisation_module) { Loader* (*new_loader)() = NULL; - bool found = App::instance().serialisation_module()->get_symbol( + bool found = App::instance().world()->serialisation_module->get_symbol( "new_loader", (void*&)new_loader); if (found) diff --git a/src/libs/gui/UploadPatchWindow.cpp b/src/libs/gui/UploadPatchWindow.cpp index 16fa0665..b14f7e2c 100644 --- a/src/libs/gui/UploadPatchWindow.cpp +++ b/src/libs/gui/UploadPatchWindow.cpp @@ -247,7 +247,7 @@ UploadPatchWindow::upload_clicked() _upload_progress->set_fraction(0.0); _upload_progress->set_text(""); - Serialiser s(*App::instance().world()->rdf_world); + Serialiser s(*App::instance().world()); const string uri = string("http://rdf.drobilla.net/ingen_patches/") .append(symbol).append(".ingen.ttl"); diff --git a/src/libs/module/Makefile.am b/src/libs/module/Makefile.am index 31a327da..84d499e4 100644 --- a/src/libs/module/Makefile.am +++ b/src/libs/module/Makefile.am @@ -9,7 +9,6 @@ libingen_module_la_CXXFLAGS = \ -DINGEN_MODULE_DIR=\"$(libdir)/ingen\" libingen_module_la_LIBADD = \ - ../shared/libingen_shared.la \ @GLIBMM_LIBS@ \ @REDLANDMM_LIBS@ \ @RAUL_LIBS@ \ diff --git a/src/libs/module/World.hpp b/src/libs/module/World.hpp index f6c5a67a..eed98085 100644 --- a/src/libs/module/World.hpp +++ b/src/libs/module/World.hpp @@ -34,8 +34,12 @@ namespace Redland { class World; } namespace Ingen { class Engine; +namespace Serialisation { class Serialiser; } +using Serialisation::Serialiser; + namespace Shared { class EngineInterface; +class Store; /** The "world" all Ingen modules may share. @@ -58,6 +62,10 @@ struct World { SharedPtr engine; SharedPtr local_engine; + SharedPtr serialiser; + SharedPtr store; + + SharedPtr serialisation_module; }; diff --git a/src/libs/serialisation/Serialiser.cpp b/src/libs/serialisation/Serialiser.cpp index 5deb17e9..1caac5b0 100644 --- a/src/libs/serialisation/Serialiser.cpp +++ b/src/libs/serialisation/Serialiser.cpp @@ -34,6 +34,7 @@ #include #include #include +#include "module/World.hpp" #include "interface/EngineInterface.hpp" #include "interface/Plugin.hpp" #include "interface/Patch.hpp" @@ -52,8 +53,9 @@ namespace Ingen { namespace Serialisation { -Serialiser::Serialiser(Redland::World& world) - : _world(world) +Serialiser::Serialiser(Shared::World& world) + : _store(world.store) + , _world(*world.rdf_world) { } @@ -296,7 +298,9 @@ Serialiser::serialise_patch(SharedPtr patch) serialise_variables(patch_id, patch->variables()); - for (GraphObject::const_iterator n = patch->children_begin(); n != patch->children_end(); ++n) { + //for (GraphObject::const_iterator n = patch->children_begin(); n != patch->children_end(); ++n) { + for (GraphObject::const_iterator n = _store->children_begin(patch); + n != _store->children_end(patch); ++n) { if (n->second->graph_parent() != patch.get()) continue; diff --git a/src/libs/serialisation/Serialiser.hpp b/src/libs/serialisation/Serialiser.hpp index 26439bdf..51d89cab 100644 --- a/src/libs/serialisation/Serialiser.hpp +++ b/src/libs/serialisation/Serialiser.hpp @@ -29,6 +29,7 @@ #include #include #include "interface/GraphObject.hpp" +#include "interface/Store.hpp" using namespace Raul; using namespace Ingen::Shared; @@ -42,6 +43,7 @@ namespace Shared { class Node; class Port; class Connection; + class World; } namespace Serialisation { @@ -54,9 +56,9 @@ namespace Serialisation { class Serialiser { public: - Serialiser(Redland::World& world); + Serialiser(Shared::World& world); - void to_file(SharedPtr object, const std::string& filename); + void to_file(SharedPtr object, const std::string& filename); std::string to_string(SharedPtr object, const std::string& base_uri, @@ -88,12 +90,13 @@ private: typedef std::map NodeMap; - SharedPtr _root_object; - Mode _mode; - NodeMap _node_map; - std::string _base_uri; - Redland::World& _world; - Redland::Model* _model; + SharedPtr _root_object; + SharedPtr _store; + Mode _mode; + NodeMap _node_map; + std::string _base_uri; + Redland::World& _world; + Redland::Model* _model; }; diff --git a/src/libs/serialisation/serialisation.cpp b/src/libs/serialisation/serialisation.cpp index 5da28529..49b8d465 100644 --- a/src/libs/serialisation/serialisation.cpp +++ b/src/libs/serialisation/serialisation.cpp @@ -36,7 +36,7 @@ Ingen::Serialisation::Serialiser* new_serialiser(Ingen::Shared::World* world) { assert(world->rdf_world); - return new Serialiser(*world->rdf_world); + return new Serialiser(*world); } -- cgit v1.2.1