From 1dad5b5aaa139993fe19e266d08dfc55844e6804 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 12 Jan 2013 23:38:03 +0000 Subject: 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 --- src/engine/Loader.cpp | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) (limited to 'src/engine/Loader.cpp') 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 +SPtr Loader::load(const Glib::ustring& uri) { using Glib::ustring; - SharedPtr machine; + SPtr machine; ustring document_uri = uri; @@ -68,10 +68,10 @@ Loader::load(const Glib::ustring& uri) cout << "[Loader] Loading " << document_uri << endl; - machine = SharedPtr( + machine = SPtr( new Machine(TimeUnit::beats(MACHINA_PPQN))); - typedef std::map > Created; + typedef std::map > 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( - new Node( - TimeStamp(TimeUnit(TimeUnit::BEATS, MACHINA_PPQN), - d.get_object().to_float()), - true)); + SPtr 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(new Node( - TimeStamp(TimeUnit(TimeUnit::BEATS, MACHINA_PPQN), - d.get_object().to_float()), - false)); + SPtr 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_i->second; - const int note_num = results->get("note").to_int(); + SPtr 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 tail = tail_i->second; - const SharedPtr head = head_i->second; + const SPtr tail = tail_i->second; + const SPtr head = head_i->second; - SharedPtr edge(new Edge(tail, head)); + SPtr 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(); + return SPtr(); } } -- cgit v1.2.1