aboutsummaryrefslogtreecommitdiffstats
path: root/src/engine/Loader.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2013-01-12 23:38:03 +0000
committerDavid Robillard <d@drobilla.net>2013-01-12 23:38:03 +0000
commit1dad5b5aaa139993fe19e266d08dfc55844e6804 (patch)
treefd2bed5971853b429f1b74369a778a4d608e6925 /src/engine/Loader.cpp
parent8f048287d06afd7d3c2e90f4a503d7666a9cb6fa (diff)
downloadmachina-1dad5b5aaa139993fe19e266d08dfc55844e6804.tar.gz
machina-1dad5b5aaa139993fe19e266d08dfc55844e6804.tar.bz2
machina-1dad5b5aaa139993fe19e266d08dfc55844e6804.zip
Remove Raul::SharedPtr and switch to std::shared_ptr.
Use project local short type aliases for shared_ptr and friends. Move Raul::Disposable and Raul::Manageable into Raul::Maid. Use sets to store machina nodes and edges to avoid O(n) searches. git-svn-id: http://svn.drobilla.net/lad/trunk/machina@4939 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/engine/Loader.cpp')
-rw-r--r--src/engine/Loader.cpp37
1 files changed, 18 insertions, 19 deletions
diff --git a/src/engine/Loader.cpp b/src/engine/Loader.cpp
index 32e8d19..c206c4c 100644
--- a/src/engine/Loader.cpp
+++ b/src/engine/Loader.cpp
@@ -50,12 +50,12 @@ Loader::Loader(Raul::Forge& forge, Sord::World& rdf_world)
* @param uri URI of machine (resolvable URI to an RDF document).
* @return Loaded Machine.
*/
-SharedPtr<Machine>
+SPtr<Machine>
Loader::load(const Glib::ustring& uri)
{
using Glib::ustring;
- SharedPtr<Machine> machine;
+ SPtr<Machine> machine;
ustring document_uri = uri;
@@ -68,10 +68,10 @@ Loader::load(const Glib::ustring& uri)
cout << "[Loader] Loading " << document_uri << endl;
- machine = SharedPtr<Machine>(
+ machine = SPtr<Machine>(
new Machine(TimeUnit::beats(MACHINA_PPQN)));
- typedef std::map<Sord::Node, SharedPtr<Node> > Created;
+ typedef std::map<Sord::Node, SPtr<Node> > Created;
Created created;
Sord::Model model(_rdf_world, document_uri);
@@ -98,11 +98,10 @@ Loader::load(const Glib::ustring& uri)
!i.end(); ++i) {
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));
+ SPtr<Node> node(
+ new Node(TimeStamp(TimeUnit(TimeUnit::BEATS, MACHINA_PPQN),
+ d.get_object().to_float()),
+ true));
Sord::Iter s = model.find(node_id, rdf_type, machina_SelectorNode);
if (!s.end()) {
@@ -119,10 +118,10 @@ Loader::load(const Glib::ustring& uri)
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),
- d.get_object().to_float()),
- false));
+ SPtr<Node> node(
+ new Node(TimeStamp(TimeUnit(TimeUnit::BEATS, MACHINA_PPQN),
+ d.get_object().to_float()),
+ false));
machine->add_node(node);
created[node_id] = node;
}
@@ -143,8 +142,8 @@ Loader::load(const Glib::ustring& uri)
Created::iterator node_i
= created.find((const char*)results->get("node"));
if (node_i != created.end()) {
- SharedPtr<Node> node = node_i->second;
- const int note_num = results->get("note").to_int();
+ SPtr<Node> node = node_i->second;
+ const int note_num = results->get("note").to_int();
if (note_num >= 0 && note_num <= 127) {
node->set_enter_action(
ActionFactory::note_on((uint8_t)note_num));
@@ -179,10 +178,10 @@ Loader::load(const Glib::ustring& uri)
Created::iterator head_i = created.find(head);
if (tail_i != created.end() && head_i != created.end()) {
- const SharedPtr<Node> tail = tail_i->second;
- const SharedPtr<Node> head = head_i->second;
+ const SPtr<Node> tail = tail_i->second;
+ const SPtr<Node> head = head_i->second;
- SharedPtr<Edge> edge(new Edge(tail, head));
+ SPtr<Edge> edge(new Edge(tail, head));
edge->set_probability(prob);
tail->add_edge(edge);
@@ -197,7 +196,7 @@ Loader::load(const Glib::ustring& uri)
machine->reset(NULL, machine->time());
return machine;
} else {
- return SharedPtr<Machine>();
+ return SPtr<Machine>();
}
}