aboutsummaryrefslogtreecommitdiffstats
path: root/src/engine/Loader.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine/Loader.cpp')
-rw-r--r--src/engine/Loader.cpp72
1 files changed, 31 insertions, 41 deletions
diff --git a/src/engine/Loader.cpp b/src/engine/Loader.cpp
index 3b889f5..2fe161c 100644
--- a/src/engine/Loader.cpp
+++ b/src/engine/Loader.cpp
@@ -38,7 +38,7 @@ using namespace std;
namespace Machina {
-Loader::Loader(Redland::World& rdf_world)
+Loader::Loader(Sord::World& rdf_world)
: _rdf_world(rdf_world)
{
_rdf_world.add_prefix("xsd", "http://www.w3.org/2001/XMLSchema#");
@@ -62,17 +62,7 @@ Loader::load(const Glib::ustring& uri)
// If "URI" doesn't contain a colon, try to resolve as a filename
if (uri.find(":") == ustring::npos) {
- raptor_uri* base_uri = raptor_new_uri((const unsigned char*)"file:.");
- raptor_uri* document_raptor_uri = raptor_new_uri_relative_to_base(
- base_uri, (const unsigned char*)uri.c_str());
- if (document_raptor_uri) {
- document_uri = (char*)raptor_uri_as_string(document_raptor_uri);
- raptor_free_uri(document_raptor_uri);
- raptor_free_uri(base_uri);
- } else {
- raptor_free_uri(base_uri);
- return machine; // NULL
- }
+ document_uri = "file://" + document_uri;
}
const string machine_uri = string("<>");
@@ -81,38 +71,38 @@ Loader::load(const Glib::ustring& uri)
machine = SharedPtr<Machine>(new Machine(TimeUnit::beats(MACHINA_PPQN)));
- typedef std::map<Redland::Node, SharedPtr<Node> > Created;
+ typedef std::map<Sord::Node, SharedPtr<Node> > Created;
Created created;
- Redland::Model model(_rdf_world, document_uri);
+ Sord::Model model(_rdf_world, document_uri);
model.load_file(document_uri);
- Redland::Node nil;
+ Sord::Node nil;
- Redland::Resource rdf_type(_rdf_world, NS_RDF "type");
- Redland::Resource machina_SelectorNode(_rdf_world, NS_MACHINA "initialNode");
- Redland::Resource machina_node(_rdf_world, NS_MACHINA "node");
- Redland::Resource machina_initialNode(_rdf_world, NS_MACHINA "initialNode");
- Redland::Resource machina_duration(_rdf_world, NS_MACHINA "duration");
- Redland::Resource machina_edge(_rdf_world, NS_MACHINA "edge");
- Redland::Resource machina_tail(_rdf_world, NS_MACHINA "tail");
- Redland::Resource machina_head(_rdf_world, NS_MACHINA "head");
- Redland::Resource machina_probability(_rdf_world, NS_MACHINA "probability");
+ Sord::Resource rdf_type(_rdf_world, NS_RDF "type");
+ Sord::Resource machina_SelectorNode(_rdf_world, NS_MACHINA "initialNode");
+ Sord::Resource machina_node(_rdf_world, NS_MACHINA "node");
+ Sord::Resource machina_initialNode(_rdf_world, NS_MACHINA "initialNode");
+ Sord::Resource machina_duration(_rdf_world, NS_MACHINA "duration");
+ Sord::Resource machina_edge(_rdf_world, NS_MACHINA "edge");
+ Sord::Resource machina_tail(_rdf_world, NS_MACHINA "tail");
+ Sord::Resource machina_head(_rdf_world, NS_MACHINA "head");
+ Sord::Resource machina_probability(_rdf_world, NS_MACHINA "probability");
- Redland::Node machine_node = Redland::Resource(_rdf_world, ".");
+ Sord::Node machine_node = Sord::Resource(_rdf_world, ".");
/* Get initial nodes */
- for (Redland::Iter i = model.find(machine_node, machina_initialNode, nil);
+ for (Sord::Iter i = model.find(machine_node, machina_initialNode, nil);
!i.end(); ++i) {
- const Redland::Node& node_id = i.get_object();
- Redland::Iter d = model.find(node_id, machina_duration, nil);
+ const Sord::Node& node_id = i.get_object();
+ Sord::Iter d = model.find(node_id, machina_duration, nil);
SharedPtr<Node> node(
new Node(
TimeStamp(TimeUnit(TimeUnit::BEATS, MACHINA_PPQN),
d.get_object().to_float()),
true));
- Redland::Iter s = model.find(node_id, rdf_type, machina_SelectorNode);
+ Sord::Iter s = model.find(node_id, rdf_type, machina_SelectorNode);
if (!s.end()) {
node->set_selector(true);
}
@@ -122,10 +112,10 @@ Loader::load(const Glib::ustring& uri)
}
/* Get remaining (non-initial) nodes */
- for (Redland::Iter i = model.find(machine_node, machina_node, nil);
+ for (Sord::Iter i = model.find(machine_node, machina_node, nil);
!i.end(); ++i) {
- const Redland::Node& node_id = i.get_object();
- Redland::Iter d = model.find(node_id, machina_duration, nil);
+ const Sord::Node& node_id = i.get_object();
+ Sord::Iter d = model.find(node_id, machina_duration, nil);
if (created.find(node_id) == created.end()) {
SharedPtr<Node> node(new Node(
TimeStamp(TimeUnit(TimeUnit::BEATS, MACHINA_PPQN),
@@ -165,16 +155,16 @@ Loader::load(const Glib::ustring& uri)
#endif
/* Get edges */
- for (Redland::Iter i = model.find(machine_node, machina_edge, nil);
+ for (Sord::Iter i = model.find(machine_node, machina_edge, nil);
!i.end(); ++i) {
- Redland::Node edge = i.get_object();
- Redland::Iter t = model.find(edge, machina_tail, nil);
- Redland::Iter h = model.find(edge, machina_head, nil);
- Redland::Iter p = model.find(edge, machina_probability, nil);
-
- Redland::Node tail = t.get_object();
- Redland::Node head = h.get_object();
- Redland::Node probability = p.get_object();
+ Sord::Node edge = i.get_object();
+ Sord::Iter t = model.find(edge, machina_tail, nil);
+ Sord::Iter h = model.find(edge, machina_head, nil);
+ Sord::Iter p = model.find(edge, machina_probability, nil);
+
+ Sord::Node tail = t.get_object();
+ Sord::Node head = h.get_object();
+ Sord::Node probability = p.get_object();
float prob = probability.to_float();