diff options
author | David Robillard <d@drobilla.net> | 2007-05-02 23:58:28 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2007-05-02 23:58:28 +0000 |
commit | 40ff85e256ca9094fb75cdcbabd3442339f91ecd (patch) | |
tree | bc2c23a9802110f14836fc87413e08be1b7b7266 /src/libs | |
parent | 10e23868c8199335ebd360afb62911174075658c (diff) | |
download | ingen-40ff85e256ca9094fb75cdcbabd3442339f91ecd.tar.gz ingen-40ff85e256ca9094fb75cdcbabd3442339f91ecd.tar.bz2 ingen-40ff85e256ca9094fb75cdcbabd3442339f91ecd.zip |
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
Diffstat (limited to 'src/libs')
58 files changed, 478 insertions, 356 deletions
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 <string> -#include "raul/Path.h" -#include "raul/SharedPtr.h" +#include <raul/Path.h> +#include <raul/SharedPtr.h> #include "PortModel.h" #include <cassert> 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 <string> -#include "raul/Path.h" +#include <raul/Path.h> 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 <libxml/parser.h> -#include <libxml/tree.h> -#include <libxml/xpath.h> -#include <algorithm> -#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 <iostream> #include <fstream> #include <vector> +#include <algorithm> #include <utility> // for pair, make_pair #include <cassert> #include <cstring> #include <string> #include <cstdlib> // for atof #include <cmath> +#include <libxml/parser.h> +#include <libxml/tree.h> +#include <libxml/xpath.h> +#include <raul/Path.h> +#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<NodeModel>(); @@ -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 <boost/optional.hpp> #include <glibmm/ustring.h> #include <libxml/tree.h> -#include "raul/SharedPtr.h" -#include "raul/Path.h" +#include <raul/SharedPtr.h> +#include <raul/Path.h> +#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<ModelEngineInterface> engine) + DeprecatedLoader(SharedPtr<EngineInterface> 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<ModelEngineInterface> _engine; + SharedPtr<EngineInterface> _engine; /// Translations of paths from the loading file to actual paths (for deprecated patches) std::map<string, string> _load_path_translations; 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 <http://drobilla.net> - * - * 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<ControlModel>::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 <http://drobilla.net> - * - * 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 <string> -#include <lo/lo.h> -#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 <sigc++/sigc++.h> #include "ObjectModel.h" #include "PortModel.h" -#include "raul/Path.h" -#include "raul/SharedPtr.h" +#include <raul/Path.h> +#include <raul/SharedPtr.h> #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 <raul/AtomLiblo.h> #include <list> #include <cassert> #include <cstring> 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 <iostream> #include "OSCEngineSender.h" #include "interface/ClientKey.h" -#include "raul/AtomLiblo.h" +#include <raul/AtomLiblo.h> using std::cout; using std::cerr; using std::endl; namespace Ingen { 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 <cassert> #include <boost/utility.hpp> #include <sigc++/sigc++.h> -#include "raul/Atom.h" -#include "raul/Path.h" -#include "raul/SharedPtr.h" +#include <raul/Atom.h> +#include <raul/Path.h> +#include <raul/SharedPtr.h> 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 <map> #include <sigc++/sigc++.h> #include "NodeModel.h" -#include "raul/SharedPtr.h" +#include <raul/SharedPtr.h> #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 <string> #include <iostream> -#include "raul/Path.h" -#include "raul/SharedPtr.h" +#include <raul/Path.h> +#include <raul/SharedPtr.h> #ifdef HAVE_SLV2 #include <slv2/slv2.h> #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 <list> #include <sigc++/sigc++.h> #include "ObjectModel.h" -#include "raul/SharedPtr.h" -#include "raul/Path.h" +#include <raul/SharedPtr.h> +#include <raul/Path.h> 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 <raul/Path.h> #include <raul/Atom.h> #include <raul/AtomRedland.h> +#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 <string> #include <map> #include <list> -#include "raul/SharedPtr.h" +#include <raul/SharedPtr.h> #include <sigc++/sigc++.h> -#include "raul/Path.h" -#include "raul/Atom.h" +#include <raul/Path.h> +#include <raul/Atom.h> #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 <sigc++/sigc++.h> #include "interface/ClientInterface.h" #include "SigClientInterface.h" -#include "raul/SRSWQueue.h" -#include "raul/Atom.h" +#include <raul/SRSWQueue.h> +#include <raul/Atom.h> 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 <pthread.h> #include "types.h" #include "interface/ClientInterface.h" -#include "raul/SharedPtr.h" +#include <raul/SharedPtr.h> 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 <raul/SharedPtr.h> #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 <string> #include <boost/utility.hpp> -#include "raul/Path.h" +#include <raul/Path.h> #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<AudioDriver>(new JackAudioDriver(*this)); +} + + +void +Engine::start_osc_driver(const std::string& port) +{ + _event_source = SharedPtr<EventSource>(new OSCEngineReceiver( + *this, pre_processor_queue_size, port.c_str())); +} + + +void +Engine::set_event_source(SharedPtr<EventSource> source) +{ + _event_source = source; +} + + bool -Engine::activate(SharedPtr<AudioDriver> ad, SharedPtr<EventSource> 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<AudioDriver> ad, SharedPtr<EventSource> 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<EventSource> source); - bool activate(SharedPtr<AudioDriver> ad, SharedPtr<EventSource> 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 <cassert> -#include "raul/SharedPtr.h" +#include <raul/SharedPtr.h> #include "types.h" #include <raul/Deletable.h> #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 <cstddef> #include <cassert> #include <raul/Deletable.h> -#include "raul/Path.h" -#include "raul/Atom.h" +#include <raul/Path.h> +#include <raul/Atom.h> #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 <raul/AtomLiblo.h> 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 <iostream> #include <cstdlib> #include <string> #include <lo/lo.h> #include "types.h" -#include "raul/SharedPtr.h" -#include "raul/AtomLiblo.h" -#include "QueuedEventSource.h" +#include <raul/SharedPtr.h> +#include <raul/AtomLiblo.h> #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> 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<OSCResponder>( - 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<OSCResponder>(new OSCResponder(me->_engine->broadcaster(), id, url)); + me->_osc_responder = SharedPtr<OSCResponder>(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<ClientInterface> client = me->_engine->broadcaster()->client( + SharedPtr<ClientInterface> 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 <string> #include <lo/lo.h> -#include "raul/SharedPtr.h" +#include <raul/SharedPtr.h> #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> 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 <string> -#include "raul/Path.h" +#include <raul/Path.h> #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 <pthread.h> #include "types.h" -#include "raul/SRSWQueue.h" -#include "raul/Slave.h" +#include <raul/SRSWQueue.h> +#include <raul/Slave.h> 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> 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<Responder>(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<ClientInterface> 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 <inttypes.h> #include <string> #include <memory> -#include "raul/SharedPtr.h" +#include <raul/SharedPtr.h> #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> 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> _responder; - SharedPtr<Engine> _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 <cstdlib> #include <pthread.h> #include "types.h" -#include "raul/Semaphore.h" -#include "raul/SRSWQueue.h" -#include "raul/Slave.h" +#include <raul/Semaphore.h> +#include <raul/SRSWQueue.h> +#include <raul/Slave.h> #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 <inttypes.h> #include <string> -#include "raul/SharedPtr.h" +#include <raul/SharedPtr.h> #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 <raul/Thread.h> 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 <http://drobilla.net> + * + * 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 <http://drobilla.net> + * + * 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 <raul/Maid.h> -#include "raul/Path.h" +#include <raul/Path.h> #include "ObjectStore.h" -#include "raul/Path.h" +#include <raul/Path.h> #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 <raul/Path.h> #include <string> 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 <raul/Maid.h> -#include "raul/Path.h" +#include <raul/Path.h> #include "QueuedEventSource.h" #include "ObjectStore.h" #include "ClientBroadcaster.h" -#include "raul/Path.h" +#include <raul/Path.h> #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 <string> #include "QueuedEvent.h" -#include "raul/Path.h" +#include <raul/Path.h> #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 <raul/Maid.h> #include "ClientBroadcaster.h" #include "AudioDriver.h" -#include "raul/Path.h" +#include <raul/Path.h> #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 <raul/Maid.h> #include "ObjectStore.h" -#include "raul/Path.h" +#include <raul/Path.h> #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 <raul/Path.h> 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 <string> -#include "raul/Path.h" +#include <raul/Path.h> #include "QueuedEvent.h" #include <raul/List.h> 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 <raul/Path.h> #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 <string> #include "QueuedEvent.h" -#include "raul/Atom.h" +#include <raul/Atom.h> 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 <string> #include "QueuedEvent.h" -#include "raul/Atom.h" +#include <raul/Atom.h> 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 <http://drobilla.net> + * + * 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 <string> +#include <sstream> +#include <iostream> +#include <glibmm/module.h> +#include <glibmm/miscutils.h> +#include <raul/SharedPtr.h> + +#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<Glib::Module> +load_module(const string& name) +{ + SharedPtr<Glib::Module> 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<Glib::Module>(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<Glib::Module>(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<Glib::Module>(); + } +} + + +} // namespace Shared +} // namespace Ingen + diff --git a/src/libs/client/OSCModelEngineInterface.h b/src/libs/module/Module.h index a4a19c95..b0fdee1b 100644 --- a/src/libs/client/OSCModelEngineInterface.h +++ b/src/libs/module/Module.h @@ -15,28 +15,25 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef OSCMODELENGINEINTERFACE_H -#define OSCMODELENGINEINTERFACE_H - #include <string> -#include "OSCEngineSender.h" -#include "ModelEngineInterface.h" +#include <glibmm/module.h> +#include <raul/SharedPtr.h> -using std::string; +#ifndef INGEN_MODULE_DIR +#error This file expects INGEN_MODULE_DIR to be defined. +#endif -/** \defgroup IngenClient Client Library */ namespace Ingen { -namespace Client { +namespace Shared { -class OSCModelEngineInterface : public OSCEngineSender, public ModelEngineInterface -{ -public: - OSCModelEngineInterface(const string& engine_url) : OSCEngineSender(engine_url) {} -}; +/** Load a dynamic module from the default path. + * + * \param name The base name of the module, e.g. "ingen_serialisation" + */ +SharedPtr<Glib::Module> load_module(const std::string& name); -} // namespace Client +} // namespace Shared } // namespace Ingen -#endif // OSCMODELENGINEINTERFACE_H diff --git a/src/libs/client/Loader.cpp b/src/libs/serialisation/Loader.cpp index 8ebea580..157756b1 100644 --- a/src/libs/client/Loader.cpp +++ b/src/libs/serialisation/Loader.cpp @@ -19,8 +19,8 @@ #include <glibmm/ustring.h> #include <raul/RDFModel.h> #include <raul/RDFQuery.h> -#include "Loader.h" #include "interface/EngineInterface.h" +#include "Loader.h" using namespace std; using namespace Raul; @@ -37,13 +37,13 @@ namespace Serialisation { * @return whether or not load was successful. */ bool -load(SharedPtr<EngineInterface> engine, - Raul::RDF::World* rdf_world, - const Glib::ustring& document_uri, - boost::optional<Path> parent, - string patch_name, - Glib::ustring patch_uri, - map<string,Atom> data) +Loader::load(SharedPtr<EngineInterface> engine, + Raul::RDF::World* rdf_world, + const Glib::ustring& document_uri, + boost::optional<Path> parent, + string patch_name, + Glib::ustring patch_uri, + map<string,Atom> data) { // FIXME: this whole thing is a mess diff --git a/src/libs/client/Loader.h b/src/libs/serialisation/Loader.h index 74aa7cbb..a02e5cdb 100644 --- a/src/libs/client/Loader.h +++ b/src/libs/serialisation/Loader.h @@ -24,6 +24,7 @@ #include <boost/optional.hpp> #include <raul/SharedPtr.h> #include <raul/Path.h> +#include <raul/Atom.h> namespace Raul { class Atom; namespace RDF { class World; } } namespace Ingen { namespace Shared { class EngineInterface; } } @@ -31,16 +32,22 @@ namespace Ingen { namespace Shared { class EngineInterface; } } namespace Ingen { namespace Serialisation { -typedef std::map<std::string, Raul::Atom> Metadata; -bool -load(SharedPtr<Ingen::Shared::EngineInterface> engine, - Raul::RDF::World* world, - const Glib::ustring& uri, - boost::optional<Raul::Path> parent, - std::string patch_name, - Glib::ustring patch_uri = "", - Metadata data = Metadata()); +class Loader { +public: + virtual ~Loader() {} + + typedef std::map<std::string, Raul::Atom> Metadata; + + virtual bool + load(SharedPtr<Ingen::Shared::EngineInterface> engine, + Raul::RDF::World* world, + const Glib::ustring& uri, + boost::optional<Raul::Path> parent, + std::string patch_name, + Glib::ustring patch_uri = "", + Metadata data = Metadata()); +}; } // namespace Serialisation 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 <http://drobilla.net> + * + * 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 <http://drobilla.net> + * + * 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 + |