From 40ff85e256ca9094fb75cdcbabd3442339f91ecd Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 2 May 2007 23:58:28 +0000 Subject: Added svn:ignore property to everything. Made engine and patch loader separate dynamically loaded modules. No more monolithic ingenuity (module loaded at runtime). git-svn-id: http://svn.drobilla.net/lad/ingen@491 a436a847-0d15-0410-975c-d299462d15a1 --- src/libs/Makefile.am | 2 +- src/libs/client/ConnectionModel.h | 4 +- src/libs/client/ControlModel.h | 2 +- src/libs/client/DeprecatedLoader.cpp | 46 ++-- src/libs/client/DeprecatedLoader.h | 11 +- src/libs/client/Loader.cpp | 342 ------------------------- src/libs/client/Loader.h | 49 ---- src/libs/client/Makefile.am | 13 +- src/libs/client/ModelEngineInterface.cpp | 99 ------- src/libs/client/ModelEngineInterface.h | 72 ------ src/libs/client/NodeModel.h | 4 +- src/libs/client/OSCClientReceiver.cpp | 2 +- src/libs/client/OSCEngineSender.cpp | 2 +- src/libs/client/OSCModelEngineInterface.h | 42 --- src/libs/client/ObjectModel.h | 6 +- src/libs/client/PatchModel.h | 2 +- src/libs/client/PluginModel.h | 4 +- src/libs/client/PortModel.h | 4 +- src/libs/client/Serializer.cpp | 2 +- src/libs/client/Serializer.h | 1 - src/libs/client/Store.h | 6 +- src/libs/client/ThreadedSigClientInterface.h | 4 +- src/libs/engine/ClientBroadcaster.h | 2 +- src/libs/engine/DirectResponder.h | 2 +- src/libs/engine/Driver.h | 2 +- src/libs/engine/Engine.cpp | 33 ++- src/libs/engine/Engine.h | 18 +- src/libs/engine/Event.h | 2 +- src/libs/engine/GraphObject.h | 4 +- src/libs/engine/Makefile.am | 24 +- src/libs/engine/OSCClientSender.cpp | 2 +- src/libs/engine/OSCEngineReceiver.cpp | 16 +- src/libs/engine/OSCEngineReceiver.h | 4 +- src/libs/engine/ObjectStore.h | 2 +- src/libs/engine/PostProcessor.h | 4 +- src/libs/engine/QueuedEngineInterface.cpp | 66 ++--- src/libs/engine/QueuedEngineInterface.h | 6 +- src/libs/engine/QueuedEventSource.h | 6 +- src/libs/engine/Responder.h | 2 +- src/libs/engine/ThreadManager.h | 2 +- src/libs/engine/engine.cpp | 42 +++ src/libs/engine/engine.h | 38 +++ src/libs/engine/events/AddNodeEvent.cpp | 4 +- src/libs/engine/events/AddNodeEvent.h | 2 +- src/libs/engine/events/AddPortEvent.cpp | 4 +- src/libs/engine/events/ConnectionEvent.h | 2 +- src/libs/engine/events/CreatePatchEvent.cpp | 2 +- src/libs/engine/events/DestroyEvent.cpp | 2 +- src/libs/engine/events/DisconnectNodeEvent.cpp | 2 +- src/libs/engine/events/DisconnectPortEvent.h | 2 +- src/libs/engine/events/RenameEvent.cpp | 2 +- src/libs/engine/events/RequestMetadataEvent.h | 2 +- src/libs/engine/events/SetMetadataEvent.h | 2 +- src/libs/module/Makefile.am | 9 + src/libs/module/Module.cpp | 80 ++++++ src/libs/module/Module.h | 39 +++ src/libs/serialisation/Loader.cpp | 342 +++++++++++++++++++++++++ src/libs/serialisation/Loader.h | 56 ++++ src/libs/serialisation/Makefile.am | 16 ++ src/libs/serialisation/serialisation.cpp | 34 +++ src/libs/serialisation/serialisation.h | 38 +++ 61 files changed, 879 insertions(+), 757 deletions(-) delete mode 100644 src/libs/client/Loader.cpp delete mode 100644 src/libs/client/Loader.h delete mode 100644 src/libs/client/ModelEngineInterface.cpp delete mode 100644 src/libs/client/ModelEngineInterface.h delete mode 100644 src/libs/client/OSCModelEngineInterface.h create mode 100644 src/libs/engine/engine.cpp create mode 100644 src/libs/engine/engine.h create mode 100644 src/libs/module/Makefile.am create mode 100644 src/libs/module/Module.cpp create mode 100644 src/libs/module/Module.h create mode 100644 src/libs/serialisation/Loader.cpp create mode 100644 src/libs/serialisation/Loader.h create mode 100644 src/libs/serialisation/Makefile.am create mode 100644 src/libs/serialisation/serialisation.cpp create mode 100644 src/libs/serialisation/serialisation.h (limited to 'src/libs') diff --git a/src/libs/Makefile.am b/src/libs/Makefile.am index b509598e..81422435 100644 --- a/src/libs/Makefile.am +++ b/src/libs/Makefile.am @@ -1,2 +1,2 @@ -SUBDIRS = engine client +SUBDIRS = module engine serialisation client diff --git a/src/libs/client/ConnectionModel.h b/src/libs/client/ConnectionModel.h index 7024d058..9e62d5b4 100644 --- a/src/libs/client/ConnectionModel.h +++ b/src/libs/client/ConnectionModel.h @@ -19,8 +19,8 @@ #define CONNECTIONMODEL_H #include -#include "raul/Path.h" -#include "raul/SharedPtr.h" +#include +#include #include "PortModel.h" #include using std::string; diff --git a/src/libs/client/ControlModel.h b/src/libs/client/ControlModel.h index dc709944..5729faec 100644 --- a/src/libs/client/ControlModel.h +++ b/src/libs/client/ControlModel.h @@ -19,7 +19,7 @@ #define CONTROLMODEL_H #include -#include "raul/Path.h" +#include namespace Ingen { namespace Client { diff --git a/src/libs/client/DeprecatedLoader.cpp b/src/libs/client/DeprecatedLoader.cpp index 97e6583d..d4b650df 100644 --- a/src/libs/client/DeprecatedLoader.cpp +++ b/src/libs/client/DeprecatedLoader.cpp @@ -15,28 +15,29 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "DeprecatedLoader.h" -#include -#include -#include -#include -#include "PatchModel.h" -#include "NodeModel.h" -#include "ConnectionModel.h" -#include "PortModel.h" -#include "PresetModel.h" -#include "ModelEngineInterface.h" -#include "PluginModel.h" -#include "raul/Path.h" + #include #include #include +#include #include // for pair, make_pair #include #include #include #include // for atof #include +#include +#include +#include +#include +#include "interface/EngineInterface.h" +#include "PatchModel.h" +#include "NodeModel.h" +#include "ConnectionModel.h" +#include "PortModel.h" +#include "PresetModel.h" +#include "PluginModel.h" +#include "DeprecatedLoader.h" using std::string; using std::vector; using std::pair; using std::cerr; using std::cout; using std::endl; @@ -245,8 +246,11 @@ DeprecatedLoader::load_patch(const Glib::ustring& filename, poly = 1; // Create it, if we're not merging - if (!existing) - _engine->create_patch_with_data(path, poly, initial_data); + if (!existing) { + _engine->create_patch(path, poly); + for (MetadataMap::const_iterator i = initial_data.begin(); i != initial_data.end(); ++i) + _engine->set_metadata(path, i->first, i->second); + } // Load nodes cur = xmlDocGetRootElement(doc)->xmlChildrenNode; @@ -294,7 +298,8 @@ DeprecatedLoader::load_patch(const Glib::ustring& filename, xmlCleanupParser(); // Done above.. late enough? - //_engine->set_metadata_map(path, initial_data); + //for (MetadataMap::const_iterator i = data.begin(); i != data.end(); ++i) + // _engine->set_metadata(subject, i->first, i->second); if (!existing) _engine->enable_patch(path); @@ -485,7 +490,8 @@ DeprecatedLoader::load_node(const Path& parent, xmlDocPtr doc, const xmlNodePtr path = new_path; - _engine->set_metadata_map(path, initial_data); + for (MetadataMap::const_iterator i = initial_data.begin(); i != initial_data.end(); ++i) + _engine->set_metadata(path, i->first, i->second); return SharedPtr(); @@ -508,7 +514,8 @@ DeprecatedLoader::load_node(const Path& parent, xmlDocPtr doc, const xmlNodePtr else _engine->create_node(path, plugin_type, library_name, plugin_label, polyphonic); - _engine->set_metadata_map(path, initial_data); + for (MetadataMap::const_iterator i = initial_data.begin(); i != initial_data.end(); ++i) + _engine->set_metadata(path, i->first, i->second); return true; } @@ -516,7 +523,8 @@ DeprecatedLoader::load_node(const Path& parent, xmlDocPtr doc, const xmlNodePtr // Not deprecated } else { _engine->create_node(path, plugin_uri, polyphonic); - _engine->set_metadata_map(path, initial_data); + for (MetadataMap::const_iterator i = initial_data.begin(); i != initial_data.end(); ++i) + _engine->set_metadata(path, i->first, i->second); return true; } diff --git a/src/libs/client/DeprecatedLoader.h b/src/libs/client/DeprecatedLoader.h index aa9557f5..dde9f631 100644 --- a/src/libs/client/DeprecatedLoader.h +++ b/src/libs/client/DeprecatedLoader.h @@ -25,11 +25,13 @@ #include #include #include -#include "raul/SharedPtr.h" -#include "raul/Path.h" +#include +#include +#include "interface/EngineInterface.h" #include "ObjectModel.h" using std::string; +using Ingen::Shared::EngineInterface; namespace Ingen { namespace Client { @@ -38,7 +40,6 @@ class PatchModel; class NodeModel; class ConnectionModel; class PresetModel; -class ModelEngineInterface; /** Loads deprecated (XML) patch files (from the Om days). @@ -48,7 +49,7 @@ class ModelEngineInterface; class DeprecatedLoader { public: - DeprecatedLoader(SharedPtr engine) + DeprecatedLoader(SharedPtr engine) : /*_patch_search_path(".")*/ _engine(engine) { assert(_engine); @@ -72,7 +73,7 @@ private: string translate_load_path(const string& path); //string _patch_search_path; - SharedPtr _engine; + SharedPtr _engine; /// Translations of paths from the loading file to actual paths (for deprecated patches) std::map _load_path_translations; diff --git a/src/libs/client/Loader.cpp b/src/libs/client/Loader.cpp deleted file mode 100644 index 8ebea580..00000000 --- a/src/libs/client/Loader.cpp +++ /dev/null @@ -1,342 +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 - */ - -#include -#include -#include -#include -#include "Loader.h" -#include "interface/EngineInterface.h" - -using namespace std; -using namespace Raul; -using namespace Ingen::Shared; - -namespace Ingen { -namespace Serialisation { - - -/** Load (create) a patch from RDF into the engine. - * - * @param document_uri URI of file to load objects from. - * @param parent Path of parent under which to load objects. - * @return whether or not load was successful. - */ -bool -load(SharedPtr engine, - Raul::RDF::World* rdf_world, - const Glib::ustring& document_uri, - boost::optional parent, - string patch_name, - Glib::ustring patch_uri, - map data) -{ - // FIXME: this whole thing is a mess - - std::map created; - - RDF::Model model(*rdf_world, document_uri); - - //patch_uri = string("<") + patch_uri + ">"; - patch_uri = string("<") + document_uri + ">"; - - cerr << "[Loader] Loading " << patch_uri << " from " << document_uri - << " under " << (string)(parent ? (string)parent.get() : "no parent") << endl; - - /* Get polyphony (mandatory) */ - - // FIXME: polyphony datatype - RDF::Query query(*rdf_world, Glib::ustring( - "SELECT DISTINCT ?poly WHERE {\n") + - patch_uri + " ingen:polyphony ?poly\n }"); - - RDF::Query::Results results = query.run(*rdf_world, model); - - if (results.size() == 0) { - cerr << "[Loader] ERROR: No polyphony found!" << endl; - return false; - } - - RDF::Node poly_node = (*results.begin())["poly"]; - assert(poly_node.is_int()); - size_t patch_poly = (size_t)poly_node.to_int(); - - /* Get name (if available/necessary) */ - - if (patch_name == "") { - patch_name = string(document_uri.substr(document_uri.find_last_of("/")+1)); - if (patch_name.substr(patch_name.length()-10) == ".ingen.ttl") - patch_name = patch_name.substr(0, patch_name.length()-10); - - query = RDF::Query(*rdf_world, Glib::ustring( - "SELECT DISTINCT ?name WHERE {\n") + - patch_uri + " ingen:name ?name\n}"); - - results = query.run(*rdf_world, model); - - if (results.size() > 0) - patch_name = (*results.begin())["name"].to_string(); - } - - Path patch_path = ( parent ? (parent.get().base() + patch_name) : Path("/") ); - cerr << "************ PATCH: name=" << patch_name << ", path=" << patch_path - << ", poly = " << patch_poly << endl; - engine->create_patch(patch_path, patch_poly); - - - /* Load (plugin) nodes */ - - query = RDF::Query(*rdf_world, Glib::ustring( - "SELECT DISTINCT ?name ?plugin ?floatkey ?floatval WHERE {\n") + - patch_uri + " ingen:node ?node .\n" - "?node ingen:name ?name ;\n" - " ingen:plugin ?plugin .\n" - "OPTIONAL { ?node ?floatkey ?floatval . \n" - " FILTER ( datatype(?floatval) = xsd:decimal ) }\n" - "}"); - - results = query.run(*rdf_world, model); - - for (RDF::Query::Results::iterator i = results.begin(); i != results.end(); ++i) { - - string name = (*i)["name"].to_string(); - string plugin = (*i)["plugin"].to_string(); - - const Path node_path = patch_path.base() + (string)name; - - if (created.find(node_path) == created.end()) { - engine->create_node(node_path, plugin, false); - created[node_path] = true; - } - - string floatkey = rdf_world->prefixes().qualify((*i)["floatkey"].to_string()); - RDF::Node val_node = (*i)["floatval"]; - - if (floatkey != "" && val_node.is_float()) - engine->set_metadata(patch_path.base() + name, floatkey, Atom(val_node.to_float())); - } - - - /* Load subpatches */ - - query = RDF::Query(*rdf_world, Glib::ustring( - "SELECT DISTINCT ?patch ?name WHERE {\n") + - patch_uri + " ingen:node ?patch .\n" - "?patch a ingen:Patch ;\n" - " ingen:name ?name .\n" - "}"); - - results = query.run(*rdf_world, model); - - for (RDF::Query::Results::iterator i = results.begin(); i != results.end(); ++i) { - - string name = (*i)["name"].to_string(); - string patch = (*i)["patch"].to_string(); - - const Path subpatch_path = patch_path.base() + (string)name; - - if (created.find(subpatch_path) == created.end()) { - load(engine, rdf_world, document_uri, patch_path, name, patch); - created[subpatch_path] = true; - } - } - - created.clear(); - - - /* Set node port control values */ - - query = RDF::Query(*rdf_world, Glib::ustring( - "SELECT DISTINCT ?nodename ?portname ?portval WHERE {\n") + - patch_uri + " ingen:node ?node .\n" - "?node ingen:name ?nodename ;\n" - " ingen:port ?port .\n" - "?port ingen:name ?portname ;\n" - " ingen:value ?portval .\n" - "FILTER ( datatype(?portval) = xsd:decimal )\n" - "}\n"); - - results = query.run(*rdf_world, model); - - for (RDF::Query::Results::iterator i = results.begin(); i != results.end(); ++i) { - - string node_name = (*i)["nodename"].to_string(); - string port_name = (*i)["portname"].to_string(); - const float val = (*i)["portval"].to_float(); - - Path port_path = patch_path.base() + (const string&)node_name +"/"+ (const string&)port_name; - - engine->set_port_value(port_path, val); - } - - - /* Load this patch's ports */ - - query = RDF::Query(*rdf_world, Glib::ustring( - "SELECT DISTINCT ?port ?type ?name ?datatype ?floatkey ?floatval ?portval WHERE {\n") + - patch_uri + " ingen:port ?port .\n" - "?port a ?type ;\n" - " ingen:name ?name ;\n" - " ingen:dataType ?datatype .\n" - "OPTIONAL { ?port ?floatkey ?floatval . \n" - " FILTER ( datatype(?floatval) = xsd:decimal ) }\n" - "OPTIONAL { ?port ingen:value ?portval . \n" - " FILTER ( datatype(?portval) = xsd:decimal ) }\n" - "}"); - - results = query.run(*rdf_world, model); - - for (RDF::Query::Results::iterator i = results.begin(); i != results.end(); ++i) { - string name = (*i)["name"].to_string(); - string type = rdf_world->qualify((*i)["type"].to_string()); - string datatype = (*i)["datatype"].to_string(); - - const Path port_path = patch_path.base() + (string)name; - - if (created.find(port_path) == created.end()) { - //cerr << "TYPE: " << type << endl; - bool is_output = (type == "ingen:OutputPort"); // FIXME: check validity - engine->create_port(port_path, datatype, is_output); - created[port_path] = true; - } - - RDF::Node val_node = (*i)["portval"]; - if (val_node.is_float()) - engine->set_port_value(patch_path.base() + name, val_node.to_float()); - - string floatkey = rdf_world->qualify((*i)["floatkey"].to_string()); - val_node = (*i)["floatval"]; - - if (floatkey != "" && val_node.is_float()) - engine->set_metadata(patch_path.base() + name, floatkey, Atom(val_node.to_float())); - } - - created.clear(); - - - /* Node -> Node connections */ - - query = RDF::Query(*rdf_world, Glib::ustring( - "SELECT DISTINCT ?srcnodename ?srcname ?dstnodename ?dstname WHERE {\n") + - patch_uri + "ingen:node ?srcnode ;\n" - " ingen:node ?dstnode .\n" - "?srcnode ingen:port ?src ;\n" - " ingen:name ?srcnodename .\n" - "?dstnode ingen:port ?dst ;\n" - " ingen:name ?dstnodename .\n" - "?src ingen:name ?srcname .\n" - "?dst ingen:connectedTo ?src ;\n" - " ingen:name ?dstname .\n" - "}\n"); - - results = query.run(*rdf_world, model); - - for (RDF::Query::Results::iterator i = results.begin(); i != results.end(); ++i) { - Path src_node = patch_path.base() + (*i)["srcnodename"].to_string(); - Path src_port = src_node.base() + (*i)["srcname"].to_string(); - Path dst_node = patch_path.base() + (*i)["dstnodename"].to_string(); - Path dst_port = dst_node.base() + (*i)["dstname"].to_string(); - - cerr << patch_path << " 1 CONNECTION: " << src_port << " -> " << dst_port << endl; - - engine->connect(src_port, dst_port); - } - - - /* This Patch -> Node connections */ - - query = RDF::Query(*rdf_world, Glib::ustring( - "SELECT DISTINCT ?srcname ?dstnodename ?dstname WHERE {\n") + - patch_uri + " ingen:port ?src ;\n" - " ingen:node ?dstnode .\n" - "?dstnode ingen:port ?dst ;\n" - " ingen:name ?dstnodename .\n" - "?dst ingen:connectedTo ?src ;\n" - " ingen:name ?dstname .\n" - "?src ingen:name ?srcname .\n" - "}\n"); - - results = query.run(*rdf_world, model); - - for (RDF::Query::Results::iterator i = results.begin(); i != results.end(); ++i) { - Path src_port = patch_path.base() + (*i)["srcname"].to_string(); - Path dst_node = patch_path.base() + (*i)["dstnodename"].to_string(); - Path dst_port = dst_node.base() + (*i)["dstname"].to_string(); - - cerr << patch_path << " 2 CONNECTION: " << src_port << " -> " << dst_port << endl; - - engine->connect(src_port, dst_port); - } - - - /* Node -> This Patch connections */ - - query = RDF::Query(*rdf_world, Glib::ustring( - "SELECT DISTINCT ?srcnodename ?srcname ?dstname WHERE {\n") + - patch_uri + " ingen:port ?dst ;\n" - " ingen:node ?srcnode .\n" - "?srcnode ingen:port ?src ;\n" - " ingen:name ?srcnodename .\n" - "?dst ingen:connectedTo ?src ;\n" - " ingen:name ?dstname .\n" - "?src ingen:name ?srcname .\n" - "}\n"); - - results = query.run(*rdf_world, model); - - for (RDF::Query::Results::iterator i = results.begin(); i != results.end(); ++i) { - Path dst_port = patch_path.base() + (*i)["dstname"].to_string(); - Path src_node = patch_path.base() + (*i)["srcnodename"].to_string(); - Path src_port = src_node.base() + (*i)["srcname"].to_string(); - - cerr << patch_path << " 3 CONNECTION: " << src_port << " -> " << dst_port << endl; - - engine->connect(src_port, dst_port); - } - - - /* Load metadata */ - - query = RDF::Query(*rdf_world, Glib::ustring( - "SELECT DISTINCT ?floatkey ?floatval WHERE {\n") + - patch_uri + " ?floatkey ?floatval . \n" - " FILTER ( datatype(?floatval) = xsd:decimal ) \n" - "}"); - - results = query.run(*rdf_world, model); - - for (RDF::Query::Results::iterator i = results.begin(); i != results.end(); ++i) { - - string floatkey = rdf_world->prefixes().qualify((*i)["floatkey"].to_string()); - RDF::Node val_node = (*i)["floatval"]; - - if (floatkey != "" && val_node.is_float()) - engine->set_metadata(patch_path, floatkey, Atom(val_node.to_float())); - } - - - // Set passed metadata last to override any loaded values - for (Metadata::const_iterator i = data.begin(); i != data.end(); ++i) - engine->set_metadata(patch_path, i->first, i->second); - - return true; -} - - -} // namespace Serialisation -} // namespace Ingen - diff --git a/src/libs/client/Loader.h b/src/libs/client/Loader.h deleted file mode 100644 index 74aa7cbb..00000000 --- a/src/libs/client/Loader.h +++ /dev/null @@ -1,49 +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 LOADER_H -#define LOADER_H - -#include -#include -#include -#include -#include -#include - -namespace Raul { class Atom; namespace RDF { class World; } } -namespace Ingen { namespace Shared { class EngineInterface; } } - -namespace Ingen { -namespace Serialisation { - -typedef std::map Metadata; - -bool -load(SharedPtr engine, - Raul::RDF::World* world, - const Glib::ustring& uri, - boost::optional parent, - std::string patch_name, - Glib::ustring patch_uri = "", - Metadata data = Metadata()); - - -} // namespace Serialisation -} // namespace Ingen - -#endif // LOADER_H diff --git a/src/libs/client/Makefile.am b/src/libs/client/Makefile.am index b226c381..1a0aa61d 100644 --- a/src/libs/client/Makefile.am +++ b/src/libs/client/Makefile.am @@ -1,23 +1,20 @@ if BUILD_CLIENT_LIB -noinst_LTLIBRARIES = libingenclient.la +noinst_LTLIBRARIES = libingen_client.la -libingenclient_la_CXXFLAGS = @RAUL_CFLAGS@ @SLV2_CFLAGS@ @LXML2_CFLAGS@ @RASQAL_CFLAGS@ @RAPTOR_CFLAGS@ @LSIGCPP_CFLAGS@ @GLIBMM_CFLAGS@ -I$(top_srcdir)/src/common -DPKGDATADIR=\"$(pkgdatadir)\" +libingen_client_la_CXXFLAGS = @RAUL_CFLAGS@ @SLV2_CFLAGS@ @LXML2_CFLAGS@ @RASQAL_CFLAGS@ @RAPTOR_CFLAGS@ @LSIGCPP_CFLAGS@ @GLIBMM_CFLAGS@ -I$(top_srcdir)/src/common -DPKGDATADIR=\"$(pkgdatadir)\" -libingenclient_la_LIBADD = @RAUL_LIBS@ @SLV2_LIBS@ @LXML2_LIBS@ @LOSC_LIBS@ @RASQAL_LIBS@ @RAPTOR_LIBS@ @LSIGCPP_LIBS@ @GLIBMM_LIBS@ +libingen_client_la_LIBADD = @RAUL_LIBS@ @SLV2_LIBS@ @LXML2_LIBS@ @LOSC_LIBS@ @RASQAL_LIBS@ @RAPTOR_LIBS@ @LSIGCPP_LIBS@ @GLIBMM_LIBS@ -libingenclient_la_SOURCES = \ +libingen_client_la_SOURCES = \ OSCEngineSender.h \ OSCEngineSender.cpp \ - OSCModelEngineInterface.h \ OSCClientReceiver.h \ OSCClientReceiver.cpp \ SigClientInterface.h \ DirectSigClientInterface.h \ ThreadedSigClientInterface.h \ ThreadedSigClientInterface.cpp \ - ModelEngineInterface.h \ - ModelEngineInterface.cpp \ PresetModel.h \ ControlModel.h \ ObjectModel.h \ @@ -31,8 +28,6 @@ libingenclient_la_SOURCES = \ PluginModel.cpp \ Serializer.h \ Serializer.cpp \ - Loader.h \ - Loader.cpp \ DeprecatedLoader.h \ DeprecatedLoader.cpp \ ConnectionModel.h \ diff --git a/src/libs/client/ModelEngineInterface.cpp b/src/libs/client/ModelEngineInterface.cpp deleted file mode 100644 index 9401a937..00000000 --- a/src/libs/client/ModelEngineInterface.cpp +++ /dev/null @@ -1,99 +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 - */ - -#include "ModelEngineInterface.h" -#include "PatchModel.h" -#include "PresetModel.h" - -namespace Ingen { -namespace Client { - - -/** Load a node. - */ -void -ModelEngineInterface::create_node_with_data(const string& plugin_uri, - const Path& path, - bool is_polyphonic, - const MetadataMap& initial_data) -{ - // Load by URI - if (plugin_uri.length() > 0) { - create_node(path, plugin_uri, is_polyphonic); - - // Load by libname, label - } else { - cerr << "FIXME: non-uri" << endl; - #if 0 - //assert(nm->plugin()->lib_name().length() > 0); - assert(nm->plugin()->plug_label().length() > 0); - - create_node(nm->path(), - nm->plugin()->type_string(), - nm->plugin()->lib_name().c_str(), - nm->plugin()->plug_label().c_str(), - nm->polyphonic()); - #endif - } - - set_metadata_map(path, initial_data); -} - - -/** Create a patch. - */ -void -ModelEngineInterface::create_patch_with_data(const Path& path, size_t poly, const MetadataMap& data) -{ - create_patch(path, poly); - set_metadata_map(path, data); -} - - -void -ModelEngineInterface::create_port_with_data(const Path& path, - const string& data_type, - bool direction, - const MetadataMap& data) -{ - create_port(path, data_type, direction); - set_metadata_map(path, data); -} - -/** Set all pieces of metadata in a map. - */ -void -ModelEngineInterface::set_metadata_map(const Path& subject, const MetadataMap& data) -{ - for (MetadataMap::const_iterator i = data.begin(); i != data.end(); ++i) - set_metadata(subject, i->first, i->second); -} - - -/** Set a preset by setting all relevant controls for a patch. - */ -void -ModelEngineInterface::set_preset(const Path& patch_path, const PresetModel* const pm) -{ - for (list::const_iterator i = pm->controls().begin(); i != pm->controls().end(); ++i) { - set_port_value_queued((*i).port_path(), (*i).value()); - } -} - - -} // namespace Client -} // namespace Ingen diff --git a/src/libs/client/ModelEngineInterface.h b/src/libs/client/ModelEngineInterface.h deleted file mode 100644 index d93d6564..00000000 --- a/src/libs/client/ModelEngineInterface.h +++ /dev/null @@ -1,72 +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 MODELENGINEINTERFACE_H -#define MODELENGINEINTERFACE_H - -#include -#include -#include "interface/EngineInterface.h" -#include "ObjectModel.h" -using std::string; - -class Path; - -/** \defgroup IngenClient Client Library */ -namespace Ingen { -namespace Client { - -class ObjectModel; -class NodeModel; -class PresetModel; -class PatchModel; - - -/** Model-based engine command interface. - * - * \ingroup IngenClient - */ -class ModelEngineInterface : public virtual Shared::EngineInterface -{ -public: - virtual ~ModelEngineInterface() {} - - virtual void create_patch_with_data(const Path& path, - size_t poly, - const MetadataMap& initial_data); - - virtual void create_node_with_data(const string& plugin_uri, - const Path& path, - bool is_polyphonicc, - const MetadataMap& initial_data); - - virtual void create_port_with_data(const Path& path, - const string& data_type, - bool direction, - const MetadataMap& data); - - virtual void set_metadata_map(const Path& subject, const MetadataMap& data); - virtual void set_preset(const Path& patch_path, const PresetModel* pm); - -protected: - ModelEngineInterface() {} -}; - -} // namespace Client -} // namespace Ingen - -#endif // MODELENGINEINTERFACE_H diff --git a/src/libs/client/NodeModel.h b/src/libs/client/NodeModel.h index 2dd96f35..f8866f15 100644 --- a/src/libs/client/NodeModel.h +++ b/src/libs/client/NodeModel.h @@ -25,8 +25,8 @@ #include #include "ObjectModel.h" #include "PortModel.h" -#include "raul/Path.h" -#include "raul/SharedPtr.h" +#include +#include #include "PluginModel.h" using std::string; using std::map; using std::find; diff --git a/src/libs/client/OSCClientReceiver.cpp b/src/libs/client/OSCClientReceiver.cpp index 7545b141..d56b8f2e 100644 --- a/src/libs/client/OSCClientReceiver.cpp +++ b/src/libs/client/OSCClientReceiver.cpp @@ -16,7 +16,7 @@ */ #include "OSCClientReceiver.h" -#include "raul/AtomLiblo.h" +#include #include #include #include diff --git a/src/libs/client/OSCEngineSender.cpp b/src/libs/client/OSCEngineSender.cpp index 11bbc3d7..6ebf8df0 100644 --- a/src/libs/client/OSCEngineSender.cpp +++ b/src/libs/client/OSCEngineSender.cpp @@ -18,7 +18,7 @@ #include #include "OSCEngineSender.h" #include "interface/ClientKey.h" -#include "raul/AtomLiblo.h" +#include using std::cout; using std::cerr; using std::endl; namespace Ingen { diff --git a/src/libs/client/OSCModelEngineInterface.h b/src/libs/client/OSCModelEngineInterface.h deleted file mode 100644 index a4a19c95..00000000 --- a/src/libs/client/OSCModelEngineInterface.h +++ /dev/null @@ -1,42 +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 OSCMODELENGINEINTERFACE_H -#define OSCMODELENGINEINTERFACE_H - -#include -#include "OSCEngineSender.h" -#include "ModelEngineInterface.h" - -using std::string; - -/** \defgroup IngenClient Client Library */ -namespace Ingen { -namespace Client { - - -class OSCModelEngineInterface : public OSCEngineSender, public ModelEngineInterface -{ -public: - OSCModelEngineInterface(const string& engine_url) : OSCEngineSender(engine_url) {} -}; - - -} // namespace Client -} // namespace Ingen - -#endif // OSCMODELENGINEINTERFACE_H diff --git a/src/libs/client/ObjectModel.h b/src/libs/client/ObjectModel.h index 882ff911..d388475a 100644 --- a/src/libs/client/ObjectModel.h +++ b/src/libs/client/ObjectModel.h @@ -26,9 +26,9 @@ #include #include #include -#include "raul/Atom.h" -#include "raul/Path.h" -#include "raul/SharedPtr.h" +#include +#include +#include using std::string; using std::map; using std::find; using std::cout; using std::cerr; using std::endl; diff --git a/src/libs/client/PatchModel.h b/src/libs/client/PatchModel.h index c55bce89..faceef72 100644 --- a/src/libs/client/PatchModel.h +++ b/src/libs/client/PatchModel.h @@ -24,7 +24,7 @@ #include #include #include "NodeModel.h" -#include "raul/SharedPtr.h" +#include #include "ConnectionModel.h" using std::list; using std::string; using std::map; diff --git a/src/libs/client/PluginModel.h b/src/libs/client/PluginModel.h index aba4d1cf..20777bd9 100644 --- a/src/libs/client/PluginModel.h +++ b/src/libs/client/PluginModel.h @@ -21,8 +21,8 @@ #include "../../../config.h" #include #include -#include "raul/Path.h" -#include "raul/SharedPtr.h" +#include +#include #ifdef HAVE_SLV2 #include #endif diff --git a/src/libs/client/PortModel.h b/src/libs/client/PortModel.h index 15a381d4..139e2a97 100644 --- a/src/libs/client/PortModel.h +++ b/src/libs/client/PortModel.h @@ -24,8 +24,8 @@ #include #include #include "ObjectModel.h" -#include "raul/SharedPtr.h" -#include "raul/Path.h" +#include +#include using std::string; using std::list; using std::cerr; using std::endl; namespace Ingen { diff --git a/src/libs/client/Serializer.cpp b/src/libs/client/Serializer.cpp index 85a13331..4a746ae1 100644 --- a/src/libs/client/Serializer.cpp +++ b/src/libs/client/Serializer.cpp @@ -33,13 +33,13 @@ #include #include #include +#include "interface/EngineInterface.h" #include "Serializer.h" #include "PatchModel.h" #include "NodeModel.h" #include "ConnectionModel.h" #include "PortModel.h" #include "PresetModel.h" -#include "ModelEngineInterface.h" #include "PluginModel.h" using namespace std; diff --git a/src/libs/client/Serializer.h b/src/libs/client/Serializer.h index ad91afac..ee7d3dff 100644 --- a/src/libs/client/Serializer.h +++ b/src/libs/client/Serializer.h @@ -39,7 +39,6 @@ class NodeModel; class PortModel; class ConnectionModel; class PresetModel; -class ModelEngineInterface; /** Serializes Ingen objects (patches, nodes, etc) to RDF. diff --git a/src/libs/client/Store.h b/src/libs/client/Store.h index 2059f55f..e481fc2d 100644 --- a/src/libs/client/Store.h +++ b/src/libs/client/Store.h @@ -22,10 +22,10 @@ #include #include #include -#include "raul/SharedPtr.h" +#include #include -#include "raul/Path.h" -#include "raul/Atom.h" +#include +#include #include "interface/EngineInterface.h" using std::string; using std::map; using std::list; using Ingen::Shared::EngineInterface; diff --git a/src/libs/client/ThreadedSigClientInterface.h b/src/libs/client/ThreadedSigClientInterface.h index c0b1ce73..d0cb4e89 100644 --- a/src/libs/client/ThreadedSigClientInterface.h +++ b/src/libs/client/ThreadedSigClientInterface.h @@ -23,8 +23,8 @@ #include #include "interface/ClientInterface.h" #include "SigClientInterface.h" -#include "raul/SRSWQueue.h" -#include "raul/Atom.h" +#include +#include using std::string; /** Returns nothing and takes no parameters (because they have all been bound) */ diff --git a/src/libs/engine/ClientBroadcaster.h b/src/libs/engine/ClientBroadcaster.h index 4cdecaa2..8b6d4616 100644 --- a/src/libs/engine/ClientBroadcaster.h +++ b/src/libs/engine/ClientBroadcaster.h @@ -26,7 +26,7 @@ #include #include "types.h" #include "interface/ClientInterface.h" -#include "raul/SharedPtr.h" +#include using std::list; using std::string; using std::pair; diff --git a/src/libs/engine/DirectResponder.h b/src/libs/engine/DirectResponder.h index d38693b1..c9e50f76 100644 --- a/src/libs/engine/DirectResponder.h +++ b/src/libs/engine/DirectResponder.h @@ -19,7 +19,7 @@ #ifndef DIRECTRESPONDER_H #define DIRECTRESPONDER_H -#include "raul/SharedPtr.h" +#include #include "interface/ClientInterface.h" #include "Responder.h" diff --git a/src/libs/engine/Driver.h b/src/libs/engine/Driver.h index fbddc828..bb65fe9b 100644 --- a/src/libs/engine/Driver.h +++ b/src/libs/engine/Driver.h @@ -20,7 +20,7 @@ #include #include -#include "raul/Path.h" +#include #include "DataType.h" namespace Ingen { diff --git a/src/libs/engine/Engine.cpp b/src/libs/engine/Engine.cpp index ddb9ea81..d9481786 100644 --- a/src/libs/engine/Engine.cpp +++ b/src/libs/engine/Engine.cpp @@ -35,6 +35,7 @@ #include "PostProcessor.h" #include "CreatePatchEvent.h" #include "EnablePatchEvent.h" +#include "OSCEngineReceiver.h" #ifdef HAVE_JACK_MIDI #include "JackMidiDriver.h" #endif @@ -139,14 +140,37 @@ Engine::main_iteration() } +void +Engine::start_jack_driver() +{ + _audio_driver = SharedPtr(new JackAudioDriver(*this)); +} + + +void +Engine::start_osc_driver(const std::string& port) +{ + _event_source = SharedPtr(new OSCEngineReceiver( + *this, pre_processor_queue_size, port.c_str())); +} + + +void +Engine::set_event_source(SharedPtr source) +{ + _event_source = source; +} + + bool -Engine::activate(SharedPtr ad, SharedPtr es) +Engine::activate() { if (_activated) return false; - // Setup drivers - _audio_driver = ad; + assert(_audio_driver); + assert(_event_source); + #ifdef HAVE_JACK_MIDI _midi_driver = new JackMidiDriver(((JackAudioDriver*)_audio_driver.get())->jack_client()); #elif HAVE_ALSA_MIDI @@ -155,9 +179,6 @@ Engine::activate(SharedPtr ad, SharedPtr es) _midi_driver = new DummyMidiDriver(); #endif - // Set event source (FIXME: handle multiple sources) - _event_source = es; - _event_source->activate(); // Create root patch diff --git a/src/libs/engine/Engine.h b/src/libs/engine/Engine.h index 38d638c3..e66e1125 100644 --- a/src/libs/engine/Engine.h +++ b/src/libs/engine/Engine.h @@ -54,19 +54,23 @@ class Engine : boost::noncopyable { public: Engine(); - ~Engine(); + virtual ~Engine(); - int main(); - bool main_iteration(); + virtual int main(); + virtual bool main_iteration(); /** Set the quit flag that should kill all threads and exit cleanly. * Note that it will take some time. */ - void quit() { _quit_flag = true; } + virtual void quit() { _quit_flag = true; } + + virtual void start_jack_driver(); + virtual void start_osc_driver(const std::string& port); + virtual void set_event_source(SharedPtr source); - bool activate(SharedPtr ad, SharedPtr es); - void deactivate(); + virtual bool activate(); + virtual void deactivate(); - bool activated() { return _activated; } + virtual bool activated() { return _activated; } Raul::Maid* maid() const { return _maid; } EventSource* event_source() const { return _event_source.get(); } diff --git a/src/libs/engine/Event.h b/src/libs/engine/Event.h index f0fd170a..9fd398e2 100644 --- a/src/libs/engine/Event.h +++ b/src/libs/engine/Event.h @@ -19,7 +19,7 @@ #define EVENT_H #include -#include "raul/SharedPtr.h" +#include #include "types.h" #include #include "Responder.h" diff --git a/src/libs/engine/GraphObject.h b/src/libs/engine/GraphObject.h index 8754c28a..c5993595 100644 --- a/src/libs/engine/GraphObject.h +++ b/src/libs/engine/GraphObject.h @@ -23,8 +23,8 @@ #include #include #include -#include "raul/Path.h" -#include "raul/Atom.h" +#include +#include #include "types.h" using std::string; diff --git a/src/libs/engine/Makefile.am b/src/libs/engine/Makefile.am index 98737957..5529898d 100644 --- a/src/libs/engine/Makefile.am +++ b/src/libs/engine/Makefile.am @@ -2,12 +2,16 @@ SUBDIRS = tests events MAINTAINERCLEANFILES = Makefile.in -noinst_LTLIBRARIES = libingen.la -libingen_la_CXXFLAGS = @RAUL_CFLAGS@ @JACK_CFLAGS@ @LOSC_CFLAGS@ @ALSA_CFLAGS@ @LASH_CFLAGS@ @SLV2_CFLAGS@ -I$(top_srcdir)/src/common -I$(top_srcdir)/src/libs/engine/events +moduledir = $(libdir)/ingen -libingen_la_LIBADD = @RAUL_LIBS@ @JACK_LIBS@ @LOSC_LIBS@ @ALSA_LIBS@ @LASH_LIBS@ @SLV2_LIBS@ +module_LTLIBRARIES = libingen_engine.la +libingen_engine_la_CXXFLAGS = @RAUL_CFLAGS@ @JACK_CFLAGS@ @LOSC_CFLAGS@ @ALSA_CFLAGS@ @LASH_CFLAGS@ @SLV2_CFLAGS@ -I$(top_srcdir)/src/common -I$(top_srcdir)/src/libs/engine/events +libingen_engine_la_LDFLAGS = -no-undefined -module -avoid-version +libingen_engine_la_LIBADD = @RAUL_LIBS@ @JACK_LIBS@ @LOSC_LIBS@ @ALSA_LIBS@ @LASH_LIBS@ @SLV2_LIBS@ -libingen_la_SOURCES = \ +libingen_engine_la_SOURCES = \ + engine.h \ + engine.cpp \ util.h \ tuning.h \ events.h \ @@ -160,26 +164,26 @@ libingen_la_SOURCES = \ # MidiOutputNode.cpp if WITH_JACK_MIDI -libingen_la_SOURCES += \ +libingen_engine_la_SOURCES += \ JackMidiDriver.h \ JackMidiDriver.cpp \ jack_compat.h endif if WITH_ALSA_MIDI -libingen_la_SOURCES += \ +libingen_engine_la_SOURCES += \ AlsaMidiDriver.h \ AlsaMidiDriver.cpp endif if WITH_LADSPA -libingen_la_SOURCES += \ +libingen_engine_la_SOURCES += \ LADSPANode.h \ LADSPANode.cpp endif if WITH_DSSI -libingen_la_SOURCES += \ +libingen_engine_la_SOURCES += \ DSSINode.h \ DSSINode.cpp \ events/DSSIConfigureEvent.cpp \ @@ -193,13 +197,13 @@ libingen_la_SOURCES += \ endif if WITH_LV2 -libingen_la_SOURCES += \ +libingen_engine_la_SOURCES += \ LV2Node.h \ LV2Node.cpp endif if WITH_LASH -libingen_la_SOURCES += \ +libingen_engine_la_SOURCES += \ LashDriver.h \ LashDriver.cpp endif diff --git a/src/libs/engine/OSCClientSender.cpp b/src/libs/engine/OSCClientSender.cpp index 1ba9491d..763574d1 100644 --- a/src/libs/engine/OSCClientSender.cpp +++ b/src/libs/engine/OSCClientSender.cpp @@ -30,7 +30,7 @@ #include "AudioDriver.h" #include "interface/ClientInterface.h" #include "Responder.h" -#include "raul/AtomLiblo.h" +#include using std::cout; using std::cerr; using std::endl; namespace Ingen { diff --git a/src/libs/engine/OSCEngineReceiver.cpp b/src/libs/engine/OSCEngineReceiver.cpp index 218af3c5..1d835190 100644 --- a/src/libs/engine/OSCEngineReceiver.cpp +++ b/src/libs/engine/OSCEngineReceiver.cpp @@ -15,17 +15,17 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "OSCEngineReceiver.h" #include #include #include #include #include "types.h" -#include "raul/SharedPtr.h" -#include "raul/AtomLiblo.h" -#include "QueuedEventSource.h" +#include +#include #include "interface/ClientKey.h" #include "interface/ClientInterface.h" +#include "OSCEngineReceiver.h" +#include "QueuedEventSource.h" #include "OSCClientSender.h" #include "OSCResponder.h" #include "ClientBroadcaster.h" @@ -48,7 +48,7 @@ using Shared::ClientKey; */ -OSCEngineReceiver::OSCEngineReceiver(SharedPtr engine, size_t queue_size, const char* const port) +OSCEngineReceiver::OSCEngineReceiver(Engine& engine, size_t queue_size, const char* const port) : EngineInterface(), QueuedEngineInterface(engine, queue_size, queue_size), // FIXME _port(port), @@ -227,7 +227,7 @@ OSCEngineReceiver::set_response_address_cb(const char* path, const char* types, // Shitty deal, make a new one //cerr << "** Setting response address to " << url << "(2)" << endl; me->_osc_responder = SharedPtr( - new OSCResponder(me->_engine->broadcaster(), id, url)); + new OSCResponder(me->_engine.broadcaster(), id, url)); me->set_responder(me->_osc_responder); @@ -237,7 +237,7 @@ OSCEngineReceiver::set_response_address_cb(const char* path, const char* types, // Otherwise we have a NULL responder, definitely need to set a new one } else { //cerr << "** null responder\n"; - me->_osc_responder = SharedPtr(new OSCResponder(me->_engine->broadcaster(), id, url)); + me->_osc_responder = SharedPtr(new OSCResponder(me->_engine.broadcaster(), id, url)); me->set_responder(me->_osc_responder); //cerr << "** Setting response address to " << url << "(2)" << endl; } @@ -247,7 +247,7 @@ OSCEngineReceiver::set_response_address_cb(const char* path, const char* types, // Don't respond } else { me->disable_responses(); - SharedPtr client = me->_engine->broadcaster()->client( + SharedPtr client = me->_engine.broadcaster()->client( ClientKey(ClientKey::OSC_URL, (const char*)url)); if (client) client->disable(); diff --git a/src/libs/engine/OSCEngineReceiver.h b/src/libs/engine/OSCEngineReceiver.h index 15fae6cd..04448fdf 100644 --- a/src/libs/engine/OSCEngineReceiver.h +++ b/src/libs/engine/OSCEngineReceiver.h @@ -21,7 +21,7 @@ #include "config.h" #include #include -#include "raul/SharedPtr.h" +#include #include "QueuedEngineInterface.h" #include "OSCResponder.h" using std::string; @@ -61,7 +61,7 @@ inline static int name##_cb(LO_HANDLER_ARGS, void* myself)\ class OSCEngineReceiver : public QueuedEngineInterface { public: - OSCEngineReceiver(SharedPtr engine, size_t queue_size, const char* const port); + OSCEngineReceiver(Engine& engine, size_t queue_size, const char* const port); ~OSCEngineReceiver(); void activate(); diff --git a/src/libs/engine/ObjectStore.h b/src/libs/engine/ObjectStore.h index 7cfa10c3..4c0a621a 100644 --- a/src/libs/engine/ObjectStore.h +++ b/src/libs/engine/ObjectStore.h @@ -20,7 +20,7 @@ #define OBJECTSTORE_H #include -#include "raul/Path.h" +#include #include "Tree.h" using std::string; diff --git a/src/libs/engine/PostProcessor.h b/src/libs/engine/PostProcessor.h index 4ab4ae2f..4e3d91a1 100644 --- a/src/libs/engine/PostProcessor.h +++ b/src/libs/engine/PostProcessor.h @@ -20,8 +20,8 @@ #include #include "types.h" -#include "raul/SRSWQueue.h" -#include "raul/Slave.h" +#include +#include namespace Raul { class Maid; } diff --git a/src/libs/engine/QueuedEngineInterface.cpp b/src/libs/engine/QueuedEngineInterface.cpp index 681cf798..b38692ea 100644 --- a/src/libs/engine/QueuedEngineInterface.cpp +++ b/src/libs/engine/QueuedEngineInterface.cpp @@ -24,7 +24,7 @@ namespace Ingen { -QueuedEngineInterface::QueuedEngineInterface(SharedPtr engine, size_t queued_size, size_t stamped_size) +QueuedEngineInterface::QueuedEngineInterface(Engine& engine, size_t queued_size, size_t stamped_size) : QueuedEventSource(queued_size, stamped_size) , _responder(SharedPtr(new Responder())) // NULL responder , _engine(engine) @@ -37,7 +37,7 @@ QueuedEngineInterface::now() const { // Exactly one cycle latency (some could run ASAP if we get lucky, but not always, and a slight // constant latency is far better than jittery lower (average) latency - return _engine->audio_driver()->frame_time() + _engine->audio_driver()->buffer_size(); + return _engine.audio_driver()->frame_time() + _engine.audio_driver()->buffer_size(); } @@ -76,14 +76,14 @@ QueuedEngineInterface::disable_responses() void QueuedEngineInterface::register_client(ClientKey key, SharedPtr client) { - push_queued(new RegisterClientEvent(*_engine.get(), _responder, now(), key, client)); + push_queued(new RegisterClientEvent(_engine, _responder, now(), key, client)); } void QueuedEngineInterface::unregister_client(ClientKey key) { - push_queued(new UnregisterClientEvent(*_engine.get(), _responder, now(), key)); + push_queued(new UnregisterClientEvent(_engine, _responder, now(), key)); } @@ -92,7 +92,7 @@ QueuedEngineInterface::unregister_client(ClientKey key) void QueuedEngineInterface::load_plugins() { - push_queued(new LoadPluginsEvent(*_engine.get(), _responder, now())); + push_queued(new LoadPluginsEvent(_engine, _responder, now())); } @@ -100,14 +100,14 @@ QueuedEngineInterface::load_plugins() void QueuedEngineInterface::activate() { - push_queued(new PingQueuedEvent(*_engine.get(), _responder, now())); + push_queued(new PingQueuedEvent(_engine, _responder, now())); } void QueuedEngineInterface::deactivate() { - push_queued(new DeactivateEvent(*_engine.get(), _responder, now())); + push_queued(new DeactivateEvent(_engine, _responder, now())); } @@ -115,7 +115,7 @@ void QueuedEngineInterface::quit() { _responder->respond_ok(); - _engine->quit(); + _engine.quit(); } @@ -126,7 +126,7 @@ void QueuedEngineInterface::create_patch(const string& path, uint32_t poly) { - push_queued(new CreatePatchEvent(*_engine.get(), _responder, now(), path, poly)); + push_queued(new CreatePatchEvent(_engine, _responder, now(), path, poly)); } @@ -135,7 +135,7 @@ void QueuedEngineInterface::create_port(const string& path, const string& data_type, bool direction) { - push_queued(new AddPortEvent(*_engine.get(), _responder, now(), path, data_type, direction, this)); + push_queued(new AddPortEvent(_engine, _responder, now(), path, data_type, direction, this)); } @@ -144,7 +144,7 @@ QueuedEngineInterface::create_node(const string& path, const string& plugin_uri, bool polyphonic) { - push_queued(new AddNodeEvent(*_engine.get(), _responder, now(), + push_queued(new AddNodeEvent(_engine, _responder, now(), path, plugin_uri, polyphonic)); } @@ -156,7 +156,7 @@ QueuedEngineInterface::create_node(const string& path, const string& plugin_label, bool polyphonic) { - push_queued(new AddNodeEvent(*_engine.get(), _responder, now(), + push_queued(new AddNodeEvent(_engine, _responder, now(), path, plugin_type, plugin_lib, plugin_label, polyphonic)); } @@ -164,35 +164,35 @@ void QueuedEngineInterface::rename(const string& old_path, const string& new_name) { - push_queued(new RenameEvent(*_engine.get(), _responder, now(), old_path, new_name)); + push_queued(new RenameEvent(_engine, _responder, now(), old_path, new_name)); } void QueuedEngineInterface::destroy(const string& path) { - push_queued(new DestroyEvent(*_engine.get(), _responder, now(), this, path)); + push_queued(new DestroyEvent(_engine, _responder, now(), this, path)); } void QueuedEngineInterface::clear_patch(const string& patch_path) { - push_queued(new ClearPatchEvent(*_engine.get(), _responder, now(), this, patch_path)); + push_queued(new ClearPatchEvent(_engine, _responder, now(), this, patch_path)); } void QueuedEngineInterface::enable_patch(const string& patch_path) { - push_queued(new EnablePatchEvent(*_engine.get(), _responder, now(), patch_path)); + push_queued(new EnablePatchEvent(_engine, _responder, now(), patch_path)); } void QueuedEngineInterface::disable_patch(const string& patch_path) { - push_queued(new DisablePatchEvent(*_engine.get(), _responder, now(), patch_path)); + push_queued(new DisablePatchEvent(_engine, _responder, now(), patch_path)); } @@ -200,7 +200,7 @@ void QueuedEngineInterface::connect(const string& src_port_path, const string& dst_port_path) { - push_queued(new ConnectionEvent(*_engine.get(), _responder, now(), src_port_path, dst_port_path)); + push_queued(new ConnectionEvent(_engine, _responder, now(), src_port_path, dst_port_path)); } @@ -209,14 +209,14 @@ void QueuedEngineInterface::disconnect(const string& src_port_path, const string& dst_port_path) { - push_queued(new DisconnectionEvent(*_engine.get(), _responder, now(), src_port_path, dst_port_path)); + push_queued(new DisconnectionEvent(_engine, _responder, now(), src_port_path, dst_port_path)); } void QueuedEngineInterface::disconnect_all(const string& node_path) { - push_queued(new DisconnectNodeEvent(*_engine.get(), _responder, now(), node_path)); + push_queued(new DisconnectNodeEvent(_engine, _responder, now(), node_path)); } @@ -224,7 +224,7 @@ void QueuedEngineInterface::set_port_value(const string& port_path, float value) { - push_stamped(new SetPortValueEvent(*_engine.get(), _responder, now(), port_path, value)); + push_stamped(new SetPortValueEvent(_engine, _responder, now(), port_path, value)); } @@ -233,7 +233,7 @@ QueuedEngineInterface::set_port_value(const string& port_path, uint32_t voice, float value) { - push_stamped(new SetPortValueEvent(*_engine.get(), _responder, now(), voice, port_path, value)); + push_stamped(new SetPortValueEvent(_engine, _responder, now(), voice, port_path, value)); } @@ -241,7 +241,7 @@ void QueuedEngineInterface::set_port_value_queued(const string& port_path, float value) { - push_queued(new SetPortValueQueuedEvent(*_engine.get(), _responder, now(), port_path, value)); + push_queued(new SetPortValueQueuedEvent(_engine, _responder, now(), port_path, value)); } @@ -251,7 +251,7 @@ QueuedEngineInterface::set_program(const string& node_path, uint32_t program) { #ifdef HAVE_DSSI - push_queued(new DSSIProgramEvent(*_engine.get(), _responder, now(), node_path, bank, program)); + push_queued(new DSSIProgramEvent(_engine, _responder, now(), node_path, bank, program)); #endif } @@ -259,7 +259,7 @@ QueuedEngineInterface::set_program(const string& node_path, void QueuedEngineInterface::midi_learn(const string& node_path) { - push_queued(new MidiLearnEvent(*_engine.get(), _responder, now(), node_path)); + push_queued(new MidiLearnEvent(_engine, _responder, now(), node_path)); } @@ -268,7 +268,7 @@ QueuedEngineInterface::set_metadata(const string& path, const string& predicate, const Atom& value) { - push_queued(new SetMetadataEvent(*_engine.get(), _responder, now(), path, predicate, value)); + push_queued(new SetMetadataEvent(_engine, _responder, now(), path, predicate, value)); } @@ -277,8 +277,8 @@ QueuedEngineInterface::set_metadata(const string& path, void QueuedEngineInterface::ping() { - if (_engine->activated()) { - push_queued(new PingQueuedEvent(*_engine.get(), _responder, now())); + if (_engine.activated()) { + push_queued(new PingQueuedEvent(_engine, _responder, now())); } else if (_responder) { _responder->respond_ok(); } @@ -288,35 +288,35 @@ QueuedEngineInterface::ping() void QueuedEngineInterface::request_plugin(const string& uri) { - push_queued(new RequestPluginEvent(*_engine.get(), _responder, now(), uri)); + push_queued(new RequestPluginEvent(_engine, _responder, now(), uri)); } void QueuedEngineInterface::request_object(const string& path) { - push_queued(new RequestObjectEvent(*_engine.get(), _responder, now(), path)); + push_queued(new RequestObjectEvent(_engine, _responder, now(), path)); } void QueuedEngineInterface::request_port_value(const string& port_path) { - push_queued(new RequestPortValueEvent(*_engine.get(), _responder, now(), port_path)); + push_queued(new RequestPortValueEvent(_engine, _responder, now(), port_path)); } void QueuedEngineInterface::request_plugins() { - push_queued(new RequestPluginsEvent(*_engine.get(), _responder, now())); + push_queued(new RequestPluginsEvent(_engine, _responder, now())); } void QueuedEngineInterface::request_all_objects() { - push_queued(new RequestAllObjectsEvent(*_engine.get(), _responder, now())); + push_queued(new RequestAllObjectsEvent(_engine, _responder, now())); } diff --git a/src/libs/engine/QueuedEngineInterface.h b/src/libs/engine/QueuedEngineInterface.h index bfc4237f..ddf293dc 100644 --- a/src/libs/engine/QueuedEngineInterface.h +++ b/src/libs/engine/QueuedEngineInterface.h @@ -21,7 +21,7 @@ #include #include #include -#include "raul/SharedPtr.h" +#include #include "interface/EngineInterface.h" #include "interface/ClientInterface.h" #include "interface/ClientKey.h" @@ -61,7 +61,7 @@ class Engine; class QueuedEngineInterface : public QueuedEventSource, public virtual EngineInterface { public: - QueuedEngineInterface(SharedPtr engine, size_t queued_size, size_t stamped_size); + QueuedEngineInterface(Engine& engine, size_t queued_size, size_t stamped_size); virtual ~QueuedEngineInterface() {} void set_next_response_id(int32_t id); @@ -158,7 +158,7 @@ protected: /** Where responses to current messages will go. */ SharedPtr _responder; - SharedPtr _engine; + Engine& _engine; private: SampleCount now() const; diff --git a/src/libs/engine/QueuedEventSource.h b/src/libs/engine/QueuedEventSource.h index 9bda226f..d0c17c0b 100644 --- a/src/libs/engine/QueuedEventSource.h +++ b/src/libs/engine/QueuedEventSource.h @@ -21,9 +21,9 @@ #include #include #include "types.h" -#include "raul/Semaphore.h" -#include "raul/SRSWQueue.h" -#include "raul/Slave.h" +#include +#include +#include #include "Event.h" #include "EventSource.h" diff --git a/src/libs/engine/Responder.h b/src/libs/engine/Responder.h index 9fa72dcf..f111b02a 100644 --- a/src/libs/engine/Responder.h +++ b/src/libs/engine/Responder.h @@ -20,7 +20,7 @@ #include #include -#include "raul/SharedPtr.h" +#include #include "interface/ClientKey.h" #include "interface/ClientInterface.h" using std::string; diff --git a/src/libs/engine/ThreadManager.h b/src/libs/engine/ThreadManager.h index a62431ff..dc415526 100644 --- a/src/libs/engine/ThreadManager.h +++ b/src/libs/engine/ThreadManager.h @@ -18,7 +18,7 @@ #ifndef THREADMANAGER_H #define THREADMANAGER_H -#include "raul/Thread.h" +#include using Raul::Thread; diff --git a/src/libs/engine/engine.cpp b/src/libs/engine/engine.cpp new file mode 100644 index 00000000..a2ba26da --- /dev/null +++ b/src/libs/engine/engine.cpp @@ -0,0 +1,42 @@ +/* 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 + */ + +#include "engine.h" +#include "Engine.h" +#include "QueuedEngineInterface.h" +#include "tuning.h" + +namespace Ingen { + + +Engine* +new_engine() +{ + return new Engine(); +} + + +QueuedEngineInterface* +new_queued_engine_interface(Engine& engine) +{ + return new QueuedEngineInterface(engine, + Ingen::event_queue_size, Ingen::event_queue_size); +} + + +} // namespace Ingen + diff --git a/src/libs/engine/engine.h b/src/libs/engine/engine.h new file mode 100644 index 00000000..aac69661 --- /dev/null +++ b/src/libs/engine/engine.h @@ -0,0 +1,38 @@ +/* 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 INGEN_ENGINE_H +#define INGEN_ENGINE_H + +namespace Ingen { + +class Engine; +class QueuedEngineInterface; + + +extern "C" { + + extern Engine* new_engine(); + extern QueuedEngineInterface* new_queued_interface(Engine& engine); + +} + + +} // namespace Ingen + +#endif // INGEN_ENGINE_H + diff --git a/src/libs/engine/events/AddNodeEvent.cpp b/src/libs/engine/events/AddNodeEvent.cpp index 0e3fa56d..88efbb45 100644 --- a/src/libs/engine/events/AddNodeEvent.cpp +++ b/src/libs/engine/events/AddNodeEvent.cpp @@ -26,9 +26,9 @@ #include "NodeFactory.h" #include "ClientBroadcaster.h" #include -#include "raul/Path.h" +#include #include "ObjectStore.h" -#include "raul/Path.h" +#include #include "Port.h" namespace Ingen { diff --git a/src/libs/engine/events/AddNodeEvent.h b/src/libs/engine/events/AddNodeEvent.h index 6b68f627..7a88cd1c 100644 --- a/src/libs/engine/events/AddNodeEvent.h +++ b/src/libs/engine/events/AddNodeEvent.h @@ -19,7 +19,7 @@ #define ADDNODEEVENT_H #include "QueuedEvent.h" -#include "raul/Path.h" +#include #include using std::string; diff --git a/src/libs/engine/events/AddPortEvent.cpp b/src/libs/engine/events/AddPortEvent.cpp index c9f22cd1..1157d06a 100644 --- a/src/libs/engine/events/AddPortEvent.cpp +++ b/src/libs/engine/events/AddPortEvent.cpp @@ -23,11 +23,11 @@ #include "Engine.h" #include "Patch.h" #include -#include "raul/Path.h" +#include #include "QueuedEventSource.h" #include "ObjectStore.h" #include "ClientBroadcaster.h" -#include "raul/Path.h" +#include #include "Port.h" #include "AudioDriver.h" #include "MidiDriver.h" diff --git a/src/libs/engine/events/ConnectionEvent.h b/src/libs/engine/events/ConnectionEvent.h index bebb6cfd..9565d79f 100644 --- a/src/libs/engine/events/ConnectionEvent.h +++ b/src/libs/engine/events/ConnectionEvent.h @@ -20,7 +20,7 @@ #include #include "QueuedEvent.h" -#include "raul/Path.h" +#include #include "types.h" using std::string; diff --git a/src/libs/engine/events/CreatePatchEvent.cpp b/src/libs/engine/events/CreatePatchEvent.cpp index 344dbbe9..81d05368 100644 --- a/src/libs/engine/events/CreatePatchEvent.cpp +++ b/src/libs/engine/events/CreatePatchEvent.cpp @@ -25,7 +25,7 @@ #include #include "ClientBroadcaster.h" #include "AudioDriver.h" -#include "raul/Path.h" +#include #include "ObjectStore.h" namespace Ingen { diff --git a/src/libs/engine/events/DestroyEvent.cpp b/src/libs/engine/events/DestroyEvent.cpp index 14e6702c..c00306d8 100644 --- a/src/libs/engine/events/DestroyEvent.cpp +++ b/src/libs/engine/events/DestroyEvent.cpp @@ -30,7 +30,7 @@ #include "ClientBroadcaster.h" #include #include "ObjectStore.h" -#include "raul/Path.h" +#include #include "QueuedEventSource.h" #include "Port.h" diff --git a/src/libs/engine/events/DisconnectNodeEvent.cpp b/src/libs/engine/events/DisconnectNodeEvent.cpp index 8f2a90f2..f304f0b1 100644 --- a/src/libs/engine/events/DisconnectNodeEvent.cpp +++ b/src/libs/engine/events/DisconnectNodeEvent.cpp @@ -32,7 +32,7 @@ #include "ClientBroadcaster.h" #include "util.h" #include "ObjectStore.h" -#include "raul/Path.h" +#include using std::cerr; using std::endl; diff --git a/src/libs/engine/events/DisconnectPortEvent.h b/src/libs/engine/events/DisconnectPortEvent.h index f3058fa1..089508ea 100644 --- a/src/libs/engine/events/DisconnectPortEvent.h +++ b/src/libs/engine/events/DisconnectPortEvent.h @@ -19,7 +19,7 @@ #define DISCONNECTPORTEVENT_H #include -#include "raul/Path.h" +#include #include "QueuedEvent.h" #include diff --git a/src/libs/engine/events/RenameEvent.cpp b/src/libs/engine/events/RenameEvent.cpp index 52205046..a833c42e 100644 --- a/src/libs/engine/events/RenameEvent.cpp +++ b/src/libs/engine/events/RenameEvent.cpp @@ -22,7 +22,7 @@ #include "Tree.h" #include "Engine.h" #include "ClientBroadcaster.h" -#include "raul/Path.h" +#include #include "ObjectStore.h" namespace Ingen { diff --git a/src/libs/engine/events/RequestMetadataEvent.h b/src/libs/engine/events/RequestMetadataEvent.h index e074b6ee..497a94bf 100644 --- a/src/libs/engine/events/RequestMetadataEvent.h +++ b/src/libs/engine/events/RequestMetadataEvent.h @@ -20,7 +20,7 @@ #include #include "QueuedEvent.h" -#include "raul/Atom.h" +#include using std::string; namespace Ingen { diff --git a/src/libs/engine/events/SetMetadataEvent.h b/src/libs/engine/events/SetMetadataEvent.h index ca50adda..fae167a4 100644 --- a/src/libs/engine/events/SetMetadataEvent.h +++ b/src/libs/engine/events/SetMetadataEvent.h @@ -20,7 +20,7 @@ #include #include "QueuedEvent.h" -#include "raul/Atom.h" +#include using std::string; diff --git a/src/libs/module/Makefile.am b/src/libs/module/Makefile.am new file mode 100644 index 00000000..28cd2822 --- /dev/null +++ b/src/libs/module/Makefile.am @@ -0,0 +1,9 @@ +noinst_LTLIBRARIES = libingen_module.la + +libingen_module_la_CXXFLAGS = @RAUL_CFLAGS@ @GLIBMM_CFLAGS@ -DINGEN_MODULE_DIR=\"$(libdir)/ingen\" + +libingen_module_la_LIBADD = @RAUL_LIBS@ @GLIBMM_LIBS@ + +libingen_module_la_SOURCES = \ + Module.h \ + Module.cpp diff --git a/src/libs/module/Module.cpp b/src/libs/module/Module.cpp new file mode 100644 index 00000000..d92ee97a --- /dev/null +++ b/src/libs/module/Module.cpp @@ -0,0 +1,80 @@ +/* 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 + */ + +#include +#include +#include +#include +#include +#include + +#ifndef INGEN_MODULE_DIR +#error This file expects INGEN_MODULE_DIR to be defined. +#endif + +using namespace std; + +namespace Ingen { +namespace Shared { + + +/** Load a dynamic module from the default path. + * + * This will check in the directories specified in the environment variable + * INGEN_MODULE_PATH (typical colon delimited format), then the default module + * installation directory (ie /usr/local/lib/ingen), in that order. + * + * \param name The base name of the module, e.g. "ingen_serialisation" + */ +SharedPtr +load_module(const string& name) +{ + SharedPtr module; + + // Search INGEN_MODULE_PATH first + bool module_path_found; + string module_path = Glib::getenv("INGEN_MODULE_PATH", module_path_found); + if (module_path_found) { + string dir; + istringstream iss(module_path); + while (getline(iss, dir, ':')) { + module = SharedPtr(new Glib::Module( + Glib::Module::build_path(dir, name), + Glib::MODULE_BIND_LAZY)); + + if (module && *module.get()) + return module; + } + } + + // Try default directory if not found + module = SharedPtr(new Glib::Module( + Glib::Module::build_path(INGEN_MODULE_DIR, name), + Glib::MODULE_BIND_LAZY)); + + if (*module.get()) { + return module; + } else { + cerr << "Unable to load module \"" << name << "\" (you may want to set INGEN_MODULE_PATH)." << endl; + return SharedPtr(); + } +} + + +} // namespace Shared +} // namespace Ingen + diff --git a/src/libs/module/Module.h b/src/libs/module/Module.h new file mode 100644 index 00000000..b0fdee1b --- /dev/null +++ b/src/libs/module/Module.h @@ -0,0 +1,39 @@ +/* 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 + */ + +#include +#include +#include + +#ifndef INGEN_MODULE_DIR +#error This file expects INGEN_MODULE_DIR to be defined. +#endif + +namespace Ingen { +namespace Shared { + + +/** Load a dynamic module from the default path. + * + * \param name The base name of the module, e.g. "ingen_serialisation" + */ +SharedPtr load_module(const std::string& name); + + +} // namespace Shared +} // namespace Ingen + diff --git a/src/libs/serialisation/Loader.cpp b/src/libs/serialisation/Loader.cpp new file mode 100644 index 00000000..157756b1 --- /dev/null +++ b/src/libs/serialisation/Loader.cpp @@ -0,0 +1,342 @@ +/* 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 + */ + +#include +#include +#include +#include +#include "interface/EngineInterface.h" +#include "Loader.h" + +using namespace std; +using namespace Raul; +using namespace Ingen::Shared; + +namespace Ingen { +namespace Serialisation { + + +/** Load (create) a patch from RDF into the engine. + * + * @param document_uri URI of file to load objects from. + * @param parent Path of parent under which to load objects. + * @return whether or not load was successful. + */ +bool +Loader::load(SharedPtr engine, + Raul::RDF::World* rdf_world, + const Glib::ustring& document_uri, + boost::optional parent, + string patch_name, + Glib::ustring patch_uri, + map data) +{ + // FIXME: this whole thing is a mess + + std::map created; + + RDF::Model model(*rdf_world, document_uri); + + //patch_uri = string("<") + patch_uri + ">"; + patch_uri = string("<") + document_uri + ">"; + + cerr << "[Loader] Loading " << patch_uri << " from " << document_uri + << " under " << (string)(parent ? (string)parent.get() : "no parent") << endl; + + /* Get polyphony (mandatory) */ + + // FIXME: polyphony datatype + RDF::Query query(*rdf_world, Glib::ustring( + "SELECT DISTINCT ?poly WHERE {\n") + + patch_uri + " ingen:polyphony ?poly\n }"); + + RDF::Query::Results results = query.run(*rdf_world, model); + + if (results.size() == 0) { + cerr << "[Loader] ERROR: No polyphony found!" << endl; + return false; + } + + RDF::Node poly_node = (*results.begin())["poly"]; + assert(poly_node.is_int()); + size_t patch_poly = (size_t)poly_node.to_int(); + + /* Get name (if available/necessary) */ + + if (patch_name == "") { + patch_name = string(document_uri.substr(document_uri.find_last_of("/")+1)); + if (patch_name.substr(patch_name.length()-10) == ".ingen.ttl") + patch_name = patch_name.substr(0, patch_name.length()-10); + + query = RDF::Query(*rdf_world, Glib::ustring( + "SELECT DISTINCT ?name WHERE {\n") + + patch_uri + " ingen:name ?name\n}"); + + results = query.run(*rdf_world, model); + + if (results.size() > 0) + patch_name = (*results.begin())["name"].to_string(); + } + + Path patch_path = ( parent ? (parent.get().base() + patch_name) : Path("/") ); + cerr << "************ PATCH: name=" << patch_name << ", path=" << patch_path + << ", poly = " << patch_poly << endl; + engine->create_patch(patch_path, patch_poly); + + + /* Load (plugin) nodes */ + + query = RDF::Query(*rdf_world, Glib::ustring( + "SELECT DISTINCT ?name ?plugin ?floatkey ?floatval WHERE {\n") + + patch_uri + " ingen:node ?node .\n" + "?node ingen:name ?name ;\n" + " ingen:plugin ?plugin .\n" + "OPTIONAL { ?node ?floatkey ?floatval . \n" + " FILTER ( datatype(?floatval) = xsd:decimal ) }\n" + "}"); + + results = query.run(*rdf_world, model); + + for (RDF::Query::Results::iterator i = results.begin(); i != results.end(); ++i) { + + string name = (*i)["name"].to_string(); + string plugin = (*i)["plugin"].to_string(); + + const Path node_path = patch_path.base() + (string)name; + + if (created.find(node_path) == created.end()) { + engine->create_node(node_path, plugin, false); + created[node_path] = true; + } + + string floatkey = rdf_world->prefixes().qualify((*i)["floatkey"].to_string()); + RDF::Node val_node = (*i)["floatval"]; + + if (floatkey != "" && val_node.is_float()) + engine->set_metadata(patch_path.base() + name, floatkey, Atom(val_node.to_float())); + } + + + /* Load subpatches */ + + query = RDF::Query(*rdf_world, Glib::ustring( + "SELECT DISTINCT ?patch ?name WHERE {\n") + + patch_uri + " ingen:node ?patch .\n" + "?patch a ingen:Patch ;\n" + " ingen:name ?name .\n" + "}"); + + results = query.run(*rdf_world, model); + + for (RDF::Query::Results::iterator i = results.begin(); i != results.end(); ++i) { + + string name = (*i)["name"].to_string(); + string patch = (*i)["patch"].to_string(); + + const Path subpatch_path = patch_path.base() + (string)name; + + if (created.find(subpatch_path) == created.end()) { + load(engine, rdf_world, document_uri, patch_path, name, patch); + created[subpatch_path] = true; + } + } + + created.clear(); + + + /* Set node port control values */ + + query = RDF::Query(*rdf_world, Glib::ustring( + "SELECT DISTINCT ?nodename ?portname ?portval WHERE {\n") + + patch_uri + " ingen:node ?node .\n" + "?node ingen:name ?nodename ;\n" + " ingen:port ?port .\n" + "?port ingen:name ?portname ;\n" + " ingen:value ?portval .\n" + "FILTER ( datatype(?portval) = xsd:decimal )\n" + "}\n"); + + results = query.run(*rdf_world, model); + + for (RDF::Query::Results::iterator i = results.begin(); i != results.end(); ++i) { + + string node_name = (*i)["nodename"].to_string(); + string port_name = (*i)["portname"].to_string(); + const float val = (*i)["portval"].to_float(); + + Path port_path = patch_path.base() + (const string&)node_name +"/"+ (const string&)port_name; + + engine->set_port_value(port_path, val); + } + + + /* Load this patch's ports */ + + query = RDF::Query(*rdf_world, Glib::ustring( + "SELECT DISTINCT ?port ?type ?name ?datatype ?floatkey ?floatval ?portval WHERE {\n") + + patch_uri + " ingen:port ?port .\n" + "?port a ?type ;\n" + " ingen:name ?name ;\n" + " ingen:dataType ?datatype .\n" + "OPTIONAL { ?port ?floatkey ?floatval . \n" + " FILTER ( datatype(?floatval) = xsd:decimal ) }\n" + "OPTIONAL { ?port ingen:value ?portval . \n" + " FILTER ( datatype(?portval) = xsd:decimal ) }\n" + "}"); + + results = query.run(*rdf_world, model); + + for (RDF::Query::Results::iterator i = results.begin(); i != results.end(); ++i) { + string name = (*i)["name"].to_string(); + string type = rdf_world->qualify((*i)["type"].to_string()); + string datatype = (*i)["datatype"].to_string(); + + const Path port_path = patch_path.base() + (string)name; + + if (created.find(port_path) == created.end()) { + //cerr << "TYPE: " << type << endl; + bool is_output = (type == "ingen:OutputPort"); // FIXME: check validity + engine->create_port(port_path, datatype, is_output); + created[port_path] = true; + } + + RDF::Node val_node = (*i)["portval"]; + if (val_node.is_float()) + engine->set_port_value(patch_path.base() + name, val_node.to_float()); + + string floatkey = rdf_world->qualify((*i)["floatkey"].to_string()); + val_node = (*i)["floatval"]; + + if (floatkey != "" && val_node.is_float()) + engine->set_metadata(patch_path.base() + name, floatkey, Atom(val_node.to_float())); + } + + created.clear(); + + + /* Node -> Node connections */ + + query = RDF::Query(*rdf_world, Glib::ustring( + "SELECT DISTINCT ?srcnodename ?srcname ?dstnodename ?dstname WHERE {\n") + + patch_uri + "ingen:node ?srcnode ;\n" + " ingen:node ?dstnode .\n" + "?srcnode ingen:port ?src ;\n" + " ingen:name ?srcnodename .\n" + "?dstnode ingen:port ?dst ;\n" + " ingen:name ?dstnodename .\n" + "?src ingen:name ?srcname .\n" + "?dst ingen:connectedTo ?src ;\n" + " ingen:name ?dstname .\n" + "}\n"); + + results = query.run(*rdf_world, model); + + for (RDF::Query::Results::iterator i = results.begin(); i != results.end(); ++i) { + Path src_node = patch_path.base() + (*i)["srcnodename"].to_string(); + Path src_port = src_node.base() + (*i)["srcname"].to_string(); + Path dst_node = patch_path.base() + (*i)["dstnodename"].to_string(); + Path dst_port = dst_node.base() + (*i)["dstname"].to_string(); + + cerr << patch_path << " 1 CONNECTION: " << src_port << " -> " << dst_port << endl; + + engine->connect(src_port, dst_port); + } + + + /* This Patch -> Node connections */ + + query = RDF::Query(*rdf_world, Glib::ustring( + "SELECT DISTINCT ?srcname ?dstnodename ?dstname WHERE {\n") + + patch_uri + " ingen:port ?src ;\n" + " ingen:node ?dstnode .\n" + "?dstnode ingen:port ?dst ;\n" + " ingen:name ?dstnodename .\n" + "?dst ingen:connectedTo ?src ;\n" + " ingen:name ?dstname .\n" + "?src ingen:name ?srcname .\n" + "}\n"); + + results = query.run(*rdf_world, model); + + for (RDF::Query::Results::iterator i = results.begin(); i != results.end(); ++i) { + Path src_port = patch_path.base() + (*i)["srcname"].to_string(); + Path dst_node = patch_path.base() + (*i)["dstnodename"].to_string(); + Path dst_port = dst_node.base() + (*i)["dstname"].to_string(); + + cerr << patch_path << " 2 CONNECTION: " << src_port << " -> " << dst_port << endl; + + engine->connect(src_port, dst_port); + } + + + /* Node -> This Patch connections */ + + query = RDF::Query(*rdf_world, Glib::ustring( + "SELECT DISTINCT ?srcnodename ?srcname ?dstname WHERE {\n") + + patch_uri + " ingen:port ?dst ;\n" + " ingen:node ?srcnode .\n" + "?srcnode ingen:port ?src ;\n" + " ingen:name ?srcnodename .\n" + "?dst ingen:connectedTo ?src ;\n" + " ingen:name ?dstname .\n" + "?src ingen:name ?srcname .\n" + "}\n"); + + results = query.run(*rdf_world, model); + + for (RDF::Query::Results::iterator i = results.begin(); i != results.end(); ++i) { + Path dst_port = patch_path.base() + (*i)["dstname"].to_string(); + Path src_node = patch_path.base() + (*i)["srcnodename"].to_string(); + Path src_port = src_node.base() + (*i)["srcname"].to_string(); + + cerr << patch_path << " 3 CONNECTION: " << src_port << " -> " << dst_port << endl; + + engine->connect(src_port, dst_port); + } + + + /* Load metadata */ + + query = RDF::Query(*rdf_world, Glib::ustring( + "SELECT DISTINCT ?floatkey ?floatval WHERE {\n") + + patch_uri + " ?floatkey ?floatval . \n" + " FILTER ( datatype(?floatval) = xsd:decimal ) \n" + "}"); + + results = query.run(*rdf_world, model); + + for (RDF::Query::Results::iterator i = results.begin(); i != results.end(); ++i) { + + string floatkey = rdf_world->prefixes().qualify((*i)["floatkey"].to_string()); + RDF::Node val_node = (*i)["floatval"]; + + if (floatkey != "" && val_node.is_float()) + engine->set_metadata(patch_path, floatkey, Atom(val_node.to_float())); + } + + + // Set passed metadata last to override any loaded values + for (Metadata::const_iterator i = data.begin(); i != data.end(); ++i) + engine->set_metadata(patch_path, i->first, i->second); + + return true; +} + + +} // namespace Serialisation +} // namespace Ingen + diff --git a/src/libs/serialisation/Loader.h b/src/libs/serialisation/Loader.h new file mode 100644 index 00000000..a02e5cdb --- /dev/null +++ b/src/libs/serialisation/Loader.h @@ -0,0 +1,56 @@ +/* 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 LOADER_H +#define LOADER_H + +#include +#include +#include +#include +#include +#include +#include + +namespace Raul { class Atom; namespace RDF { class World; } } +namespace Ingen { namespace Shared { class EngineInterface; } } + +namespace Ingen { +namespace Serialisation { + + +class Loader { +public: + virtual ~Loader() {} + + typedef std::map Metadata; + + virtual bool + load(SharedPtr engine, + Raul::RDF::World* world, + const Glib::ustring& uri, + boost::optional parent, + std::string patch_name, + Glib::ustring patch_uri = "", + Metadata data = Metadata()); +}; + + +} // namespace Serialisation +} // namespace Ingen + +#endif // LOADER_H diff --git a/src/libs/serialisation/Makefile.am b/src/libs/serialisation/Makefile.am new file mode 100644 index 00000000..f1343463 --- /dev/null +++ b/src/libs/serialisation/Makefile.am @@ -0,0 +1,16 @@ +MAINTAINERCLEANFILES = Makefile.in + +moduledir = $(libdir)/ingen + +module_LTLIBRARIES = libingen_serialisation.la + +libingen_serialisation_la_CXXFLAGS = @RAUL_CFLAGS@ -I$(top_srcdir)/src/common +libingen_serialisation_la_LDFLAGS = -no-undefined -module -avoid-version +libingen_serialisation_la_LIBADD = @RAUL_LIBS@ + +libingen_serialisation_la_SOURCES = \ + serialisation.h \ + serialisation.cpp \ + Loader.h \ + Loader.cpp + diff --git a/src/libs/serialisation/serialisation.cpp b/src/libs/serialisation/serialisation.cpp new file mode 100644 index 00000000..e0764fc1 --- /dev/null +++ b/src/libs/serialisation/serialisation.cpp @@ -0,0 +1,34 @@ +/* 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 + */ + +#include "serialisation.h" +#include "Loader.h" + +namespace Ingen { +namespace Serialisation { + + +Ingen::Serialisation::Loader* +new_loader() +{ + return new Loader(); +} + + +} // namespace Serialisation +} // namespace Ingen + diff --git a/src/libs/serialisation/serialisation.h b/src/libs/serialisation/serialisation.h new file mode 100644 index 00000000..f65b9c2e --- /dev/null +++ b/src/libs/serialisation/serialisation.h @@ -0,0 +1,38 @@ +/* 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 INGEN_SERIALISATION_H +#define INGEN_SERIALISATION_H + +namespace Ingen { +namespace Serialisation { + +class Loader; + + +extern "C" { + + extern Loader* new_loader(); + +} + + +} // namespace Serialisation +} // namespace Ingen + +#endif // INGEN_SERIALISATION_H + -- cgit v1.2.1