diff options
-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 | ||||
-rw-r--r-- | src/gui/MachinaGUI.cpp | 42 | ||||
-rw-r--r-- | src/gui/MachinaGUI.hpp | 9 | ||||
-rw-r--r-- | src/gui/machina.glade | 8 |
8 files changed, 108 insertions, 16 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; } diff --git a/src/gui/MachinaGUI.cpp b/src/gui/MachinaGUI.cpp index dab150f..546bf7d 100644 --- a/src/gui/MachinaGUI.cpp +++ b/src/gui/MachinaGUI.cpp @@ -21,6 +21,8 @@ #include <libglademm/xml.h> #include <fstream> #include <pthread.h> +#include <raul/RDFWriter.h> +#include <machina/Machine.hpp> #include "MachinaGUI.hpp" #include "MachinaCanvas.hpp" #include "NodeView.hpp" @@ -107,7 +109,10 @@ MachinaGUI::MachinaGUI(SharedPtr<Machina::Machine> machine) xml->get_widget("machina_win", _main_window); xml->get_widget("about_win", _about_window); xml->get_widget("help_dialog", _help_dialog); - xml->get_widget("file_quit_menuitem", _menu_file_quit); + xml->get_widget("open_menuitem", _menu_file_open); + xml->get_widget("save_menuitem", _menu_file_save); + xml->get_widget("save_as_menuitem", _menu_file_save_as); + xml->get_widget("quit_menuitem", _menu_file_quit); xml->get_widget("view_refresh_menuitem", _menu_view_refresh); xml->get_widget("view_messages_menuitem", _menu_view_messages); xml->get_widget("help_about_menuitem", _menu_help_about); @@ -131,14 +136,17 @@ MachinaGUI::MachinaGUI(SharedPtr<Machina::Machine> machine) _zoom_full_button->signal_clicked().connect(sigc::mem_fun(_canvas.get(), &MachinaCanvas::zoom_full)); + _menu_file_open->signal_activate().connect( sigc::mem_fun(this, &MachinaGUI::menu_file_open)); + _menu_file_save->signal_activate().connect( sigc::mem_fun(this, &MachinaGUI::menu_file_save)); + _menu_file_save_as->signal_activate().connect( sigc::mem_fun(this, &MachinaGUI::menu_file_save_as)); _menu_file_quit->signal_activate().connect( sigc::mem_fun(this, &MachinaGUI::menu_file_quit)); _menu_view_refresh->signal_activate().connect( sigc::mem_fun(this, &MachinaGUI::menu_view_refresh)); _menu_view_messages->signal_toggled().connect( sigc::mem_fun(this, &MachinaGUI::show_messages_toggled)); _menu_help_about->signal_activate().connect( sigc::mem_fun(this, &MachinaGUI::menu_help_about)); - _menu_help_help->signal_activate().connect( sigc::mem_fun(this, &MachinaGUI::menu_help_help)); + _menu_help_help->signal_activate().connect( sigc::mem_fun(this, &MachinaGUI::menu_help_help)); connect_widgets(); - + //update_state(); _canvas->show(); @@ -275,6 +283,8 @@ MachinaGUI::connect_widgets() } +using namespace std; + void MachinaGUI::menu_file_quit() @@ -284,6 +294,31 @@ MachinaGUI::menu_file_quit() void +MachinaGUI::menu_file_open() +{ + cerr << "open\n"; + +} + + +void +MachinaGUI::menu_file_save() +{ + cerr << "save\n"; + + Raul::RDFWriter writer; + writer.start_to_filename("test.machina.ttl"); + _machine->write_state(writer); + writer.finish();} + + +void +MachinaGUI::menu_file_save_as() +{ +} + + +void MachinaGUI::on_pane_position_changed() { // avoid infinite recursion... @@ -365,3 +400,4 @@ MachinaGUI::menu_help_help() _help_dialog->run(); _help_dialog->hide(); } + diff --git a/src/gui/MachinaGUI.hpp b/src/gui/MachinaGUI.hpp index 147a506..a9ae5e5 100644 --- a/src/gui/MachinaGUI.hpp +++ b/src/gui/MachinaGUI.hpp @@ -18,7 +18,6 @@ #ifndef MACHINA_GUI_H #define MACHINA_GUI_H -//#include "config.h" #include <string> #include <raul/SharedPtr.h> #include <raul/Maid.h> @@ -56,6 +55,9 @@ protected: void connect_widgets(); void menu_file_quit(); + void menu_file_open(); + void menu_file_save(); + void menu_file_save_as(); void show_messages_toggled(); void menu_view_refresh(); void menu_help_about(); @@ -71,7 +73,7 @@ protected: bool _update_pane_position; int _user_pane_position; - bool _refresh; + bool _refresh; boost::shared_ptr<MachinaCanvas> _canvas; boost::shared_ptr<Machina::Machine> _machine; @@ -83,6 +85,9 @@ protected: Gtk::Window* _main_window; Gtk::Dialog* _help_dialog; Gtk::AboutDialog* _about_window; + Gtk::MenuItem* _menu_file_open; + Gtk::MenuItem* _menu_file_save; + Gtk::MenuItem* _menu_file_save_as; Gtk::MenuItem* _menu_file_quit; Gtk::MenuItem* _menu_help_about; Gtk::CheckMenuItem* _menu_view_messages; diff --git a/src/gui/machina.glade b/src/gui/machina.glade index 3216b96..06241a6 100644 --- a/src/gui/machina.glade +++ b/src/gui/machina.glade @@ -44,7 +44,7 @@ <widget class="GtkMenu" id="file_menu_menu"> <child> - <widget class="GtkImageMenuItem" id="open_session_menuitem"> + <widget class="GtkImageMenuItem" id="open_menuitem"> <property name="visible">True</property> <property name="label">gtk-open</property> <property name="use_stock">True</property> @@ -53,7 +53,7 @@ </child> <child> - <widget class="GtkImageMenuItem" id="save_session_menuitem"> + <widget class="GtkImageMenuItem" id="save_menuitem"> <property name="visible">True</property> <property name="label">gtk-save</property> <property name="use_stock">True</property> @@ -62,7 +62,7 @@ </child> <child> - <widget class="GtkImageMenuItem" id="save_session_as_menuitem"> + <widget class="GtkImageMenuItem" id="save_as_menuitem"> <property name="visible">True</property> <property name="label">gtk-save-as</property> <property name="use_stock">True</property> @@ -77,7 +77,7 @@ </child> <child> - <widget class="GtkImageMenuItem" id="file_quit_menuitem"> + <widget class="GtkImageMenuItem" id="quit_menuitem"> <property name="visible">True</property> <property name="label">gtk-quit</property> <property name="use_stock">True</property> |