aboutsummaryrefslogtreecommitdiffstats
path: root/src/engine/machina/Machine.hpp
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/machina/Machine.hpp
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/machina/Machine.hpp')
-rw-r--r--src/engine/machina/Machine.hpp53
1 files changed, 26 insertions, 27 deletions
diff --git a/src/engine/machina/Machine.hpp b/src/engine/machina/Machine.hpp
index acfc599..1a8f267 100644
--- a/src/engine/machina/Machine.hpp
+++ b/src/engine/machina/Machine.hpp
@@ -19,15 +19,13 @@
#define MACHINA_MACHINE_HPP
#include <vector>
+#include <set>
#include <boost/utility.hpp>
+#include "machina/types.hpp"
#include "raul/Atom.hpp"
-#include "raul/Maid.hpp"
#include "raul/RingBuffer.hpp"
-#include "raul/SharedPtr.hpp"
#include "raul/TimeSlice.hpp"
-#include "raul/WeakPtr.hpp"
-
#include "sord/sordmm.hpp"
#include "types.hpp"
@@ -61,49 +59,50 @@ public:
bool is_finished() { return _is_finished; }
bool is_activated() { return _is_activated; }
- void add_node(SharedPtr<Node> node);
- void remove_node(SharedPtr<Node> node);
- void learn(SharedPtr<Raul::Maid> maid, SharedPtr<Node> node);
+ void add_node(SPtr<Node> node);
+ void remove_node(SPtr<Node> node);
+ void learn(SPtr<Raul::Maid> maid, SPtr<Node> node);
void write_state(Sord::Model& model);
// Audio context
void reset(MIDISink* sink, Raul::TimeStamp time);
- uint32_t run(Context& context, SharedPtr<UpdateBuffer> updates);
+ uint32_t run(Context& context, SPtr<UpdateBuffer> updates);
// Any context
inline Raul::TimeStamp time() const { return _time; }
- SharedPtr<LearnRequest> pending_learn() { return _pending_learn; }
- void clear_pending_learn() { _pending_learn.reset(); }
+ SPtr<LearnRequest> pending_learn() { return _pending_learn; }
+ void clear_pending_learn() { _pending_learn.reset(); }
- typedef std::list< SharedPtr<Node> > Nodes;
+ typedef std::set< SPtr<Node> > Nodes;
Nodes& nodes() { return _nodes; }
const Nodes& nodes() const { return _nodes; }
- SharedPtr<Node> random_node();
- SharedPtr<Edge> random_edge();
+ SPtr<Node> random_node();
+ SPtr<Edge> random_edge();
private:
// Audio context
- SharedPtr<Node> earliest_node() const;
+ SPtr<Node> earliest_node() const;
+
+ bool enter_node(Context& context,
+ SPtr<Node> node,
+ SPtr<UpdateBuffer> updates);
- bool enter_node(Context& context,
- SharedPtr<Node> node,
- SharedPtr<UpdateBuffer> updates);
+ void exit_node(Context& context,
+ SPtr<Node> node,
+ SPtr<UpdateBuffer> updates);
- void exit_node(Context& context,
- SharedPtr<Node> node,
- SharedPtr<UpdateBuffer> updates);
+ static const size_t MAX_ACTIVE_NODES = 128;
- static const size_t MAX_ACTIVE_NODES = 128;
- std::vector< SharedPtr<Node> > _active_nodes;
+ std::vector< SPtr<Node> > _active_nodes;
- SharedPtr<LearnRequest> _pending_learn;
- Nodes _nodes;
- Raul::TimeStamp _time;
- bool _is_activated;
- bool _is_finished;
+ SPtr<LearnRequest> _pending_learn;
+ Nodes _nodes;
+ Raul::TimeStamp _time;
+ bool _is_activated;
+ bool _is_finished;
};
} // namespace Machina