summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2008-08-17 23:35:43 +0000
committerDavid Robillard <d@drobilla.net>2008-08-17 23:35:43 +0000
commit77d608d6ca282795b348a615932b1abbd47b0472 (patch)
treebc714c316e0611ea5daa8c7f77a0cff2f57cab59 /src
parent14401d11e598651e7caf39cce884362e58ef5941 (diff)
downloadingen-77d608d6ca282795b348a615932b1abbd47b0472.tar.gz
ingen-77d608d6ca282795b348a615932b1abbd47b0472.tar.bz2
ingen-77d608d6ca282795b348a615932b1abbd47b0472.zip
Copy/paste of patch ports.
git-svn-id: http://svn.drobilla.net/lad/ingen@1427 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r--src/libs/gui/PatchPortModule.cpp21
-rw-r--r--src/libs/gui/PatchPortModule.hpp1
-rw-r--r--src/libs/serialisation/Parser.cpp57
-rw-r--r--src/libs/serialisation/Parser.hpp9
-rw-r--r--src/libs/shared/Builder.cpp2
-rw-r--r--src/libs/shared/ClashAvoider.cpp2
6 files changed, 80 insertions, 12 deletions
diff --git a/src/libs/gui/PatchPortModule.cpp b/src/libs/gui/PatchPortModule.cpp
index ec083c1b..b23ac5c7 100644
--- a/src/libs/gui/PatchPortModule.cpp
+++ b/src/libs/gui/PatchPortModule.cpp
@@ -129,10 +129,29 @@ PatchPortModule::set_variable(const string& key, const Atom& value)
void
PatchPortModule::set_property(const string& key, const Atom& value)
{
- if (key == "ingen:polyphonic" && value.type() == Atom::BOOL)
+ if (key == "ingen:polyphonic" && value.type() == Atom::BOOL) {
set_stacked_border(value.get_bool());
+ } else if (key == "ingen:selected" && value.type() == Atom::BOOL) {
+ if (value.get_bool() != selected()) {
+ if (value.get_bool())
+ _canvas.lock()->select_item(shared_from_this());
+ else
+ _canvas.lock()->unselect_item(shared_from_this());
+ }
+ }
+}
+
+
+void
+PatchPortModule::set_selected(bool b)
+{
+ if (b != selected()) {
+ Module::set_selected(b);
+ App::instance().engine()->set_property(_port->path(), "ingen:selected", b);
+ }
}
+
} // namespace GUI
} // namespace Ingen
diff --git a/src/libs/gui/PatchPortModule.hpp b/src/libs/gui/PatchPortModule.hpp
index bdf9c6d5..d6715834 100644
--- a/src/libs/gui/PatchPortModule.hpp
+++ b/src/libs/gui/PatchPortModule.hpp
@@ -62,6 +62,7 @@ protected:
PatchPortModule(boost::shared_ptr<PatchCanvas> canvas, SharedPtr<PortModel> port);
void create_menu();
+ void set_selected(bool b);
void set_variable(const std::string& predicate, const Raul::Atom& value);
void set_property(const std::string& predicate, const Raul::Atom& value);
diff --git a/src/libs/serialisation/Parser.cpp b/src/libs/serialisation/Parser.cpp
index c9592fc4..9ddfb601 100644
--- a/src/libs/serialisation/Parser.cpp
+++ b/src/libs/serialisation/Parser.cpp
@@ -120,6 +120,7 @@ Parser::parse(
//if (object_uri)
// object_uri = uri_relative_to_base(base_uri, object_uri.get());
+ const Redland::Node::Type res = Redland::Node::RESOURCE;
Glib::ustring query_str;
if (object_uri)
query_str = Glib::ustring("SELECT DISTINCT ?class WHERE { <") + object_uri.get() + "> a ?class . }";
@@ -129,11 +130,12 @@ Parser::parse(
Redland::Query query(*world->rdf_world, query_str);
Redland::Query::Results results = query.run(*world->rdf_world, model, base_uri);
- const Redland::Node patch_class(*world->rdf_world, Redland::Node::RESOURCE, NS_INGEN "Patch");
- const Redland::Node node_class(*world->rdf_world, Redland::Node::RESOURCE, NS_INGEN "Node");
- const Redland::Node port_class(*world->rdf_world, Redland::Node::RESOURCE, NS_INGEN "Port");
+ const Redland::Node patch_class(*world->rdf_world, res, NS_INGEN "Patch");
+ const Redland::Node node_class(*world->rdf_world, res, NS_INGEN "Node");
+ const Redland::Node in_port_class(*world->rdf_world, res, NS_INGEN "InputPort");
+ const Redland::Node out_port_class(*world->rdf_world, res, NS_INGEN "OutputPort");
- const Redland::Node subject_uri(*world->rdf_world, Redland::Node::RESOURCE,
+ const Redland::Node subject_uri(*world->rdf_world, res,
(object_uri ? object_uri.get() : "http://example.org"));
bool ret = false;
@@ -141,7 +143,8 @@ Parser::parse(
for (Redland::Query::Results::iterator i = results.begin(); i != results.end(); ++i) {
const Redland::Node subject = (object_uri ? subject_uri : (*i)["subject"]);
const Redland::Node rdf_class = (*i)["class"];
- if (rdf_class == patch_class || rdf_class == node_class || rdf_class == port_class) {
+ if (rdf_class == patch_class || rdf_class == node_class ||
+ rdf_class == in_port_class || rdf_class == out_port_class) {
Path path = parse_path(world, model, base_uri, subject.to_c_string(), parent, symbol);
if (rdf_class == patch_class) {
ret = parse_patch(world, target, model, base_uri, subject.to_c_string(), path, data);
@@ -150,8 +153,9 @@ Parser::parse(
} else if (rdf_class == node_class) {
ret = parse_node(world, target, model,
base_uri, Glib::ustring("<") + subject.to_c_string() + ">", path, data);
- } else if (rdf_class == port_class) {
- cout << "*** TODO: PARSE PORT" << endl;
+ } else if (rdf_class == in_port_class || rdf_class == out_port_class) {
+ ret = parse_port(world, target, model,
+ base_uri, Glib::ustring("<") + subject.to_c_string() + ">", path, data);
}
if (ret == false) {
cerr << "Failed to parse object " << object_uri << endl;
@@ -429,6 +433,45 @@ Parser::parse_node(
bool
+Parser::parse_port(
+ Ingen::Shared::World* world,
+ Ingen::Shared::CommonInterface* target,
+ Redland::Model& model,
+ const Glib::ustring& base_uri,
+ const Glib::ustring& subject,
+ Raul::Path path,
+ boost::optional<GraphObject::Variables> data)
+{
+ Redland::Query query(*world->rdf_world, Glib::ustring(
+ "SELECT DISTINCT ?type ?datatype ?value WHERE {\n") +
+ subject + " a ?type ;\n"
+ " a ?datatype .\n"
+ " FILTER (?type != ?datatype && ((?type = ingen:InputPort) || (?type = ingen:OutputPort)))\n"
+ "OPTIONAL { " + subject + " ingen:value ?value . }\n"
+ "}");
+
+ Redland::Query::Results results = query.run(*world->rdf_world, model, base_uri);
+ world->rdf_world->mutex().lock();
+
+ for (Redland::Query::Results::iterator i = results.begin(); i != results.end(); ++i) {
+ const string type = world->rdf_world->qualify((*i)["type"].to_string());
+ const string datatype = world->rdf_world->qualify((*i)["datatype"].to_string());
+
+ bool is_output = (type == "ingen:OutputPort");
+ // FIXME: read index
+ target->new_port(path, 0, datatype, is_output);
+
+ const Redland::Node& val_node = (*i)["value"];
+ if (val_node.to_string() != "")
+ target->set_port_value(path, AtomRDF::node_to_atom(val_node));
+ }
+ world->rdf_world->mutex().unlock();
+
+ return parse_variables(world, target, model, base_uri, subject, path, data);
+}
+
+
+bool
Parser::parse_connections(
Ingen::Shared::World* world,
Ingen::Shared::CommonInterface* target,
diff --git a/src/libs/serialisation/Parser.hpp b/src/libs/serialisation/Parser.hpp
index 1bc7245e..3a99b7da 100644
--- a/src/libs/serialisation/Parser.hpp
+++ b/src/libs/serialisation/Parser.hpp
@@ -98,6 +98,15 @@ private:
const Glib::ustring& subject,
Raul::Path path,
boost::optional<GraphObject::Variables> data);
+
+ bool parse_port(
+ Ingen::Shared::World* world,
+ Ingen::Shared::CommonInterface* target,
+ Redland::Model& model,
+ const Glib::ustring& base_uri,
+ const Glib::ustring& subject,
+ Raul::Path path,
+ boost::optional<GraphObject::Variables> data=boost::optional<GraphObject::Variables>());
bool parse_variables(
Ingen::Shared::World* world,
diff --git a/src/libs/shared/Builder.cpp b/src/libs/shared/Builder.cpp
index 2b5e954c..bc8fb21c 100644
--- a/src/libs/shared/Builder.cpp
+++ b/src/libs/shared/Builder.cpp
@@ -45,8 +45,6 @@ Builder::build(SharedPtr<const GraphObject> object)
build_object(object);
for (Patch::Connections::const_iterator i = patch->connections().begin();
i != patch->connections().end(); ++i) {
- cout << "BUILDER CONNECTION: " <<(*i)->src_port_path()
- << " -> " << (*i)->dst_port_path() << endl;
_interface.connect((*i)->src_port_path(), (*i)->dst_port_path());
}
return;
diff --git a/src/libs/shared/ClashAvoider.cpp b/src/libs/shared/ClashAvoider.cpp
index 3647f023..bd169d4b 100644
--- a/src/libs/shared/ClashAvoider.cpp
+++ b/src/libs/shared/ClashAvoider.cpp
@@ -38,7 +38,6 @@ ClashAvoider::map_path(const Raul::Path& in)
// No clash, use symbol unmodified
if (s == _store.end()) {
InsertRecord i = _symbol_map.insert(make_pair(in, in));
- cout << i.first->second << endl;
return i.first->second;
} else {
@@ -66,7 +65,6 @@ ClashAvoider::map_path(const Raul::Path& in)
ss << in << "_" << offset;
InsertRecord i = _symbol_map.insert(make_pair(in, ss.str()));
assert(_store.find(i.first->second) == _store.end());
- cout << i.first->second << endl;
return i.first->second;
}
}