diff options
Diffstat (limited to 'src/engine')
-rw-r--r-- | src/engine/JackDriver.cpp | 14 | ||||
-rw-r--r-- | src/engine/Machine.cpp | 24 | ||||
-rw-r--r-- | src/engine/Node.cpp | 17 | ||||
-rw-r--r-- | src/engine/machina/Machine.hpp | 5 | ||||
-rw-r--r-- | src/engine/machina/Node.hpp | 5 |
5 files changed, 58 insertions, 7 deletions
diff --git a/src/engine/JackDriver.cpp b/src/engine/JackDriver.cpp index fefa4d2..6dc2153 100644 --- a/src/engine/JackDriver.cpp +++ b/src/engine/JackDriver.cpp @@ -60,11 +60,15 @@ JackDriver::attach(const std::string& client_name) void JackDriver::detach() { - jack_port_unregister(jack_client(), _input_port); - jack_port_unregister(jack_client(), _output_port); - _input_port = NULL; - _output_port = NULL; - + if (_input_port) { + jack_port_unregister(jack_client(), _input_port); + _input_port = NULL; + } + + if (_output_port) { + jack_port_unregister(jack_client(), _output_port); + _output_port = NULL; + } Raul::JackDriver::detach(); } diff --git a/src/engine/Machine.cpp b/src/engine/Machine.cpp index dbb212c..142ea37 100644 --- a/src/engine/Machine.cpp +++ b/src/engine/Machine.cpp @@ -197,5 +197,29 @@ Machine::learn(SharedPtr<LearnRequest> learn) } +void +Machine::write_state(Raul::RDFWriter& writer) +{ + using Raul::RdfId; + + writer.add_prefix("machina", "http://drobilla.net/ns/machina"); + + writer.write(RdfId(RdfId::RESOURCE, ""), + RdfId(RdfId::RESOURCE, "rdf:type"), + RdfId(RdfId::RESOURCE, "machina:Machine")); + + for (Nodes::const_iterator n = _nodes.begin(); n != _nodes.end(); ++n) { + if ( ! (*n)->id() ) + (*n)->set_id(writer.blank_id()); + + (*n)->write_state(writer); + + writer.write(RdfId(RdfId::RESOURCE, ""), + RdfId(RdfId::RESOURCE, "machina:node"), + (*n)->id()); + } +} + + } // namespace Machina diff --git a/src/engine/Node.cpp b/src/engine/Node.cpp index 59af04e..c0e0ce6 100644 --- a/src/engine/Node.cpp +++ b/src/engine/Node.cpp @@ -16,6 +16,7 @@ */ #include <cassert> +#include <raul/RDFWriter.h> #include "machina/Node.hpp" #include "machina/Edge.hpp" @@ -99,5 +100,21 @@ Node::remove_outgoing_edge(SharedPtr<Edge> edge) } +void +Node::write_state(Raul::RDFWriter& writer) +{ + using Raul::RdfId; + + writer.write(_id, + RdfId(RdfId::RESOURCE, "rdf:type"), + RdfId(RdfId::RESOURCE, "machina:Node")); + + writer.write(_id, + RdfId(RdfId::RESOURCE, "machina:duration"), + Raul::Atom((int)_duration)); +} + + + } // namespace Machina diff --git a/src/engine/machina/Machine.hpp b/src/engine/machina/Machine.hpp index b53f55c..3e63530 100644 --- a/src/engine/machina/Machine.hpp +++ b/src/engine/machina/Machine.hpp @@ -20,6 +20,7 @@ #include <raul/SharedPtr.h> #include <raul/List.h> +#include <raul/RDFWriter.h> #include "types.hpp" #include "LearnRequest.hpp" #include "Node.hpp" @@ -27,7 +28,7 @@ namespace Machina { -class Machine { +class Machine : public Raul::Stateful { public: Machine(); ~Machine(); @@ -42,6 +43,8 @@ public: void add_node(SharedPtr<Node> node); void learn(SharedPtr<LearnRequest> learn); + void write_state(Raul::RDFWriter& writer); + // Audio context void reset(); FrameCount run(FrameCount nframes); diff --git a/src/engine/machina/Node.hpp b/src/engine/machina/Node.hpp index 243773f..10d4ed4 100644 --- a/src/engine/machina/Node.hpp +++ b/src/engine/machina/Node.hpp @@ -21,6 +21,7 @@ #include <boost/utility.hpp> #include <raul/SharedPtr.h> #include <raul/List.h> +#include <raul/Stateful.h> #include "types.hpp" #include "Action.hpp" @@ -37,7 +38,7 @@ class Edge; * Initial nodes do not have enter actions (since they are entered at * an undefined point in time <= 0). */ -class Node : public boost::noncopyable { +class Node : public Raul::Stateful, public boost::noncopyable { public: typedef std::string ID; @@ -55,6 +56,8 @@ public: void add_outgoing_edge(SharedPtr<Edge> edge); void remove_outgoing_edge(SharedPtr<Edge> edge); + void write_state(Raul::RDFWriter& writer); + bool is_initial() const { return _is_initial; } void set_initial(bool i) { _is_initial = i; } bool is_active() const { return _is_active; } |