From 35a5d92cfcf6815553a0939c3e2bf77c1108fd31 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 30 Sep 2006 06:47:00 +0000 Subject: Work on RDF serialization (only (partial) saving so far). git-svn-id: http://svn.drobilla.net/lad/ingen@146 a436a847-0d15-0410-975c-d299462d15a1 --- src/progs/ingenuity/Loader.cpp | 42 +++++++++++++++++++-------------- src/progs/ingenuity/Loader.h | 16 ++++++++----- src/progs/ingenuity/Makefile.am | 11 +++++---- src/progs/ingenuity/NodeModule.cpp | 12 +++++----- src/progs/ingenuity/PatchCanvas.cpp | 8 +++---- src/progs/ingenuity/PatchPortModule.cpp | 16 ++++++------- 6 files changed, 58 insertions(+), 47 deletions(-) (limited to 'src/progs/ingenuity') diff --git a/src/progs/ingenuity/Loader.cpp b/src/progs/ingenuity/Loader.cpp index 59d718c7..485e450d 100644 --- a/src/progs/ingenuity/Loader.cpp +++ b/src/progs/ingenuity/Loader.cpp @@ -18,7 +18,7 @@ #include #include #include -#include "PatchLibrarian.h" +#include "Serializer.h" #include "PatchModel.h" using std::cout; using std::endl; @@ -26,9 +26,9 @@ namespace Ingenuity { Loader::Loader(CountedPtr engine) -: _patch_librarian(new PatchLibrarian(engine)) +: _serializer(new Serializer(engine)) { - assert(_patch_librarian != NULL); + assert(_serializer != NULL); // FIXME: rework this so the thread is only present when it's doing something (save mem) start(); @@ -37,7 +37,7 @@ Loader::Loader(CountedPtr engine) Loader::~Loader() { - delete _patch_librarian; + delete _serializer; } @@ -45,12 +45,12 @@ void Loader::_whipped() { _mutex.lock(); + + while ( ! _events.empty() ) { + _events.front()(); + _events.pop_front(); + } - Closure& ev = _event; - ev(); - ev.disconnect(); - - _cond.signal(); _mutex.unlock(); } @@ -65,23 +65,29 @@ Loader::load_patch(const string& filename, { _mutex.lock(); - _event = sigc::hide_return(sigc::bind( - sigc::mem_fun(_patch_librarian, &PatchLibrarian::load_patch), - filename, parent_path, name, poly, initial_data, existing)); + _events.push_back(sigc::hide_return(sigc::bind( + sigc::mem_fun(_serializer, &Serializer::load_patch), + filename, parent_path, name, poly, initial_data, existing))); - whip(); - - _cond.wait(_mutex); _mutex.unlock(); + + whip(); } void Loader::save_patch(CountedPtr model, const string& filename, bool recursive) { - cerr << "FIXME: (loader) save patch\n"; - //cout << "[Loader] Saving patch " << filename << endl; - //set_event(new SavePatchEvent(m_patch_librarian, model, filename, recursive)); + _mutex.lock(); + + _events.push_back(sigc::hide_return(sigc::bind( + sigc::mem_fun(_serializer, &Serializer::save_patch), + model, filename, recursive))); + + _mutex.unlock(); + + whip(); } + } // namespace Ingenuity diff --git a/src/progs/ingenuity/Loader.h b/src/progs/ingenuity/Loader.h index a33945a1..7459378e 100644 --- a/src/progs/ingenuity/Loader.h +++ b/src/progs/ingenuity/Loader.h @@ -18,6 +18,7 @@ #define LOADERTHREAD_H #include +#include #include #include "util/Thread.h" #include "util/Slave.h" @@ -26,9 +27,10 @@ #include "ModelEngineInterface.h" #include "ObjectModel.h" using std::string; +using std::list; namespace Ingen { namespace Client { - class PatchLibrarian; + class Serializer; class PatchModel; } } using namespace Ingen::Client; @@ -42,6 +44,9 @@ namespace Ingenuity { * blocking everything else, so the app can respond to the incoming events * caused as a result of the patch loading, while the patch loads. * + * Implemented as a slave with a list of closures (events) which processes + * all events in the (mutex protected) list each time it's whipped. + * * \ingroup Ingenuity */ class Loader : public Slave @@ -50,7 +55,7 @@ public: Loader(CountedPtr engine); ~Loader(); - PatchLibrarian& librarian() { return *_patch_librarian; } + Serializer& serializer() const { return *_serializer; } void load_patch(const string& filename, const string& parent_path, @@ -69,10 +74,9 @@ private: void _whipped(); - PatchLibrarian* const _patch_librarian; - Mutex _mutex; - Condition _cond; - Closure _event; + Serializer* const _serializer; + Mutex _mutex; + list _events; }; diff --git a/src/progs/ingenuity/Makefile.am b/src/progs/ingenuity/Makefile.am index 48b53f33..3044a2fc 100644 --- a/src/progs/ingenuity/Makefile.am +++ b/src/progs/ingenuity/Makefile.am @@ -6,14 +6,15 @@ MAINTAINERCLEANFILES = Makefile.in sharefilesdir = $(pkgdatadir) dist_sharefiles_DATA = ingenuity.glade om-icon.png -AM_CXXFLAGS = -DGTK_DISABLE_DEPRECATED -DGDK_DISABLE_DEPRECATED -I$(top_srcdir)/src/common -I$(top_srcdir)/src/libs/client -DPKGDATADIR=\"$(pkgdatadir)\" @GTKMM_CFLAGS@ @LIBGLADEMM_CFLAGS@ @GNOMECANVASMM_CFLAGS@ @LOSC_CFLAGS@ @LASH_CFLAGS@ @FLOWCANVAS_CFLAGS@ -ingenuity_LDADD = @GTKMM_LIBS@ @LIBGLADEMM_LIBS@ @GNOMECANVASMM_LIBS@ @LOSC_LIBS@ @LASH_LIBS@ @FLOWCANVAS_LIBS@ ../../libs/client/libomclient.la -ingenuity_DEPENDENCIES = ../../libs/client/libomclient.la +ingenuity_CXXFLAGS = -DGTK_DISABLE_DEPRECATED -DGDK_DISABLE_DEPRECATED -I$(top_srcdir)/src/common -I$(top_srcdir)/src/libs/client -DPKGDATADIR=\"$(pkgdatadir)\" @GTKMM_CFLAGS@ @LIBGLADEMM_CFLAGS@ @GNOMECANVASMM_CFLAGS@ @LOSC_CFLAGS@ @LASH_CFLAGS@ @FLOWCANVAS_CFLAGS@ +ingenuity_LDADD = @GTKMM_LIBS@ @LIBGLADEMM_LIBS@ @GNOMECANVASMM_LIBS@ @LOSC_LIBS@ @LASH_LIBS@ @FLOWCANVAS_LIBS@ ../../libs/client/libingenclient.la +ingenuity_DEPENDENCIES = ../../libs/client/libingenclient.la # FIXME: make engine have a separate include dir if MONOLITHIC_INGENUITY -AM_CXXFLAGS += -I$(top_srcdir)/src/libs -ingenuity_LDADD += @JACK_LIBS@ @ALSA_LIBS@ @LASH_LIBS@ @SLV2_LIBS@ -lrt ../../libs/engine/libingen.la +ingenuity_CXXFLAGS += -I$(top_srcdir)/src/libs +#ingenuity_LDADD += @JACK_LIBS@ @ALSA_LIBS@ @LASH_LIBS@ @SLV2_LIBS@ -lrt ../../libs/engine/libingen.la +ingenuity_LDADD += ../../libs/engine/libingen.la ingenuity_DEPENDENCIES += ../../libs/engine/libingen.la endif diff --git a/src/progs/ingenuity/NodeModule.cpp b/src/progs/ingenuity/NodeModule.cpp index 8545e493..29af857e 100644 --- a/src/progs/ingenuity/NodeModule.cpp +++ b/src/progs/ingenuity/NodeModule.cpp @@ -104,13 +104,13 @@ NodeModule::store_location() const float x = static_cast(property_x()); const float y = static_cast(property_y()); - const Atom& existing_x = m_node->get_metadata("module-x"); - const Atom& existing_y = m_node->get_metadata("module-y"); + const Atom& existing_x = m_node->get_metadata("ingenuity:canvas-x"); + const Atom& existing_y = m_node->get_metadata("ingenuity:canvas-y"); if (existing_x.type() != Atom::FLOAT || existing_y.type() != Atom::FLOAT || existing_x.get_float() != x || existing_y.get_float() != y) { - App::instance().engine()->set_metadata(m_node->path(), "module-x", Atom(x)); - App::instance().engine()->set_metadata(m_node->path(), "module-y", Atom(y)); + App::instance().engine()->set_metadata(m_node->path(), "ingenuity:canvas-x", Atom(x)); + App::instance().engine()->set_metadata(m_node->path(), "ingenuity:canvas-y", Atom(y)); } } @@ -126,9 +126,9 @@ NodeModule::on_right_click(GdkEventButton* event) void NodeModule::metadata_update(const string& key, const Atom& value) { - if (key == "module-x" && value.type() == Atom::FLOAT) + if (key == "ingenuity:canvas-x" && value.type() == Atom::FLOAT) move_to(value.get_float(), property_y()); - else if (key == "module-y" && value.type() == Atom::FLOAT) + else if (key == "ingenuity:canvas-y" && value.type() == Atom::FLOAT) move_to(property_x(), value.get_float()); } diff --git a/src/progs/ingenuity/PatchCanvas.cpp b/src/progs/ingenuity/PatchCanvas.cpp index 9419b252..707b8856 100644 --- a/src/progs/ingenuity/PatchCanvas.cpp +++ b/src/progs/ingenuity/PatchCanvas.cpp @@ -217,9 +217,9 @@ PatchCanvas::connect(const LibFlowCanvas::Port* src_port, const LibFlowCanvas::P CountedPtr pm(new PluginModel(PluginModel::Internal, "", "midi_control_in", "")); CountedPtr nm(new NodeModel(pm, m_patch->path().base() + src->name() + "-" + dst->name(), false)); - nm->set_metadata("module-x", Atom((float) + nm->set_metadata("canvas-x", Atom((float) (dst->module()->property_x() - dst->module()->width() - 20))); - nm->set_metadata("module-y", Atom((float) + nm->set_metadata("canvas-y", Atom((float) (dst->module()->property_y()))); App::instance().engine()->create_node_from_model(nm.get()); App::instance().engine()->connect(src->model()->path(), nm->path() + "/MIDI_In"); @@ -332,8 +332,8 @@ PatchCanvas::get_initial_data() { MetadataMap result; - result["module-x"] = Atom((float)m_last_click_x); - result["module-y"] = Atom((float)m_last_click_y); + result["ingenuity:canvas-x"] = Atom((float)m_last_click_x); + result["ingenuity:canvas-y"] = Atom((float)m_last_click_y); return result; } diff --git a/src/progs/ingenuity/PatchPortModule.cpp b/src/progs/ingenuity/PatchPortModule.cpp index 369a04b1..8843882b 100644 --- a/src/progs/ingenuity/PatchPortModule.cpp +++ b/src/progs/ingenuity/PatchPortModule.cpp @@ -51,8 +51,8 @@ PatchPortModule::PatchPortModule(PatchCanvas* canvas, CountedPtr port resize(); - const Atom& x_atom = port->get_metadata("module-x"); - const Atom& y_atom = port->get_metadata("module-y"); + const Atom& x_atom = port->get_metadata("ingenuity:canvas-x"); + const Atom& y_atom = port->get_metadata("ingenuity:canvas-y"); if (x_atom && y_atom && x_atom.type() == Atom::FLOAT && y_atom.type() == Atom::FLOAT) { move_to(x_atom.get_float(), y_atom.get_float()); @@ -73,13 +73,13 @@ PatchPortModule::store_location() const float x = static_cast(property_x()); const float y = static_cast(property_y()); - const Atom& existing_x = m_port->get_metadata("module-x"); - const Atom& existing_y = m_port->get_metadata("module-y"); + const Atom& existing_x = m_port->get_metadata("ingenuity:canvas-x"); + const Atom& existing_y = m_port->get_metadata("ingenuity:canvas-y"); if (existing_x.type() != Atom::FLOAT || existing_y.type() != Atom::FLOAT || existing_x.get_float() != x || existing_y.get_float() != y) { - App::instance().engine()->set_metadata(m_port->path(), "module-x", Atom(x)); - App::instance().engine()->set_metadata(m_port->path(), "module-y", Atom(y)); + App::instance().engine()->set_metadata(m_port->path(), "ingenuity:canvas-x", Atom(x)); + App::instance().engine()->set_metadata(m_port->path(), "ingenuity:canvas-y", Atom(y)); } } @@ -87,9 +87,9 @@ PatchPortModule::store_location() void PatchPortModule::metadata_update(const string& key, const Atom& value) { - if (key == "module-x" && value.type() == Atom::FLOAT) + if (key == "ingenuity:canvas-x" && value.type() == Atom::FLOAT) move_to(value.get_float(), property_y()); - else if (key == "module-y" && value.type() == Atom::FLOAT) + else if (key == "ingenuity:canvas-y" && value.type() == Atom::FLOAT) move_to(property_x(), value.get_float()); } -- cgit v1.2.1