From 2b5adf2b6c8c5fa44fec0a09c351a8b4954d06d4 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 18 Dec 2010 19:23:09 +0000 Subject: Remove LearnRequest from public engine API. git-svn-id: http://svn.drobilla.net/lad/trunk/machina@2763 a436a847-0d15-0410-975c-d299462d15a1 --- src/engine/JackDriver.cpp | 5 ++- src/engine/LearnRequest.cpp | 2 +- src/engine/LearnRequest.hpp | 82 +++++++++++++++++++++++++++++++++++++ src/engine/Machine.cpp | 10 +++-- src/engine/MachineBuilder.cpp | 8 +++- src/engine/Mutation.cpp | 4 +- src/engine/machina/LearnRequest.hpp | 81 ------------------------------------ src/engine/machina/Machine.hpp | 13 +++--- 8 files changed, 110 insertions(+), 95 deletions(-) create mode 100644 src/engine/LearnRequest.hpp delete mode 100644 src/engine/machina/LearnRequest.hpp (limited to 'src/engine') diff --git a/src/engine/JackDriver.cpp b/src/engine/JackDriver.cpp index 020d833..55b06e2 100644 --- a/src/engine/JackDriver.cpp +++ b/src/engine/JackDriver.cpp @@ -17,9 +17,12 @@ #include #include + +#include "machina-config.h" #include "machina/JackDriver.hpp" #include "machina/MidiAction.hpp" -#include "machina-config.h" + +#include "LearnRequest.hpp" #include "jack_compat.h" using namespace Raul; diff --git a/src/engine/LearnRequest.cpp b/src/engine/LearnRequest.cpp index ae61b5c..d5f7846 100644 --- a/src/engine/LearnRequest.cpp +++ b/src/engine/LearnRequest.cpp @@ -16,7 +16,7 @@ */ #include "raul/Quantizer.hpp" -#include "machina/LearnRequest.hpp" +#include "LearnRequest.hpp" namespace Machina { diff --git a/src/engine/LearnRequest.hpp b/src/engine/LearnRequest.hpp new file mode 100644 index 0000000..6ee60fe --- /dev/null +++ b/src/engine/LearnRequest.hpp @@ -0,0 +1,82 @@ +/* This file is part of Machina. + * Copyright (C) 2007-2009 David Robillard + * + * Machina is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) any later + * version. + * + * Machina is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef MACHINA_LEARNREQUEST_HPP +#define MACHINA_LEARNREQUEST_HPP + +#include "raul/Maid.hpp" +#include "raul/SharedPtr.hpp" + +#include "machina/MidiAction.hpp" +#include "machina/Node.hpp" +#include "machina/types.hpp" + +namespace Machina { + +class Node; +class MidiAction; + + +/** A request to MIDI learn a certain node. + */ +class LearnRequest : public Raul::Deletable { +public: + + static SharedPtr + create(SharedPtr maid, SharedPtr node) + { + SharedPtr ret(new LearnRequest(maid, node)); + maid->manage(ret); + return ret; + } + + void start(double q, Raul::TimeStamp time) + { _started = true; _start_time = time; _quantization = q; } + + void finish(TimeStamp time); + + bool started() { return _started; } + + const SharedPtr& node() { return _node; } + const SharedPtr& enter_action() { return _enter_action; } + const SharedPtr& exit_action() { return _exit_action; } + +private: + LearnRequest(SharedPtr maid, SharedPtr node) + : _started(false) + , _start_time(TimeUnit(TimeUnit::BEATS, 19200), 0, 0) // irrelevant + , _quantization(0) // irrelevant + , _node(node) + , _enter_action(new MidiAction(4, NULL)) + , _exit_action(new MidiAction(4, NULL)) + { + maid->manage(_enter_action); + maid->manage(_exit_action); + } + + bool _started; + TimeStamp _start_time; + double _quantization; + SharedPtr _node; + SharedPtr _enter_action; + SharedPtr _exit_action; +}; + + +} // namespace Machina + +#endif // MACHINA_LEARNREQUEST_HPP diff --git a/src/engine/Machine.cpp b/src/engine/Machine.cpp index cbfa54e..c7ea48d 100644 --- a/src/engine/Machine.cpp +++ b/src/engine/Machine.cpp @@ -16,14 +16,18 @@ */ #include + #include "raul/SharedPtr.hpp" #include "redlandmm/Model.hpp" #include "redlandmm/World.hpp" + #include "machina/Edge.hpp" #include "machina/Machine.hpp" #include "machina/MidiAction.hpp" #include "machina/Node.hpp" +#include "LearnRequest.hpp" + using namespace std; using namespace Raul; @@ -367,9 +371,9 @@ Machine::run(const Raul::TimeSlice& time) * NOT realtime (actions are allocated here). */ void -Machine::learn(SharedPtr learn) +Machine::learn(SharedPtr maid, SharedPtr node) { - _pending_learn = learn; + _pending_learn = LearnRequest::create(maid, node); } @@ -418,6 +422,4 @@ Machine::write_state(Redland::Model& model) } } - } // namespace Machina - diff --git a/src/engine/MachineBuilder.cpp b/src/engine/MachineBuilder.cpp index 3078cc2..946b7f5 100644 --- a/src/engine/MachineBuilder.cpp +++ b/src/engine/MachineBuilder.cpp @@ -16,12 +16,16 @@ */ #include + #include "raul/midi_events.h" +#include "raul/SharedPtr.hpp" #include "raul/Quantizer.hpp" -#include "machina/MachineBuilder.hpp" + +#include "machina/Edge.hpp" #include "machina/Machine.hpp" +#include "machina/MachineBuilder.hpp" +#include "machina/MidiAction.hpp" #include "machina/Node.hpp" -#include "machina/Edge.hpp" using namespace std; using namespace Raul; diff --git a/src/engine/Mutation.cpp b/src/engine/Mutation.cpp index bdf0599..d83ea8a 100644 --- a/src/engine/Mutation.cpp +++ b/src/engine/Mutation.cpp @@ -17,10 +17,12 @@ #include #include + +#include "machina/ActionFactory.hpp" #include "machina/Edge.hpp" #include "machina/Machine.hpp" +#include "machina/MidiAction.hpp" #include "machina/Mutation.hpp" -#include "machina/ActionFactory.hpp" using namespace std; diff --git a/src/engine/machina/LearnRequest.hpp b/src/engine/machina/LearnRequest.hpp deleted file mode 100644 index 04f0626..0000000 --- a/src/engine/machina/LearnRequest.hpp +++ /dev/null @@ -1,81 +0,0 @@ -/* This file is part of Machina. - * Copyright (C) 2007-2009 David Robillard - * - * Machina is free software; you can redistribute it and/or modify it under the - * terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later - * version. - * - * Machina is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#ifndef MACHINA_LEARNREQUEST_HPP -#define MACHINA_LEARNREQUEST_HPP - -#include "raul/Maid.hpp" -#include "raul/SharedPtr.hpp" -#include "types.hpp" -#include "Node.hpp" -#include "MidiAction.hpp" - -namespace Machina { - -class Node; -class MidiAction; - - -/** A request to MIDI learn a certain node. - */ -class LearnRequest : public Raul::Deletable { -public: - - static SharedPtr - create(SharedPtr maid, SharedPtr node) - { - SharedPtr ret(new LearnRequest(maid, node)); - maid->manage(ret); - return ret; - } - - void start(double q, Raul::TimeStamp time) - { _started = true; _start_time = time; _quantization = q; } - - void finish(TimeStamp time); - - bool started() { return _started; } - - const SharedPtr& node() { return _node; } - const SharedPtr& enter_action() { return _enter_action; } - const SharedPtr& exit_action() { return _exit_action; } - -private: - LearnRequest(SharedPtr maid, SharedPtr node) - : _started(false) - , _start_time(TimeUnit(TimeUnit::BEATS, 19200), 0, 0) // irrelevant - , _quantization(0) // irrelevant - , _node(node) - , _enter_action(new MidiAction(4, NULL)) - , _exit_action(new MidiAction(4, NULL)) - { - maid->manage(_enter_action); - maid->manage(_exit_action); - } - - bool _started; - TimeStamp _start_time; - double _quantization; - SharedPtr _node; - SharedPtr _enter_action; - SharedPtr _exit_action; -}; - - -} // namespace Machina - -#endif // MACHINA_LEARNREQUEST_HPP diff --git a/src/engine/machina/Machine.hpp b/src/engine/machina/Machine.hpp index 1d07a2c..8c1caf3 100644 --- a/src/engine/machina/Machine.hpp +++ b/src/engine/machina/Machine.hpp @@ -1,5 +1,5 @@ /* This file is part of Machina. - * Copyright (C) 2007-2009 David Robillard + * Copyright (C) 2007-2010 David Robillard * * Machina is free software; you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software @@ -20,17 +20,20 @@ #include #include -#include "raul/SharedPtr.hpp" -#include "raul/WeakPtr.hpp" + #include "raul/List.hpp" +#include "raul/Maid.hpp" +#include "raul/SharedPtr.hpp" #include "raul/TimeSlice.hpp" +#include "raul/WeakPtr.hpp" #include "redlandmm/Model.hpp" + #include "types.hpp" -#include "LearnRequest.hpp" #include "Node.hpp" namespace Machina { +class LearnRequest; /** A (Finite State) Machine. */ @@ -54,7 +57,7 @@ public: void add_node(SharedPtr node); void remove_node(SharedPtr node); - void learn(SharedPtr learn); + void learn(SharedPtr maid, SharedPtr node); void write_state(Redland::Model& model); -- cgit v1.2.1