From fca0d027053f78684823c9c0b885045708125ef6 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 16 Aug 2008 02:36:17 +0000 Subject: Reorganize two 'store' implementations, move header to shared module (prepare for factoring out). git-svn-id: http://svn.drobilla.net/lad/ingen@1395 a436a847-0d15-0410-975c-d299462d15a1 --- src/libs/client/ClientStore.cpp | 155 ++++++++++++++++++++++++++++++++++++++++ src/libs/client/ClientStore.hpp | 155 ++++++++++++++++++++++++++++++++++++++++ src/libs/client/Makefile.am | 4 +- src/libs/client/ObjectModel.hpp | 1 - src/libs/client/PatchModel.cpp | 1 + src/libs/client/Store.hpp | 155 ---------------------------------------- 6 files changed, 313 insertions(+), 158 deletions(-) create mode 100644 src/libs/client/ClientStore.cpp create mode 100644 src/libs/client/ClientStore.hpp delete mode 100644 src/libs/client/Store.hpp (limited to 'src/libs/client') diff --git a/src/libs/client/ClientStore.cpp b/src/libs/client/ClientStore.cpp new file mode 100644 index 00000000..24c23f14 --- /dev/null +++ b/src/libs/client/ClientStore.cpp @@ -0,0 +1,155 @@ +/* This file is part of Ingen. + * Copyright (C) 2007 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 STORE_H +#define STORE_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "interface/EngineInterface.hpp" +#include "shared/Store.hpp" +using std::string; using std::list; +using Ingen::Shared::EngineInterface; +using Raul::Path; +using Raul::Atom; + +namespace Ingen { + +namespace Shared { class GraphObject; } + +namespace Client { + +class SigClientInterface; +class ObjectModel; +class PluginModel; +class PatchModel; +class NodeModel; +class PortModel; +class ConnectionModel; + + +/** Automatically manages models of objects in the engine. + * + * \ingroup IngenClient + */ +class ClientStore : public Shared::Store, public sigc::trackable { // FIXME: is trackable necessary? +public: + ClientStore(SharedPtr engine, SharedPtr emitter); + + SharedPtr plugin(const string& uri); + SharedPtr object(const Path& path); + + void clear(); + + 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); + + void add_plugin(SharedPtr plugin); + + SharedPtr connection_patch(const Path& src_port_path, const Path& dst_port_path); + + // It would be nice to integrate these somehow.. + + void add_orphan(SharedPtr orphan); + void resolve_orphans(SharedPtr parent); + + void add_connection_orphan(std::pair orphan); + void resolve_connection_orphans(SharedPtr port); + + void add_plugin_orphan(SharedPtr orphan); + void resolve_plugin_orphans(SharedPtr plugin); + + void add_variable_orphan(const Path& subject, const string& predicate, const Atom& value); + void resolve_variable_orphans(SharedPtr subject); + + // Slots for SigClientInterface signals + void destruction_event(const Path& path); + void rename_event(const Path& old_path, const Path& new_path); + void new_plugin_event(const string& uri, const string& type_uri, const string& symbol, const string& name); + void new_patch_event(const Path& path, uint32_t poly); + void new_node_event(const string& plugin_uri, const Path& node_path, bool is_polyphonic, uint32_t num_ports); + void new_port_event(const Path& path, uint32_t index, const string& data_type, bool is_output); + void polyphonic_event(const Path& path, bool polyphonic); + void patch_enabled_event(const Path& path); + void patch_disabled_event(const Path& path); + void patch_polyphony_event(const Path& path, uint32_t poly); + void patch_cleared_event(const Path& path); + void variable_change_event(const Path& subject_path, const string& predicate, const Atom& value); + void control_change_event(const Path& port_path, float value); + void port_activity_event(const Path& port_path); + void connection_event(const Path& src_port_path, const Path& dst_port_path); + void disconnection_event(const Path& src_port_path, const Path& dst_port_path); + + bool attempt_connection(const Path& src_port_path, const Path& dst_port_path, bool add_orphan=false); + + SharedPtr _engine; + SharedPtr _emitter; + + Objects _objects; ///< Map, keyed by Ingen path + Plugins _plugins; ///< Map, keyed by plugin URI + + /** Objects we've received, but depend on the existance of another unknown object. + * Keyed by the path of the depended-on object (for tolerance of orderless comms) */ + Raul::PathTable > > _orphans; + + /** Same idea, except with plugins instead of parents. + * It's unfortunate everything doesn't just have a URI and this was the same.. ahem.. */ + Raul::Table > > _plugin_orphans; + + /** Not orphans OF variable like the above, but orphans which are variable */ + Raul::PathTable > > _variable_orphans; + + /** Ditto */ + list > _connection_orphans; +}; + + +} // namespace Client +} // namespace Ingen + +#endif // STORE_H diff --git a/src/libs/client/ClientStore.hpp b/src/libs/client/ClientStore.hpp new file mode 100644 index 00000000..24c23f14 --- /dev/null +++ b/src/libs/client/ClientStore.hpp @@ -0,0 +1,155 @@ +/* This file is part of Ingen. + * Copyright (C) 2007 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 STORE_H +#define STORE_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "interface/EngineInterface.hpp" +#include "shared/Store.hpp" +using std::string; using std::list; +using Ingen::Shared::EngineInterface; +using Raul::Path; +using Raul::Atom; + +namespace Ingen { + +namespace Shared { class GraphObject; } + +namespace Client { + +class SigClientInterface; +class ObjectModel; +class PluginModel; +class PatchModel; +class NodeModel; +class PortModel; +class ConnectionModel; + + +/** Automatically manages models of objects in the engine. + * + * \ingroup IngenClient + */ +class ClientStore : public Shared::Store, public sigc::trackable { // FIXME: is trackable necessary? +public: + ClientStore(SharedPtr engine, SharedPtr emitter); + + SharedPtr plugin(const string& uri); + SharedPtr object(const Path& path); + + void clear(); + + 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); + + void add_plugin(SharedPtr plugin); + + SharedPtr connection_patch(const Path& src_port_path, const Path& dst_port_path); + + // It would be nice to integrate these somehow.. + + void add_orphan(SharedPtr orphan); + void resolve_orphans(SharedPtr parent); + + void add_connection_orphan(std::pair orphan); + void resolve_connection_orphans(SharedPtr port); + + void add_plugin_orphan(SharedPtr orphan); + void resolve_plugin_orphans(SharedPtr plugin); + + void add_variable_orphan(const Path& subject, const string& predicate, const Atom& value); + void resolve_variable_orphans(SharedPtr subject); + + // Slots for SigClientInterface signals + void destruction_event(const Path& path); + void rename_event(const Path& old_path, const Path& new_path); + void new_plugin_event(const string& uri, const string& type_uri, const string& symbol, const string& name); + void new_patch_event(const Path& path, uint32_t poly); + void new_node_event(const string& plugin_uri, const Path& node_path, bool is_polyphonic, uint32_t num_ports); + void new_port_event(const Path& path, uint32_t index, const string& data_type, bool is_output); + void polyphonic_event(const Path& path, bool polyphonic); + void patch_enabled_event(const Path& path); + void patch_disabled_event(const Path& path); + void patch_polyphony_event(const Path& path, uint32_t poly); + void patch_cleared_event(const Path& path); + void variable_change_event(const Path& subject_path, const string& predicate, const Atom& value); + void control_change_event(const Path& port_path, float value); + void port_activity_event(const Path& port_path); + void connection_event(const Path& src_port_path, const Path& dst_port_path); + void disconnection_event(const Path& src_port_path, const Path& dst_port_path); + + bool attempt_connection(const Path& src_port_path, const Path& dst_port_path, bool add_orphan=false); + + SharedPtr _engine; + SharedPtr _emitter; + + Objects _objects; ///< Map, keyed by Ingen path + Plugins _plugins; ///< Map, keyed by plugin URI + + /** Objects we've received, but depend on the existance of another unknown object. + * Keyed by the path of the depended-on object (for tolerance of orderless comms) */ + Raul::PathTable > > _orphans; + + /** Same idea, except with plugins instead of parents. + * It's unfortunate everything doesn't just have a URI and this was the same.. ahem.. */ + Raul::Table > > _plugin_orphans; + + /** Not orphans OF variable like the above, but orphans which are variable */ + Raul::PathTable > > _variable_orphans; + + /** Ditto */ + list > _connection_orphans; +}; + + +} // namespace Client +} // namespace Ingen + +#endif // STORE_H diff --git a/src/libs/client/Makefile.am b/src/libs/client/Makefile.am index f111a54d..7047ce62 100644 --- a/src/libs/client/Makefile.am +++ b/src/libs/client/Makefile.am @@ -49,8 +49,8 @@ libingen_client_la_SOURCES = \ PortModel.cpp \ PortModel.hpp \ SigClientInterface.hpp \ - Store.cpp \ - Store.hpp \ + ClientStore.cpp \ + ClientStore.hpp \ ThreadedSigClientInterface.cpp \ ThreadedSigClientInterface.hpp \ client.cpp \ diff --git a/src/libs/client/ObjectModel.hpp b/src/libs/client/ObjectModel.hpp index f052f1d9..dbd188a3 100644 --- a/src/libs/client/ObjectModel.hpp +++ b/src/libs/client/ObjectModel.hpp @@ -30,7 +30,6 @@ #include #include #include "interface/GraphObject.hpp" -#include "Store.hpp" using Raul::PathTable; using std::string; diff --git a/src/libs/client/PatchModel.cpp b/src/libs/client/PatchModel.cpp index 7f928b41..360707d3 100644 --- a/src/libs/client/PatchModel.cpp +++ b/src/libs/client/PatchModel.cpp @@ -18,6 +18,7 @@ #include "PatchModel.hpp" #include "NodeModel.hpp" #include "ConnectionModel.hpp" +#include "ClientStore.hpp" #include #include diff --git a/src/libs/client/Store.hpp b/src/libs/client/Store.hpp deleted file mode 100644 index f86c511a..00000000 --- a/src/libs/client/Store.hpp +++ /dev/null @@ -1,155 +0,0 @@ -/* This file is part of Ingen. - * Copyright (C) 2007 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 STORE_H -#define STORE_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "interface/EngineInterface.hpp" -#include "interface/Store.hpp" -using std::string; using std::list; -using Ingen::Shared::EngineInterface; -using Raul::Path; -using Raul::Atom; - -namespace Ingen { - -namespace Shared { class GraphObject; } - -namespace Client { - -class SigClientInterface; -class ObjectModel; -class PluginModel; -class PatchModel; -class NodeModel; -class PortModel; -class ConnectionModel; - - -/** Automatically manages models of objects in the engine. - * - * \ingroup IngenClient - */ -class ClientStore : public Shared::Store, public sigc::trackable { // FIXME: is trackable necessary? -public: - ClientStore(SharedPtr engine, SharedPtr emitter); - - SharedPtr plugin(const string& uri); - SharedPtr object(const Path& path); - - void clear(); - - 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); - - void add_plugin(SharedPtr plugin); - - SharedPtr connection_patch(const Path& src_port_path, const Path& dst_port_path); - - // It would be nice to integrate these somehow.. - - void add_orphan(SharedPtr orphan); - void resolve_orphans(SharedPtr parent); - - void add_connection_orphan(std::pair orphan); - void resolve_connection_orphans(SharedPtr port); - - void add_plugin_orphan(SharedPtr orphan); - void resolve_plugin_orphans(SharedPtr plugin); - - void add_variable_orphan(const Path& subject, const string& predicate, const Atom& value); - void resolve_variable_orphans(SharedPtr subject); - - // Slots for SigClientInterface signals - void destruction_event(const Path& path); - void rename_event(const Path& old_path, const Path& new_path); - void new_plugin_event(const string& uri, const string& type_uri, const string& symbol, const string& name); - void new_patch_event(const Path& path, uint32_t poly); - void new_node_event(const string& plugin_uri, const Path& node_path, bool is_polyphonic, uint32_t num_ports); - void new_port_event(const Path& path, uint32_t index, const string& data_type, bool is_output); - void polyphonic_event(const Path& path, bool polyphonic); - void patch_enabled_event(const Path& path); - void patch_disabled_event(const Path& path); - void patch_polyphony_event(const Path& path, uint32_t poly); - void patch_cleared_event(const Path& path); - void variable_change_event(const Path& subject_path, const string& predicate, const Atom& value); - void control_change_event(const Path& port_path, float value); - void port_activity_event(const Path& port_path); - void connection_event(const Path& src_port_path, const Path& dst_port_path); - void disconnection_event(const Path& src_port_path, const Path& dst_port_path); - - bool attempt_connection(const Path& src_port_path, const Path& dst_port_path, bool add_orphan=false); - - SharedPtr _engine; - SharedPtr _emitter; - - Objects _objects; ///< Map, keyed by Ingen path - Plugins _plugins; ///< Map, keyed by plugin URI - - /** Objects we've received, but depend on the existance of another unknown object. - * Keyed by the path of the depended-on object (for tolerance of orderless comms) */ - Raul::PathTable > > _orphans; - - /** Same idea, except with plugins instead of parents. - * It's unfortunate everything doesn't just have a URI and this was the same.. ahem.. */ - Raul::Table > > _plugin_orphans; - - /** Not orphans OF variable like the above, but orphans which are variable */ - Raul::PathTable > > _variable_orphans; - - /** Ditto */ - list > _connection_orphans; -}; - - -} // namespace Client -} // namespace Ingen - -#endif // STORE_H -- cgit v1.2.1