diff options
Diffstat (limited to 'src/engine/Machine.cpp')
-rw-r--r-- | src/engine/Machine.cpp | 39 |
1 files changed, 35 insertions, 4 deletions
diff --git a/src/engine/Machine.cpp b/src/engine/Machine.cpp index 7f668ef..9bb88a5 100644 --- a/src/engine/Machine.cpp +++ b/src/engine/Machine.cpp @@ -16,13 +16,14 @@ */ #include <cstdlib> -#include <raul/RDFWorld.hpp> -#include <raul/RDFModel.hpp> #include <raul/SharedPtr.hpp> -#include "machina/Machine.hpp" -#include "machina/Node.hpp" +#include <redlandmm/Model.hpp> +#include <redlandmm/World.hpp> #include "machina/Edge.hpp" +#include "machina/Gene.hpp" +#include "machina/Machine.hpp" #include "machina/MidiAction.hpp" +#include "machina/Node.hpp" using namespace std; using namespace Raul; @@ -37,10 +38,40 @@ Machine::Machine() { } + +Machine::Machine(SharedPtr<Gene> genotype) + : _is_activated(false) + , _is_finished(false) + , _time(0) + , _genotype(genotype) +{ +} + Machine::~Machine() { } + + +SharedPtr<Gene> +Machine::genotype() +{ + if (_genotype) + return _genotype; + + _genotype = SharedPtr<Gene>(new Gene(_nodes.size())); + + size_t node_id = 0; + for (Nodes::iterator n = _nodes.begin(); n != _nodes.end(); ++n, ++node_id) { + size_t edge_id = 0; + for (Node::Edges::iterator e = (*n)->outgoing_edges().begin(); + e != (*n)->outgoing_edges().end(); ++e, ++edge_id) { + (*_genotype.get())[node_id].push_back(edge_id); + } + } + + return _genotype; +} /** Set the MIDI sink to be used for executing MIDI actions. |