diff options
author | David Robillard <d@drobilla.net> | 2007-10-07 19:00:30 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2007-10-07 19:00:30 +0000 |
commit | 2cb36f0265a391388b6edf988d919911b79aca4d (patch) | |
tree | 7b796835325e84e152365104b4c23bf4109f2293 /src/libs/client | |
parent | 299f075679fc7ea6a67001c2cc0442511e167cbc (diff) | |
download | ingen-2cb36f0265a391388b6edf988d919911b79aca4d.tar.gz ingen-2cb36f0265a391388b6edf988d919911b79aca4d.tar.bz2 ingen-2cb36f0265a391388b6edf988d919911b79aca4d.zip |
Begin using shared virtual Node interface client side.
git-svn-id: http://svn.drobilla.net/lad/ingen@836 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/libs/client')
-rw-r--r-- | src/libs/client/ConnectionModel.cpp | 4 | ||||
-rw-r--r-- | src/libs/client/ConnectionModel.hpp | 4 | ||||
-rw-r--r-- | src/libs/client/DeprecatedLoader.cpp | 26 | ||||
-rw-r--r-- | src/libs/client/DeprecatedLoader.hpp | 14 | ||||
-rw-r--r-- | src/libs/client/NodeModel.hpp | 15 | ||||
-rw-r--r-- | src/libs/client/ObjectModel.hpp | 10 | ||||
-rw-r--r-- | src/libs/client/Serializer.cpp | 53 |
7 files changed, 67 insertions, 59 deletions
diff --git a/src/libs/client/ConnectionModel.cpp b/src/libs/client/ConnectionModel.cpp index a40da9e4..d35457d1 100644 --- a/src/libs/client/ConnectionModel.cpp +++ b/src/libs/client/ConnectionModel.cpp @@ -51,7 +51,7 @@ ConnectionModel::ConnectionModel(SharedPtr<PortModel> src, SharedPtr<PortModel> } -const Path& +const Path ConnectionModel::src_port_path() const { if (!_src_port) @@ -61,7 +61,7 @@ ConnectionModel::src_port_path() const } -const Path& +const Path ConnectionModel::dst_port_path() const { if (!_dst_port) diff --git a/src/libs/client/ConnectionModel.hpp b/src/libs/client/ConnectionModel.hpp index 304db2b7..1a73b123 100644 --- a/src/libs/client/ConnectionModel.hpp +++ b/src/libs/client/ConnectionModel.hpp @@ -47,8 +47,8 @@ public: SharedPtr<PortModel> src_port() const { return _src_port; } SharedPtr<PortModel> dst_port() const { return _dst_port; } - const Path& src_port_path() const; - const Path& dst_port_path() const; + const Path src_port_path() const; + const Path dst_port_path() const; private: friend class Store; diff --git a/src/libs/client/DeprecatedLoader.cpp b/src/libs/client/DeprecatedLoader.cpp index ce536b4f..96305884 100644 --- a/src/libs/client/DeprecatedLoader.cpp +++ b/src/libs/client/DeprecatedLoader.cpp @@ -80,7 +80,7 @@ DeprecatedLoader::translate_load_path(const string& path) * Adds a namespace prefix for known keys, and ignores the rest. */ void -DeprecatedLoader::add_metadata(MetadataMap& data, string old_key, string value) +DeprecatedLoader::add_metadata(GraphObject::MetadataMap& data, string old_key, string value) { string key = ""; if (old_key == "module-x") @@ -132,11 +132,11 @@ DeprecatedLoader::add_metadata(MetadataMap& data, string old_key, string value) * Returns the path of the newly created patch. */ string -DeprecatedLoader::load_patch(const Glib::ustring& filename, - boost::optional<Path> parent_path, - string name, - MetadataMap initial_data, - bool existing) +DeprecatedLoader::load_patch(const Glib::ustring& filename, + boost::optional<Path> parent_path, + string name, + GraphObject::MetadataMap initial_data, + bool existing) { cerr << "[DeprecatedLoader] Loading patch " << filename << "" << endl; @@ -147,7 +147,7 @@ DeprecatedLoader::load_patch(const Glib::ustring& filename, size_t poly = 0; /* Use parameter overridden polyphony, if given */ - Raul::Table<string, Atom>::iterator poly_param = initial_data.find("ingen:polyphony"); + GraphObject::MetadataMap::iterator poly_param = initial_data.find("ingen:polyphony"); if (poly_param != initial_data.end() && poly_param->second.type() == Atom::INT) poly = poly_param->second; @@ -217,7 +217,7 @@ DeprecatedLoader::load_patch(const Glib::ustring& filename, // Create it, if we're not merging if (!existing) { _engine->create_patch(path, poly); - for (MetadataMap::const_iterator i = initial_data.begin(); i != initial_data.end(); ++i) + for (GraphObject::MetadataMap::const_iterator i = initial_data.begin(); i != initial_data.end(); ++i) _engine->set_metadata(path, i->first, i->second); } @@ -301,7 +301,7 @@ DeprecatedLoader::load_node(const Path& parent, xmlDocPtr doc, const xmlNodePtr string library_name; // deprecated string plugin_label; // deprecated - MetadataMap initial_data; + GraphObject::MetadataMap initial_data; while (cur != NULL) { key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); @@ -462,7 +462,7 @@ DeprecatedLoader::load_node(const Path& parent, xmlDocPtr doc, const xmlNodePtr path = new_path; - for (MetadataMap::const_iterator i = initial_data.begin(); i != initial_data.end(); ++i) + for (GraphObject::MetadataMap::const_iterator i = initial_data.begin(); i != initial_data.end(); ++i) _engine->set_metadata(path, i->first, i->second); return SharedPtr<NodeModel>(); @@ -486,7 +486,7 @@ DeprecatedLoader::load_node(const Path& parent, xmlDocPtr doc, const xmlNodePtr else _engine->create_node(path, plugin_type, library_name, plugin_label, polyphonic); - for (MetadataMap::const_iterator i = initial_data.begin(); i != initial_data.end(); ++i) + for (GraphObject::MetadataMap::const_iterator i = initial_data.begin(); i != initial_data.end(); ++i) _engine->set_metadata(path, i->first, i->second); return true; @@ -495,7 +495,7 @@ DeprecatedLoader::load_node(const Path& parent, xmlDocPtr doc, const xmlNodePtr // Not deprecated } else { _engine->create_node(path, plugin_uri, polyphonic); - for (MetadataMap::const_iterator i = initial_data.begin(); i != initial_data.end(); ++i) + for (GraphObject::MetadataMap::const_iterator i = initial_data.begin(); i != initial_data.end(); ++i) _engine->set_metadata(path, i->first, i->second); return true; } @@ -514,7 +514,7 @@ DeprecatedLoader::load_subpatch(const Path& parent, xmlDocPtr doc, const xmlNode string filename = ""; size_t poly = 0; - MetadataMap initial_data; + GraphObject::MetadataMap initial_data; while (cur != NULL) { key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); diff --git a/src/libs/client/DeprecatedLoader.hpp b/src/libs/client/DeprecatedLoader.hpp index 413c46b5..19dbf5cb 100644 --- a/src/libs/client/DeprecatedLoader.hpp +++ b/src/libs/client/DeprecatedLoader.hpp @@ -28,10 +28,12 @@ #include <raul/SharedPtr.hpp> #include <raul/Path.hpp> #include "interface/EngineInterface.hpp" +#include "interface/GraphObject.hpp" #include "ObjectModel.hpp" using std::string; using Ingen::Shared::EngineInterface; +using Ingen::Shared::GraphObject; namespace Ingen { namespace Client { @@ -60,14 +62,14 @@ public: string find_file(const string& filename, const string& additional_path = ""); - string load_patch(const Glib::ustring& filename, - boost::optional<Path> parent_path, - string name, - MetadataMap initial_data, - bool existing = false); + string load_patch(const Glib::ustring& filename, + boost::optional<Path> parent_path, + string name, + GraphObject::MetadataMap initial_data, + bool existing = false); private: - void add_metadata(MetadataMap& data, string key, string value); + void add_metadata(GraphObject::MetadataMap& data, string key, string value); string nameify_if_invalid(const string& name); string translate_load_path(const string& path); diff --git a/src/libs/client/NodeModel.hpp b/src/libs/client/NodeModel.hpp index fb88e2f0..080d8f4c 100644 --- a/src/libs/client/NodeModel.hpp +++ b/src/libs/client/NodeModel.hpp @@ -23,10 +23,11 @@ #include <string> #include <sigc++/sigc++.h> #include <raul/Table.hpp> -#include "ObjectModel.hpp" -#include "PortModel.hpp" #include <raul/Path.hpp> #include <raul/SharedPtr.hpp> +#include "interface/Node.hpp" +#include "ObjectModel.hpp" +#include "PortModel.hpp" #include "PluginModel.hpp" using std::string; @@ -43,7 +44,7 @@ class Store; * * \ingroup IngenClient */ -class NodeModel : public ObjectModel +class NodeModel : public ObjectModel, virtual public Ingen::Shared::Node { public: virtual ~NodeModel(); @@ -52,10 +53,10 @@ public: const Table<int,Table<int,string> >& get_programs() const { return _banks; } - const string& plugin_uri() const { return _plugin_uri; } - SharedPtr<PluginModel> plugin() const { return _plugin; } - int num_ports() const { return _ports.size(); } - const PortModelList& ports() const { return _ports; } + const string& plugin_uri() const { return _plugin_uri; } + SharedPtr<PluginModel> plugin() const { return _plugin; } + uint32_t num_ports() const { return _ports.size(); } + const PortModelList& ports() const { return _ports; } void port_value_range(SharedPtr<PortModel> port, float& min, float& max); diff --git a/src/libs/client/ObjectModel.hpp b/src/libs/client/ObjectModel.hpp index a9aff7d8..9ac3e686 100644 --- a/src/libs/client/ObjectModel.hpp +++ b/src/libs/client/ObjectModel.hpp @@ -29,16 +29,15 @@ #include <raul/Path.hpp> #include <raul/SharedPtr.hpp> #include <raul/Table.hpp> +#include "interface/GraphObject.hpp" -using std::string; using std::find; +using std::string; using Raul::Atom; using Raul::Path; namespace Ingen { namespace Client { -typedef Raul::Table<string, Atom> MetadataMap; - /** Base class for all GraphObject models (NodeModel, PatchModel, PortModel). * @@ -51,7 +50,7 @@ typedef Raul::Table<string, Atom> MetadataMap; * * \ingroup IngenClient */ -class ObjectModel : boost::noncopyable +class ObjectModel : virtual public Ingen::Shared::GraphObject, public boost::noncopyable { public: virtual ~ObjectModel(); @@ -64,7 +63,8 @@ public: const MetadataMap& metadata() const { return _metadata; } const Children& children() const { return _children; } - inline const Path& path() const { return _path; } + const Path path() const { return _path; } + const string name() const { return _path.name(); } SharedPtr<ObjectModel> parent() const { return _parent; } bool polyphonic() const { return _polyphonic; } diff --git a/src/libs/client/Serializer.cpp b/src/libs/client/Serializer.cpp index aaf9c955..e1b3805d 100644 --- a/src/libs/client/Serializer.cpp +++ b/src/libs/client/Serializer.cpp @@ -46,6 +46,7 @@ using namespace std; using namespace Raul; using namespace Raul::RDF; +using namespace Ingen::Shared; namespace Ingen { namespace Client { @@ -133,7 +134,7 @@ Serializer::finish() /** Convert a path to an RDF blank node ID for serializing. */ -Node +RDF::Node Serializer::path_to_node_id(const Path& path) { assert(_model); @@ -144,7 +145,7 @@ Serializer::path_to_node_id(const Path& path) ret[i] = '_'; } - return Node(Node::BLANK, ret); + return RDF::Node(Node::BLANK, ret); */ NodeMap::iterator i = _node_map.find(path); @@ -153,7 +154,7 @@ Serializer::path_to_node_id(const Path& path) assert(i->second.get_node()); return i->second; } else { - Node id = _world.blank_id(); + RDF::Node id = _world.blank_id(); assert(id); _node_map[path] = id; return id; @@ -241,14 +242,14 @@ Serializer::serialize(SharedPtr<ObjectModel> object) throw (std::logic_error) } -Node +RDF::Node Serializer::patch_path_to_rdf_id(const Path& path) { if (path == _root_object->path()) { - return Node(_model->world(), Node::RESOURCE, _base_uri); + return RDF::Node(_model->world(), RDF::Node::RESOURCE, _base_uri); } else { assert(path.length() > _root_object->path().length()); - return Node(_model->world(), Node::RESOURCE, + return RDF::Node(_model->world(), RDF::Node::RESOURCE, _base_uri + string("#") + path.substr(_root_object->path().length())); } } @@ -259,12 +260,12 @@ Serializer::serialize_patch(SharedPtr<PatchModel> patch) { assert(_model); - const Node patch_id = patch_path_to_rdf_id(patch->path()); + const RDF::Node patch_id = patch_path_to_rdf_id(patch->path()); _model->add_statement( patch_id, "rdf:type", - Node(_model->world(), Node::RESOURCE, "http://drobilla.net/ns/ingen#Patch")); + RDF::Node(_model->world(), RDF::Node::RESOURCE, "http://drobilla.net/ns/ingen#Patch")); if (patch->path().name().length() > 0) { _model->add_statement( @@ -282,7 +283,8 @@ Serializer::serialize_patch(SharedPtr<PatchModel> patch) "ingen:enabled", Atom(patch->enabled())); - for (MetadataMap::const_iterator m = patch->metadata().begin(); m != patch->metadata().end(); ++m) { + for (GraphObject::MetadataMap::const_iterator m = patch->metadata().begin(); + m != patch->metadata().end(); ++m) { if (m->first.find(":") != string::npos) { _model->add_statement( patch_id, @@ -298,14 +300,14 @@ Serializer::serialize_patch(SharedPtr<PatchModel> patch) _model->add_statement(patch_id, "ingen:node", patch_path_to_rdf_id(patch->path())); serialize_patch(patch); } else if (node) { - const Node node_id = path_to_node_id(n->second->path()); + const RDF::Node node_id = path_to_node_id(n->second->path()); _model->add_statement(patch_id, "ingen:node", node_id); serialize_node(node, node_id); } } for (PortModelList::const_iterator p = patch->ports().begin(); p != patch->ports().end(); ++p) { - const Node port_id = path_to_node_id((*p)->path()); + const RDF::Node port_id = path_to_node_id((*p)->path()); _model->add_statement(patch_id, "ingen:port", port_id); serialize_port(*p, port_id); } @@ -321,24 +323,25 @@ Serializer::serialize_plugin(SharedPtr<PluginModel> plugin) { assert(_model); - const Node plugin_id = Node(_model->world(), Node::RESOURCE, plugin->uri()); + const RDF::Node plugin_id = RDF::Node(_model->world(), RDF::Node::RESOURCE, plugin->uri()); _model->add_statement( plugin_id, "rdf:type", - Node(_model->world(), Node::RESOURCE, plugin->type_uri())); + RDF::Node(_model->world(), RDF::Node::RESOURCE, plugin->type_uri())); } void -Serializer::serialize_node(SharedPtr<NodeModel> node, const Node& node_id) +Serializer::serialize_node(SharedPtr<NodeModel> node, const RDF::Node& node_id) { - const Node plugin_id = Node(_model->world(), Node::RESOURCE, node->plugin()->uri()); + const RDF::Node plugin_id + = RDF::Node(_model->world(), RDF::Node::RESOURCE, node->plugin()->uri()); _model->add_statement( node_id, "rdf:type", - Node(_model->world(), Node::RESOURCE, "ingen:Node")); + RDF::Node(_model->world(), RDF::Node::RESOURCE, "ingen:Node")); _model->add_statement( node_id, @@ -363,12 +366,13 @@ Serializer::serialize_node(SharedPtr<NodeModel> node, const Node& node_id) Atom(node->path().name()));*/ for (PortModelList::const_iterator p = node->ports().begin(); p != node->ports().end(); ++p) { - const Node port_id = path_to_node_id((*p)->path()); + const RDF::Node port_id = path_to_node_id((*p)->path()); serialize_port(*p, port_id); _model->add_statement(node_id, "ingen:port", port_id); } - for (MetadataMap::const_iterator m = node->metadata().begin(); m != node->metadata().end(); ++m) { + for (GraphObject::MetadataMap::const_iterator m = node->metadata().begin(); + m != node->metadata().end(); ++m) { if (m->first.find(":") != string::npos) { _model->add_statement( node_id, @@ -383,14 +387,14 @@ Serializer::serialize_node(SharedPtr<NodeModel> node, const Node& node_id) * Audio output ports with no metadata will not be written, for example. */ void -Serializer::serialize_port(SharedPtr<PortModel> port, const Node& port_id) +Serializer::serialize_port(SharedPtr<PortModel> port, const RDF::Node& port_id) { if (port->is_input()) _model->add_statement(port_id, "rdf:type", - Node(_model->world(), Node::RESOURCE, "ingen:InputPort")); + RDF::Node(_model->world(), RDF::Node::RESOURCE, "ingen:InputPort")); else _model->add_statement(port_id, "rdf:type", - Node(_model->world(), Node::RESOURCE, "ingen:OutputPort")); + RDF::Node(_model->world(), RDF::Node::RESOURCE, "ingen:OutputPort")); _model->add_statement(port_id, "ingen:name", Atom(port->path().name().c_str())); @@ -400,7 +404,8 @@ Serializer::serialize_port(SharedPtr<PortModel> port, const Node& port_id) _model->add_statement(port_id, "ingen:value", Atom(port->value())); if (port->metadata().size() > 0) { - for (MetadataMap::const_iterator m = port->metadata().begin(); m != port->metadata().end(); ++m) { + for (GraphObject::MetadataMap::const_iterator m = port->metadata().begin(); + m != port->metadata().end(); ++m) { if (m->first.find(":") != string::npos) { _model->add_statement( port_id, @@ -418,8 +423,8 @@ Serializer::serialize_connection(SharedPtr<ConnectionModel> connection) throw (s if (!_model) throw std::logic_error("serialize_connection called without serialization in progress"); - const Node src_node = path_to_node_id(connection->src_port_path()); - const Node dst_node = path_to_node_id(connection->dst_port_path()); + const RDF::Node src_node = path_to_node_id(connection->src_port_path()); + const RDF::Node dst_node = path_to_node_id(connection->dst_port_path()); _model->add_statement(dst_node, "ingen:connectedTo", src_node); } |