aboutsummaryrefslogtreecommitdiffstats
path: root/src/engine/Action.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine/Action.hpp')
-rw-r--r--src/engine/Action.hpp60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/engine/Action.hpp b/src/engine/Action.hpp
new file mode 100644
index 0000000..2916099
--- /dev/null
+++ b/src/engine/Action.hpp
@@ -0,0 +1,60 @@
+/*
+ This file is part of Machina.
+ Copyright 2007-2013 David Robillard <http://drobilla.net>
+
+ 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 3 of the License, or 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 more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Machina. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef MACHINA_ACTION_HPP
+#define MACHINA_ACTION_HPP
+
+#include <string>
+#include <iostream>
+
+#include "raul/Maid.hpp"
+#include "raul/TimeSlice.hpp"
+
+#include "machina/types.hpp"
+
+#include "MIDISink.hpp"
+#include "Stateful.hpp"
+
+namespace machina {
+
+/** An Action, executed on entering or exiting of a state.
+ */
+struct Action
+ : public Raul::Maid::Disposable
+ , public Stateful
+{
+ bool operator==(const Action& rhs) const { return false; }
+
+ virtual void execute(MIDISink* sink, Raul::TimeStamp time) = 0;
+
+ virtual void write_state(Sord::Model& model) {}
+};
+
+class PrintAction : public Action
+{
+public:
+ explicit PrintAction(const std::string& msg) : _msg(msg) {}
+
+ void execute(MIDISink* sink, Raul::TimeStamp time)
+ { std::cout << "t=" << time << ": " << _msg << std::endl; }
+
+private:
+ std::string _msg;
+};
+
+} // namespace machina
+
+#endif // MACHINA_ACTION_HPP