From ec9540a559c40046123a2ac4be83faf90b79fbb0 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 8 Oct 2007 17:13:34 +0000 Subject: Dynamically load Serialiser from serialisation module, make it actually work, etc. git-svn-id: http://svn.drobilla.net/lad/ingen@850 a436a847-0d15-0410-975c-d299462d15a1 --- src/libs/gui/App.cpp | 25 ++++++++++++++++++++----- src/libs/gui/App.hpp | 21 ++++++++++++++++----- src/libs/gui/ThreadedLoader.cpp | 17 +++++++++-------- src/libs/gui/ThreadedLoader.hpp | 3 --- src/libs/module/Module.cpp | 2 +- src/libs/serialisation/Loader.hpp | 3 +-- src/libs/serialisation/Makefile.am | 7 ++++++- src/libs/serialisation/Serialiser.hpp | 2 +- src/libs/serialisation/serialisation.cpp | 12 ++++++++++++ src/libs/serialisation/serialisation.hpp | 7 ++++++- 10 files changed, 72 insertions(+), 27 deletions(-) (limited to 'src/libs') diff --git a/src/libs/gui/App.cpp b/src/libs/gui/App.cpp index 255af745..ef81b0cc 100644 --- a/src/libs/gui/App.cpp +++ b/src/libs/gui/App.cpp @@ -65,12 +65,27 @@ App* App::_instance = 0; App::App(Ingen::Shared::World* world) -: _configuration(new Configuration()), - _about_dialog(NULL), - _window_factory(new WindowFactory()), - _world(world), - _enable_signal(true) + : _serialisation_module(Ingen::Shared::load_module("ingen_serialisation")) + , _configuration(new Configuration()) + , _about_dialog(NULL) + , _window_factory(new WindowFactory()) + , _world(world) + , _enable_signal(true) { + if (_serialisation_module) { + Serialiser* (*new_serialiser)(Ingen::Shared::World*) = NULL; + + bool found = _serialisation_module->get_symbol("new_serialiser", (void*&)new_serialiser); + + if (found) + _serialiser = SharedPtr(new_serialiser(world)); + } + + if ( ! _serialiser) { + cerr << "WARNING: Failed to load ingen_serialisation module, save disabled." << endl; + cerr << "(If you are running from the source tree, source set_dev_environment.sh)" << endl; + } + Glib::RefPtr glade_xml = GladeFactory::new_glade_reference(); glade_xml->get_widget_derived("connect_win", _connect_window); diff --git a/src/libs/gui/App.hpp b/src/libs/gui/App.hpp index 7629cd0e..196bdd96 100644 --- a/src/libs/gui/App.hpp +++ b/src/libs/gui/App.hpp @@ -43,9 +43,14 @@ namespace Ingen { class Store; class SigClientInterface; } + namespace Serialisation { + class Serialiser; + } } + +using namespace Ingen::Shared; +using namespace Ingen::Serialisation; using namespace Ingen::Client; -using Ingen::Shared::EngineInterface; /** \defgroup GUI GTK GUI */ @@ -94,10 +99,13 @@ public: Configuration* configuration() const { return _configuration; } WindowFactory* window_factory() const { return _window_factory; } - const SharedPtr& engine() const { return _engine; } - const SharedPtr& client() const { return _client; } - const SharedPtr& store() const { return _store; } - const SharedPtr& loader() const { return _loader; } + const SharedPtr& engine() const { return _engine; } + const SharedPtr& client() const { return _client; } + const SharedPtr& store() const { return _store; } + const SharedPtr& loader() const { return _loader; } + const SharedPtr& serialiser() const { return _serialiser; } + + SharedPtr serialisation_module() { return _serialisation_module; } static inline App& instance() { assert(_instance); return *_instance; } @@ -115,10 +123,13 @@ protected: static App* _instance; + SharedPtr _serialisation_module; + SharedPtr _engine; SharedPtr _client; SharedPtr _store; SharedPtr _loader; + SharedPtr _serialiser; Configuration* _configuration; diff --git a/src/libs/gui/ThreadedLoader.cpp b/src/libs/gui/ThreadedLoader.cpp index a1c28acf..11a2bcd7 100644 --- a/src/libs/gui/ThreadedLoader.cpp +++ b/src/libs/gui/ThreadedLoader.cpp @@ -29,17 +29,18 @@ namespace GUI { ThreadedLoader::ThreadedLoader(SharedPtr engine) - : _serialisation_module(Ingen::Shared::load_module("ingen_serialisation")) - , _engine(engine) + : _engine(engine) , _deprecated_loader(engine) - , _serializer(*App::instance().world()->rdf_world) { set_name("Loader"); // FIXME: rework this so the thread is only present when it's doing something (save mem) - if (_serialisation_module) { + if (App::instance().serialisation_module()) { Loader* (*new_loader)() = NULL; - bool found = _serialisation_module->get_symbol("new_loader", (void*&)new_loader); + + bool found = App::instance().serialisation_module()->get_symbol( + "new_loader", (void*&)new_loader); + if (found) _loader = SharedPtr(new_loader()); } @@ -47,8 +48,8 @@ ThreadedLoader::ThreadedLoader(SharedPtr engine) if (_loader) { start(); } else { - cerr << "WARNING: Failed to load ingen_serialisation module, unable to load patches." << endl;; - cerr << "If you are running from the source tree, run ingenuity_dev." << endl; + cerr << "WARNING: Failed to load ingen_serialisation module, load disabled." << endl; + cerr << "(If you are running from the source tree, source set_dev_environment.sh)" << endl; } } @@ -126,7 +127,7 @@ ThreadedLoader::save_patch(SharedPtr model, const string& filename) void ThreadedLoader::save_patch_event(SharedPtr model, const string& filename) { - _serializer.to_file(model, filename); + App::instance().serialiser()->to_file(model, filename); } diff --git a/src/libs/gui/ThreadedLoader.hpp b/src/libs/gui/ThreadedLoader.hpp index d0f171af..2e03c2a1 100644 --- a/src/libs/gui/ThreadedLoader.hpp +++ b/src/libs/gui/ThreadedLoader.hpp @@ -79,13 +79,10 @@ private: void _whipped(); - SharedPtr _serialisation_module; - SharedPtr _engine; SharedPtr _loader; DeprecatedLoader _deprecated_loader; - Serialiser _serializer; Glib::Mutex _mutex; list _events; }; diff --git a/src/libs/module/Module.cpp b/src/libs/module/Module.cpp index 8f445340..83064548 100644 --- a/src/libs/module/Module.cpp +++ b/src/libs/module/Module.cpp @@ -56,7 +56,7 @@ load_module(const string& name) string filename = Glib::Module::build_path(dir, name); if (Glib::file_test(filename, Glib::FILE_TEST_EXISTS)) { - module = new Glib::Module(filename, Glib::MODULE_BIND_LAZY|Glib::MODULE_BIND_LOCAL); + module = new Glib::Module(filename, Glib::MODULE_BIND_LAZY); if (*module) { return SharedPtr(module); diff --git a/src/libs/serialisation/Loader.hpp b/src/libs/serialisation/Loader.hpp index 158831cb..d363bf28 100644 --- a/src/libs/serialisation/Loader.hpp +++ b/src/libs/serialisation/Loader.hpp @@ -23,11 +23,10 @@ #include #include #include -#include #include #include "interface/GraphObject.hpp" -namespace Raul { class Atom; namespace RDF { class World; } } +namespace Raul { namespace RDF { class World; } } namespace Ingen { namespace Shared { class EngineInterface; } } using namespace Ingen::Shared; diff --git a/src/libs/serialisation/Makefile.am b/src/libs/serialisation/Makefile.am index 0a914222..579da448 100644 --- a/src/libs/serialisation/Makefile.am +++ b/src/libs/serialisation/Makefile.am @@ -4,7 +4,12 @@ moduledir = $(libdir)/ingen module_LTLIBRARIES = libingen_serialisation.la -libingen_serialisation_la_CXXFLAGS = -I$(top_srcdir)/ingen/src/common @RAUL_CFLAGS@ @GLIBMM_CFLAGS@ +libingen_serialisation_la_CXXFLAGS = \ + -I$(top_srcdir)/ingen/src/common \ + -I$(top_srcdir)/ingen/src/libs \ + @RAUL_CFLAGS@ \ + @GLIBMM_CFLAGS@ + libingen_serialisation_la_LDFLAGS = -no-undefined -module -avoid-version libingen_serialisation_la_LIBADD = @RAUL_LIBS@ @GLIBMM_LIBS@ diff --git a/src/libs/serialisation/Serialiser.hpp b/src/libs/serialisation/Serialiser.hpp index 23d10c82..fb1df5d0 100644 --- a/src/libs/serialisation/Serialiser.hpp +++ b/src/libs/serialisation/Serialiser.hpp @@ -46,7 +46,7 @@ namespace Shared { namespace Serialisation { -/** Serializes Ingen objects (patches, nodes, etc) to RDF. +/** Serialises Ingen objects (patches, nodes, etc) to RDF. * * \ingroup IngenClient */ diff --git a/src/libs/serialisation/serialisation.cpp b/src/libs/serialisation/serialisation.cpp index 969cf9f2..5da28529 100644 --- a/src/libs/serialisation/serialisation.cpp +++ b/src/libs/serialisation/serialisation.cpp @@ -15,8 +15,11 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include CONFIG_H_PATH +#include "module/World.hpp" #include "serialisation.hpp" #include "Loader.hpp" +#include "Serialiser.hpp" namespace Ingen { namespace Serialisation { @@ -28,6 +31,15 @@ new_loader() return new Loader(); } + +Ingen::Serialisation::Serialiser* +new_serialiser(Ingen::Shared::World* world) +{ + assert(world->rdf_world); + return new Serialiser(*world->rdf_world); +} + + } // namespace Serialisation } // namespace Ingen diff --git a/src/libs/serialisation/serialisation.hpp b/src/libs/serialisation/serialisation.hpp index f65b9c2e..8f6e8291 100644 --- a/src/libs/serialisation/serialisation.hpp +++ b/src/libs/serialisation/serialisation.hpp @@ -19,14 +19,19 @@ #define INGEN_SERIALISATION_H namespace Ingen { + +namespace Shared { class World; } + namespace Serialisation { class Loader; +class Serialiser; extern "C" { - extern Loader* new_loader(); + extern Loader* new_loader(); + extern Serialiser* new_serialiser(Ingen::Shared::World* world); } -- cgit v1.2.1