aboutsummaryrefslogtreecommitdiffstats
path: root/src/engine/machina
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine/machina')
-rw-r--r--src/engine/machina/Machine.hpp5
-rw-r--r--src/engine/machina/MachineMutation.hpp37
-rw-r--r--src/engine/machina/Makefile.am1
-rw-r--r--src/engine/machina/Node.hpp24
-rw-r--r--src/engine/machina/Schrodinbit.hpp45
5 files changed, 96 insertions, 16 deletions
diff --git a/src/engine/machina/Machine.hpp b/src/engine/machina/Machine.hpp
index 626ef10..889dc1a 100644
--- a/src/engine/machina/Machine.hpp
+++ b/src/engine/machina/Machine.hpp
@@ -61,9 +61,12 @@ public:
SharedPtr<LearnRequest> pending_learn() { return _pending_learn; }
void clear_pending_learn() { _pending_learn.reset(); }
- typedef Raul::List<SharedPtr<Node> > Nodes;
+ typedef Raul::List< SharedPtr<Node> > Nodes;
Nodes& nodes() { return _nodes; }
+ SharedPtr<Node> random_node();
+ SharedPtr<Edge> random_edge();
+
void set_sink(SharedPtr<Raul::MIDISink> sink);
private:
diff --git a/src/engine/machina/MachineMutation.hpp b/src/engine/machina/MachineMutation.hpp
new file mode 100644
index 0000000..34eda30
--- /dev/null
+++ b/src/engine/machina/MachineMutation.hpp
@@ -0,0 +1,37 @@
+/* This file is part of Machina.
+ * Copyright (C) 2007 Dave 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 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_MACHINE_MUTATION_HPP
+#define MACHINA_MACHINE_MUTATION_HPP
+
+namespace Machina {
+
+class Machine;
+
+namespace Mutation {
+
+struct Mutation { virtual void mutate(Machine& machine) = 0; };
+
+struct AddEdge { static void mutate(Machine& machine); };
+struct RemoveEdge { static void mutate(Machine& machine); };
+struct AdjustEdge { static void mutate(Machine& machine); };
+
+} // namespace Mutation
+
+} // namespace Machina
+
+#endif // MACHINA_MACHINE_MUTATION_HPP
diff --git a/src/engine/machina/Makefile.am b/src/engine/machina/Makefile.am
index 65ea295..de99845 100644
--- a/src/engine/machina/Makefile.am
+++ b/src/engine/machina/Makefile.am
@@ -11,6 +11,7 @@ libmachinainclude_HEADERS = \
Loader.hpp \
Machine.hpp \
MachineBuilder.hpp \
+ MachineMutation.hpp \
MidiAction.hpp \
Node.hpp \
Recorder.hpp \
diff --git a/src/engine/machina/Node.hpp b/src/engine/machina/Node.hpp
index 041f443..a916eb6 100644
--- a/src/engine/machina/Node.hpp
+++ b/src/engine/machina/Node.hpp
@@ -24,6 +24,7 @@
#include <raul/Stateful.hpp>
#include <raul/MIDISink.hpp>
#include "Action.hpp"
+#include "Schrodinbit.hpp"
namespace Machina {
@@ -57,7 +58,7 @@ public:
void add_outgoing_edge(SharedPtr<Edge> edge);
void remove_outgoing_edge(SharedPtr<Edge> edge);
- void remove_outgoing_edges_to(SharedPtr<Node> node);
+ void remove_edges_to(SharedPtr<Node> node);
void write_state(Redland::Model& model);
@@ -71,23 +72,16 @@ public:
bool is_selector() const { return _is_selector; }
void set_selector(bool i);
- /// Schroedinger's flag
- inline bool changed() {
- if (_changed) {
- _changed = false;
- return true;
- } else {
- return false;
- }
- }
-
- void set_changed() { _changed = true; }
+ inline bool changed() { return _changed; }
+ inline void set_changed() { _changed = true; }
typedef Raul::List<SharedPtr<Edge> > Edges;
- Edges& outgoing_edges() { return _outgoing_edges; }
+ Edges& edges() { return _edges; }
+
+ SharedPtr<Edge> random_edge();
private:
- bool _changed;
+ Schrodinbit _changed;
bool _is_initial;
bool _is_selector;
bool _is_active;
@@ -95,7 +89,7 @@ private:
BeatCount _duration;
SharedPtr<Action> _enter_action;
SharedPtr<Action> _exit_action;
- Edges _outgoing_edges;
+ Edges _edges;
};
diff --git a/src/engine/machina/Schrodinbit.hpp b/src/engine/machina/Schrodinbit.hpp
new file mode 100644
index 0000000..6065cfc
--- /dev/null
+++ b/src/engine/machina/Schrodinbit.hpp
@@ -0,0 +1,45 @@
+/* This file is part of Machina.
+ * Copyright (C) 2007 Dave 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 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 SCHRODINBIT_HPP
+#define SCHRODINBIT_HPP
+
+
+/** A flag which becomes false when it's value is observed
+ */
+class Schrodinbit {
+public:
+ Schrodinbit() : _flag(false) {}
+
+ inline operator bool() {
+ const bool ret = _flag;
+ _flag = false;
+ return ret;
+ }
+
+ inline bool operator=(bool flag) {
+ _flag = flag;
+ return flag;
+ }
+
+private:
+ bool _flag;
+};
+
+
+#endif // SCHRODINBIT_HPP
+