diff options
author | David Robillard <d@drobilla.net> | 2013-01-13 09:23:42 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2013-01-13 09:23:42 +0000 |
commit | 448d6e329a55848e357d57f8ca225d987627ee08 (patch) | |
tree | 0153d22bedf929173b973b98c6840fd010b06aca /src/engine | |
parent | 67a8adbc93991acfb688f378f52392995a272fac (diff) | |
download | machina-448d6e329a55848e357d57f8ca225d987627ee08.tar.gz machina-448d6e329a55848e357d57f8ca225d987627ee08.tar.bz2 machina-448d6e329a55848e357d57f8ca225d987627ee08.zip |
Move merge operation to Machine::merge().
Delete unused Engine::import_machine().
git-svn-id: http://svn.drobilla.net/lad/trunk/machina@4956 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/engine')
-rw-r--r-- | src/engine/Engine.cpp | 9 | ||||
-rw-r--r-- | src/engine/JackDriver.cpp | 11 | ||||
-rw-r--r-- | src/engine/Machine.cpp | 15 | ||||
-rw-r--r-- | src/engine/MachineBuilder.cpp | 1 | ||||
-rw-r--r-- | src/engine/machina/Engine.hpp | 2 | ||||
-rw-r--r-- | src/engine/machina/Machine.hpp | 6 |
6 files changed, 21 insertions, 23 deletions
diff --git a/src/engine/Engine.cpp b/src/engine/Engine.cpp index 90aea9b..7807f87 100644 --- a/src/engine/Engine.cpp +++ b/src/engine/Engine.cpp @@ -97,15 +97,6 @@ Engine::load_machine_midi(const Glib::ustring& uri, } void -Engine::import_machine(SPtr<Machine> machine) -{ - _driver->machine()->nodes().insert(machine->nodes().begin(), - machine->nodes().end()); - // FIXME: thread safe? - // FIXME: announce -} - -void Engine::export_midi(const Glib::ustring& filename, Raul::TimeDuration dur) { SPtr<Machine> machine = _driver->machine(); diff --git a/src/engine/JackDriver.cpp b/src/engine/JackDriver.cpp index 0276cc5..c56e83d 100644 --- a/src/engine/JackDriver.cpp +++ b/src/engine/JackDriver.cpp @@ -437,16 +437,7 @@ JackDriver::finish_record() _play_state = PlayState::PLAYING; SPtr<Machine> machine = _recorder->finish(); _recorder.reset(); - for (const auto& m : machine->nodes()) { - if (m->is_initial()) { - for (const auto& e : m->edges()) { - e->set_tail(_machine->initial_node()); - _machine->initial_node()->edges().insert(e); - } - } else { - _machine->nodes().insert(m); - } - } + _machine->merge(*machine.get()); } int diff --git a/src/engine/Machine.cpp b/src/engine/Machine.cpp index a6abcff..b5cfb28 100644 --- a/src/engine/Machine.cpp +++ b/src/engine/Machine.cpp @@ -100,6 +100,21 @@ Machine::operator=(const Machine& copy) return *this; } +void +Machine::merge(const Machine& machine) +{ + for (const auto& m : machine.nodes()) { + if (m->is_initial()) { + for (const auto& e : m->edges()) { + e->set_tail(_initial_node); + _initial_node->edges().insert(e); + } + } else { + _nodes.insert(m); + } + } +} + /** Always returns a node, unless there are none */ SPtr<Node> Machine::random_node() diff --git a/src/engine/MachineBuilder.cpp b/src/engine/MachineBuilder.cpp index 0a515a4..ff2ee77 100644 --- a/src/engine/MachineBuilder.cpp +++ b/src/engine/MachineBuilder.cpp @@ -45,7 +45,6 @@ void MachineBuilder::reset() { _time = TimeStamp(_machine->time().unit()); // = 0 - _initial_node = SPtr<Node>(new Node(_time, true)); // duration 0 _connect_node = _initial_node; _connect_node_end_time = _time; // = 0 } diff --git a/src/engine/machina/Engine.hpp b/src/engine/machina/Engine.hpp index 7e0c9bc..39974f1 100644 --- a/src/engine/machina/Engine.hpp +++ b/src/engine/machina/Engine.hpp @@ -54,8 +54,6 @@ public: double q, Raul::TimeDuration dur); - void import_machine(SPtr<Machine> machine); - void export_midi(const Glib::ustring& filename, Raul::TimeDuration dur); diff --git a/src/engine/machina/Machine.hpp b/src/engine/machina/Machine.hpp index 8a98e4c..d4eccea 100644 --- a/src/engine/machina/Machine.hpp +++ b/src/engine/machina/Machine.hpp @@ -51,7 +51,11 @@ public: */ Machine(const Machine& copy); - Machine& operator=(const Machine& other); + /** Completely replace this machine's contents with a deep copy. */ + Machine& operator=(const Machine& copy); + + /** Merge another machine into this machine. */ + void merge(const Machine& machine); bool is_empty() { return _nodes.empty(); } bool is_finished() { return _is_finished; } |