summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/libs/client/Loader.cpp62
-rw-r--r--src/libs/client/Loader.h45
-rw-r--r--src/progs/ingenuity/App.cpp1
-rw-r--r--src/progs/ingenuity/LoadPatchWindow.cpp1
-rw-r--r--src/progs/ingenuity/ThreadedLoader.cpp7
-rw-r--r--src/progs/ingenuity/ThreadedLoader.h16
-rw-r--r--src/progs/patch_loader/patch_loader.cpp4
7 files changed, 62 insertions, 74 deletions
diff --git a/src/libs/client/Loader.cpp b/src/libs/client/Loader.cpp
index 0efc07c9..8ebea580 100644
--- a/src/libs/client/Loader.cpp
+++ b/src/libs/client/Loader.cpp
@@ -20,34 +20,30 @@
#include <raul/RDFModel.h>
#include <raul/RDFQuery.h>
#include "Loader.h"
-#include "ModelEngineInterface.h"
+#include "interface/EngineInterface.h"
+using namespace std;
using namespace Raul;
+using namespace Ingen::Shared;
namespace Ingen {
-namespace Client {
+namespace Serialisation {
-Loader::Loader(SharedPtr<ModelEngineInterface> engine, Raul::RDF::World* rdf_world)
- : _engine(engine)
- , _rdf_world(rdf_world)
-{
-}
-
-
-/** Load (create) all objects from an RDF into the engine.
+/** 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(Raul::RDF::World* rdf_world,
- const Glib::ustring& document_uri,
- boost::optional<Path> parent,
- string patch_name,
- Glib::ustring patch_uri,
- MetadataMap data)
+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
@@ -99,7 +95,7 @@ Loader::load(Raul::RDF::World* rdf_world,
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);
+ engine->create_patch(patch_path, patch_poly);
/* Load (plugin) nodes */
@@ -123,7 +119,7 @@ Loader::load(Raul::RDF::World* rdf_world,
const Path node_path = patch_path.base() + (string)name;
if (created.find(node_path) == created.end()) {
- _engine->create_node(node_path, plugin, false);
+ engine->create_node(node_path, plugin, false);
created[node_path] = true;
}
@@ -131,7 +127,7 @@ Loader::load(Raul::RDF::World* rdf_world,
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()));
+ engine->set_metadata(patch_path.base() + name, floatkey, Atom(val_node.to_float()));
}
@@ -154,7 +150,7 @@ Loader::load(Raul::RDF::World* rdf_world,
const Path subpatch_path = patch_path.base() + (string)name;
if (created.find(subpatch_path) == created.end()) {
- load(rdf_world, document_uri, patch_path, name, patch);
+ load(engine, rdf_world, document_uri, patch_path, name, patch);
created[subpatch_path] = true;
}
}
@@ -184,7 +180,7 @@ Loader::load(Raul::RDF::World* rdf_world,
Path port_path = patch_path.base() + (const string&)node_name +"/"+ (const string&)port_name;
- _engine->set_port_value(port_path, val);
+ engine->set_port_value(port_path, val);
}
@@ -206,7 +202,7 @@ Loader::load(Raul::RDF::World* rdf_world,
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 type = rdf_world->qualify((*i)["type"].to_string());
string datatype = (*i)["datatype"].to_string();
const Path port_path = patch_path.base() + (string)name;
@@ -214,19 +210,19 @@ Loader::load(Raul::RDF::World* rdf_world,
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);
+ 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());
+ engine->set_port_value(patch_path.base() + name, val_node.to_float());
- string floatkey = _rdf_world->qualify((*i)["floatkey"].to_string());
+ 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()));
+ engine->set_metadata(patch_path.base() + name, floatkey, Atom(val_node.to_float()));
}
created.clear();
@@ -257,7 +253,7 @@ Loader::load(Raul::RDF::World* rdf_world,
cerr << patch_path << " 1 CONNECTION: " << src_port << " -> " << dst_port << endl;
- _engine->connect(src_port, dst_port);
+ engine->connect(src_port, dst_port);
}
@@ -283,7 +279,7 @@ Loader::load(Raul::RDF::World* rdf_world,
cerr << patch_path << " 2 CONNECTION: " << src_port << " -> " << dst_port << endl;
- _engine->connect(src_port, dst_port);
+ engine->connect(src_port, dst_port);
}
@@ -309,7 +305,7 @@ Loader::load(Raul::RDF::World* rdf_world,
cerr << patch_path << " 3 CONNECTION: " << src_port << " -> " << dst_port << endl;
- _engine->connect(src_port, dst_port);
+ engine->connect(src_port, dst_port);
}
@@ -329,18 +325,18 @@ Loader::load(Raul::RDF::World* rdf_world,
RDF::Node val_node = (*i)["floatval"];
if (floatkey != "" && val_node.is_float())
- _engine->set_metadata(patch_path, floatkey, Atom(val_node.to_float()));
+ engine->set_metadata(patch_path, floatkey, Atom(val_node.to_float()));
}
// Set passed metadata last to override any loaded values
- for (MetadataMap::const_iterator i = data.begin(); i != data.end(); ++i)
- _engine->set_metadata(patch_path, i->first, i->second);
+ for (Metadata::const_iterator i = data.begin(); i != data.end(); ++i)
+ engine->set_metadata(patch_path, i->first, i->second);
return true;
}
-} // namespace Client
+} // namespace Serialisation
} // namespace Ingen
diff --git a/src/libs/client/Loader.h b/src/libs/client/Loader.h
index 371e7065..74aa7cbb 100644
--- a/src/libs/client/Loader.h
+++ b/src/libs/client/Loader.h
@@ -18,41 +18,32 @@
#ifndef LOADER_H
#define LOADER_H
-#include <boost/optional.hpp>
+#include <string>
+#include <map>
#include <glibmm/ustring.h>
-#include "raul/SharedPtr.h"
-#include "raul/Path.h"
-#include "ObjectModel.h"
+#include <boost/optional.hpp>
+#include <raul/SharedPtr.h>
+#include <raul/Path.h>
-namespace Raul { namespace RDF { class World; } }
+namespace Raul { class Atom; namespace RDF { class World; } }
+namespace Ingen { namespace Shared { class EngineInterface; } }
namespace Ingen {
-namespace Client {
-
-class ModelEngineInterface;
-
-
-/** Loads objects (patches, nodes, etc) into the engine from RDF.
- */
-class Loader {
-public:
- Loader(SharedPtr<ModelEngineInterface> engine, Raul::RDF::World* rdf_world);
+namespace Serialisation {
- bool load(Raul::RDF::World* world,
- const Glib::ustring& uri,
- boost::optional<Path> parent,
- string patch_name,
- Glib::ustring patch_uri = "",
- MetadataMap initial_data = MetadataMap());
+typedef std::map<std::string, Raul::Atom> Metadata;
-private:
- //string _patch_search_path;
- SharedPtr<ModelEngineInterface> _engine;
- Raul::RDF::World* _rdf_world;
-};
+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 Client
+} // namespace Serialisation
} // namespace Ingen
#endif // LOADER_H
diff --git a/src/progs/ingenuity/App.cpp b/src/progs/ingenuity/App.cpp
index 8ffcd710..0e726db9 100644
--- a/src/progs/ingenuity/App.cpp
+++ b/src/progs/ingenuity/App.cpp
@@ -40,6 +40,7 @@
#include "Store.h"
#include "ThreadedLoader.h"
#include "WindowFactory.h"
+#include "ModelEngineInterface.h"
#ifdef HAVE_LASH
#include "LashController.h"
#endif
diff --git a/src/progs/ingenuity/LoadPatchWindow.cpp b/src/progs/ingenuity/LoadPatchWindow.cpp
index aba427e9..cc7ff7bd 100644
--- a/src/progs/ingenuity/LoadPatchWindow.cpp
+++ b/src/progs/ingenuity/LoadPatchWindow.cpp
@@ -25,6 +25,7 @@
#include "ModelEngineInterface.h"
#include "ThreadedLoader.h"
+using namespace Ingen::Serialisation;
using boost::optional;
namespace Ingenuity {
diff --git a/src/progs/ingenuity/ThreadedLoader.cpp b/src/progs/ingenuity/ThreadedLoader.cpp
index 118d252f..bf195dce 100644
--- a/src/progs/ingenuity/ThreadedLoader.cpp
+++ b/src/progs/ingenuity/ThreadedLoader.cpp
@@ -27,8 +27,8 @@ namespace Ingenuity {
ThreadedLoader::ThreadedLoader(SharedPtr<ModelEngineInterface> engine)
- : _deprecated_loader(engine)
- , _loader(engine, App::instance().rdf_world())
+ : _engine(engine)
+ , _deprecated_loader(engine)
, _serializer(*App::instance().rdf_world())
{
// FIXME: rework this so the thread is only present when it's doing something (save mem)
@@ -78,7 +78,8 @@ ThreadedLoader::load_patch(bool merge,
false)));
} else {
_events.push_back(sigc::hide_return(sigc::bind(
- sigc::mem_fun(_loader, &Loader::load),
+ sigc::ptr_fun(&Ingen::Serialisation::load),
+ App::instance().engine(),
App::instance().rdf_world(),
data_base_uri,
engine_parent,
diff --git a/src/progs/ingenuity/ThreadedLoader.h b/src/progs/ingenuity/ThreadedLoader.h
index 4cab4acb..bf2c2ed5 100644
--- a/src/progs/ingenuity/ThreadedLoader.h
+++ b/src/progs/ingenuity/ThreadedLoader.h
@@ -22,15 +22,15 @@
#include <list>
#include <cassert>
#include <boost/optional/optional.hpp>
-#include "raul/Thread.h"
-#include "raul/Slave.h"
-#include "raul/Mutex.h"
-#include "raul/Condition.h"
+#include <raul/Thread.h>
+#include <raul/Slave.h>
+#include <raul/Mutex.h>
+#include <raul/Condition.h>
#include "ModelEngineInterface.h"
-#include "ObjectModel.h"
#include "Serializer.h"
#include "DeprecatedLoader.h"
#include "Loader.h"
+#include "PatchModel.h"
using std::string;
using std::list;
using boost::optional;
@@ -57,9 +57,6 @@ public:
ThreadedLoader(SharedPtr<ModelEngineInterface> engine);
~ThreadedLoader();
- //Loader& loader() const { return *_loader; }
- //Serializer& serializer() const { return *_serializer; }
-
// FIXME: there's a pattern here....
// (same core interface as Loader/Serializer)
@@ -82,8 +79,9 @@ private:
void _whipped();
+ SharedPtr<ModelEngineInterface> _engine;
+
DeprecatedLoader _deprecated_loader;
- Loader _loader;
Serializer _serializer;
Raul::Mutex _mutex;
list<Closure> _events;
diff --git a/src/progs/patch_loader/patch_loader.cpp b/src/progs/patch_loader/patch_loader.cpp
index f011d308..cc3c1903 100644
--- a/src/progs/patch_loader/patch_loader.cpp
+++ b/src/progs/patch_loader/patch_loader.cpp
@@ -61,7 +61,6 @@ int main(int argc, char** argv)
rdf_world.add_prefix("doap", "http://usefulinc.com/ns/doap#");
SharedPtr<OSCModelEngineInterface> engine(new OSCModelEngineInterface(engine_url));
- Loader loader(engine, &rdf_world);
/* Connect to engine */
engine->attach(-1, client_port);
@@ -81,7 +80,8 @@ int main(int argc, char** argv)
for (uint i=0; i < args_info.inputs_num; ++i) {
cerr << "FIXME: load patch under root" << endl;
cerr << "Load " << args_info.inputs[i] << endl;
- loader.load(&rdf_world, string("file:") + args_info.inputs[i], Path("/"), "");
+ Ingen::Serialisation::load(engine, &rdf_world,
+ string("file:") + args_info.inputs[i], Path("/"), "");
}
return 0;