diff options
Diffstat (limited to 'src')
28 files changed, 306 insertions, 190 deletions
diff --git a/src/libs/client/SigClientInterface.h b/src/libs/client/SigClientInterface.h index f384f239..6b427e3c 100644 --- a/src/libs/client/SigClientInterface.h +++ b/src/libs/client/SigClientInterface.h @@ -28,30 +28,36 @@ namespace LibOmClient { /** A LibSigC++ signal emitting interface for clients to use. * - * sed would have the copyright to this code if it was a legal person. + * This simply emits an sigc signal for every event (eg OSC message) coming from + * the engine. Use Store (which extends this) if you want a nice client-side + * model of the engine. */ class SigClientInterface : virtual public Om::Shared::ClientInterface, public sigc::trackable { public: - sigc::signal<void> bundle_begin_sig; - sigc::signal<void> bundle_end_sig; - sigc::signal<void, const string&> error_sig; - sigc::signal<void, uint32_t> num_plugins_sig; - sigc::signal<void, const string&, const string&, const string&> new_plugin_sig; - sigc::signal<void, const string&, uint32_t> new_patch_sig; + + // See the corresponding emitting functions below for parameter meanings + + sigc::signal<void> bundle_begin_sig; + sigc::signal<void> bundle_end_sig; + sigc::signal<void, const string&> error_sig; + sigc::signal<void, uint32_t> num_plugins_sig; + sigc::signal<void, const string&, const string&, const string&> new_plugin_sig; + sigc::signal<void, const string&, uint32_t> new_patch_sig; sigc::signal<void, const string&, const string&, const string&, bool, uint32_t> new_node_sig; - sigc::signal<void, const string&, const string&, bool> new_port_sig; - sigc::signal<void, const string&> patch_enabled_sig; - sigc::signal<void, const string&> patch_disabled_sig; - sigc::signal<void, const string&> patch_cleared_sig; - sigc::signal<void, const string&, const string&> object_renamed_sig; - sigc::signal<void, const string&> object_destroyed_sig; - sigc::signal<void, const string&, const string&> connection_sig; - sigc::signal<void, const string&, const string&> disconnection_sig; - sigc::signal<void, const string&, const string&, const string&> metadata_update_sig; - sigc::signal<void, const string&, float> control_change_sig; - sigc::signal<void, const string&, uint32_t, uint32_t, const string&> program_add_sig; - sigc::signal<void, const string&, uint32_t, uint32_t> program_remove_sig; + sigc::signal<void, const string&, const string&, bool> new_port_sig; + sigc::signal<void, const string&> patch_enabled_sig; + sigc::signal<void, const string&> patch_disabled_sig; + sigc::signal<void, const string&> patch_cleared_sig; + sigc::signal<void, const string&, const string&> object_renamed_sig; + sigc::signal<void, const string&> object_destroyed_sig; + sigc::signal<void, const string&, const string&> connection_sig; + sigc::signal<void, const string&, const string&> disconnection_sig; + sigc::signal<void, const string&, const string&, const string&> metadata_update_sig; + sigc::signal<void, const string&, float> control_change_sig; + sigc::signal<void, const string&, uint32_t, uint32_t, const string&> program_add_sig; + sigc::signal<void, const string&, uint32_t, uint32_t> program_remove_sig; + inline void emit_bundle_begin() { bundle_begin_sig.emit(); } diff --git a/src/progs/gtk/BreadCrumb.h b/src/progs/gtk/BreadCrumb.h index f79ad363..bbb8ee5c 100644 --- a/src/progs/gtk/BreadCrumb.h +++ b/src/progs/gtk/BreadCrumb.h @@ -32,21 +32,20 @@ namespace OmGtk { class BreadCrumb : public Gtk::ToggleButton { public: - BreadCrumb(PatchWindow* window, PatchController* patch) - : m_window(window), - m_patch(patch) + BreadCrumb(PatchWindow* window, const Path& path) + : m_window(window) + , m_path(path) { - assert(patch != NULL); set_border_width(0); - path(m_patch->path()); + set_path(path); signal_clicked().connect(sigc::bind(sigc::mem_fun( m_window, &PatchWindow::breadcrumb_clicked), this)); show_all(); } - PatchController* patch() { return m_patch; } + //PatchController* patch() { return m_patch; } - void path(const Path& path) + void set_path(const Path& path) { remove(); const string text = (path == "/") ? "/" : path.name(); @@ -55,10 +54,13 @@ public: lab->show(); add(*lab); } + + Path& path() { return m_path; } private: PatchWindow* m_window; - PatchController* m_patch; + Path m_path; + //PatchController* m_patch; }; } // namespace OmGtk diff --git a/src/progs/gtk/ConnectWindow.cpp b/src/progs/gtk/ConnectWindow.cpp index 15bab62c..0b753266 100644 --- a/src/progs/gtk/ConnectWindow.cpp +++ b/src/progs/gtk/ConnectWindow.cpp @@ -24,6 +24,8 @@ #include "Controller.h" #include "OSCListener.h" #include "Store.h" +#include "PatchController.h" +#include "PatchModel.h" namespace OmGtk { @@ -149,8 +151,13 @@ ConnectWindow::gtk_callback() Controller::instance().request_all_objects(); ++stage; } else if (stage == 7) { - if (Store::instance().num_objects() > 0) + if (Store::instance().num_objects() > 0) { + CountedPtr<PatchModel> root = Store::instance().patch("/"); + assert(root); + PatchController* root_controller = new PatchController(root); + root_controller->show_patch_window(); ++stage; + } } else if (stage == 8) { stage = -1; hide(); // FIXME: actually destroy window to save mem? diff --git a/src/progs/gtk/ControlGroups.cpp b/src/progs/gtk/ControlGroups.cpp index de87be05..b15d4d5a 100644 --- a/src/progs/gtk/ControlGroups.cpp +++ b/src/progs/gtk/ControlGroups.cpp @@ -30,7 +30,7 @@ namespace OmGtk { //////////////////// SliderControlGroup //////////////////////// -SliderControlGroup::SliderControlGroup(ControlPanel* panel, PortModel* pm, bool separator) +SliderControlGroup::SliderControlGroup(ControlPanel* panel, CountedPtr<PortModel> pm, bool separator) : ControlGroup(panel, pm, separator), m_enabled(true), m_enable_signal(false), @@ -272,7 +272,7 @@ SliderControlGroup::slider_pressed(GdkEvent* ev) /////////////// IntegerControlGroup //////////////// -IntegerControlGroup::IntegerControlGroup(ControlPanel* panel, PortModel* pm, bool separator) +IntegerControlGroup::IntegerControlGroup(ControlPanel* panel, CountedPtr<PortModel> pm, bool separator) : ControlGroup(panel, pm, separator), m_enable_signal(false), m_alignment(0.5, 0.5, 0.0, 0.0), @@ -347,7 +347,7 @@ IntegerControlGroup::update_value() /////////////// ToggleControlGroup //////////////// -ToggleControlGroup::ToggleControlGroup(ControlPanel* panel, PortModel* pm, bool separator) +ToggleControlGroup::ToggleControlGroup(ControlPanel* panel, CountedPtr<PortModel> pm, bool separator) : ControlGroup(panel, pm, separator), m_enable_signal(false), m_alignment(0.5, 0.5, 0.0, 0.0), diff --git a/src/progs/gtk/ControlGroups.h b/src/progs/gtk/ControlGroups.h index ab1e3413..9f46bdac 100644 --- a/src/progs/gtk/ControlGroups.h +++ b/src/progs/gtk/ControlGroups.h @@ -22,6 +22,7 @@ #include <libglademm/xml.h> #include <libglademm.h> #include "PortModel.h" +#include "util/CountedPtr.h" namespace LibOmClient { class PortModel; } @@ -39,14 +40,14 @@ class ControlPanel; class ControlGroup : public Gtk::VBox { public: - ControlGroup(ControlPanel* panel, PortModel* pm, bool separator) + ControlGroup(ControlPanel* panel, CountedPtr<PortModel> pm, bool separator) : Gtk::VBox(false, 0), m_control_panel(panel), m_port_model(pm), m_has_separator(separator) { - assert(m_port_model != NULL); - assert(panel != NULL); + assert(m_port_model); + assert(panel); if (separator) { m_separator = new Gtk::HSeparator(); @@ -62,7 +63,7 @@ public: virtual void set_value(float val) = 0; - inline const PortModel* const port_model() { return m_port_model; } + inline const CountedPtr<PortModel> port_model() const { return m_port_model; } virtual void set_min(float val) {} virtual void set_max(float val) {} @@ -75,7 +76,7 @@ public: protected: ControlPanel* m_control_panel; - PortModel* m_port_model; + CountedPtr<PortModel> m_port_model; bool m_has_separator; Gtk::HSeparator* m_separator; }; @@ -88,7 +89,7 @@ protected: class SliderControlGroup : public ControlGroup { public: - SliderControlGroup(ControlPanel* panel, PortModel* pm, bool separator); + SliderControlGroup(ControlPanel* panel, CountedPtr<PortModel> pm, bool separator); void set_name(const string& name); @@ -148,7 +149,7 @@ SliderControlGroup::set_value(const float val) class IntegerControlGroup : public ControlGroup { public: - IntegerControlGroup(ControlPanel* panel, PortModel* pm, bool separator); + IntegerControlGroup(ControlPanel* panel, CountedPtr<PortModel> pm, bool separator); void set_name(const string& name); void set_value(float val); @@ -173,7 +174,7 @@ private: class ToggleControlGroup : public ControlGroup { public: - ToggleControlGroup(ControlPanel* panel, PortModel* pm, bool separator); + ToggleControlGroup(ControlPanel* panel, CountedPtr<PortModel> pm, bool separator); void set_name(const string& name); void set_value(float val); diff --git a/src/progs/gtk/ControlInterface.cpp b/src/progs/gtk/ControlInterface.cpp index 9ac6e07e..f1fc44d9 100644 --- a/src/progs/gtk/ControlInterface.cpp +++ b/src/progs/gtk/ControlInterface.cpp @@ -56,7 +56,7 @@ ControlInterface::new_patch_model(PatchModel* const pm) //cout << "[ControlInterface] New patch." << endl; - if (Store::instance().patch(pm->path()) != NULL) { + if (Store::instance().patch(pm->path())) { delete pm; } else { @@ -75,8 +75,8 @@ ControlInterface::new_patch_model(PatchModel* const pm) assert(pm->parent() == NULL); PatchController* patch = new PatchController(pm); - Store::instance().add_object(patch); - _app->patch_tree()->add_patch(patch); + //Store::instance().add_object(patch); + //_app->patch_tree()->add_patch(patch); if (pm->path() == "/") patch->show_patch_window(); @@ -91,8 +91,8 @@ ControlInterface::new_node_model(NodeModel* const nm) { assert(nm); - //cerr << "[ControlInterface] New node: " << nm->name() << endl; - + cerr << "[ControlInterface] FIXME: New node: " << nm->name() << endl; +#if 0 PatchController* const pc = Store::instance().patch(nm->path().parent()); if (pc != NULL) { @@ -119,6 +119,7 @@ ControlInterface::new_node_model(NodeModel* const nm) cerr << "[NewNode] Can not find parent of " << nm->path() << ". Module will not appear." << endl; } + #endif } @@ -127,14 +128,15 @@ ControlInterface::new_port_model(PortModel* const pm) { assert(pm); - //cout << "[ControlInterface] New port." << endl; - + cout << "[ControlInterface] FIXME: New port." << endl; +/* NodeController* node = Store::instance().node(pm->path().parent()); if (node != NULL) node->add_port(pm); else cerr << "[NewPort] Could not find parent for " << pm->path() << endl; + */ } @@ -142,12 +144,13 @@ void ControlInterface::patch_enabled(const string& path) { //cout << "[ControlInterface] Patch enabled." << endl; - +/* PatchController* patch = Store::instance().patch(path); if (patch != NULL) patch->enable(); else cerr << "[PatchEnabled] Cannot find patch " << path << endl; + */ } @@ -155,12 +158,13 @@ void ControlInterface::patch_disabled(const string& path) { //cout << "[ControlInterface] Patch disabled." << endl; - +/* PatchController* patch = Store::instance().patch(path); if (patch != NULL) patch->disable(); else cerr << "[PatchDisabled] Cannot find patch " << path << endl; + */ } @@ -168,12 +172,13 @@ void ControlInterface::patch_cleared(const string& path) { //cout << "[ControlInterface] Patch cleared." << endl; - +/* PatchController* patch = Store::instance().patch(path); if (patch != NULL) patch->clear(); else cerr << "[PatchCleared] Cannot find patch " << path << endl; + */ } @@ -181,7 +186,7 @@ void ControlInterface::object_destroyed(const string& path) { //cout << "[ControlInterface] Destroying." << endl; - +/* GtkObjectController* object = Store::instance().object(path); if (object != NULL) { object->destroy(); @@ -189,6 +194,7 @@ ControlInterface::object_destroyed(const string& path) } else { cerr << "[Destroy] Cannot find object " << path << endl; } + */ } @@ -196,13 +202,14 @@ void ControlInterface::object_renamed(const string& old_path, const string& new_path) { //cout << "[ControlInterface] Renaming." << endl; - +/* GtkObjectController* object = Store::instance().object(old_path); if (object != NULL) object->set_path(new_path); else cerr << "[ObjectRenamed] Can not find object " << old_path << " to rename." << endl; + */ } @@ -212,7 +219,7 @@ ControlInterface::connection_model(ConnectionModel* connection) assert(connection); //cout << "[ControlInterface] Connection" << endl; - +/* assert(connection->src_port_path().parent().parent() == connection->dst_port_path().parent().parent()); @@ -223,6 +230,7 @@ ControlInterface::connection_model(ConnectionModel* connection) else cerr << "[Connection] Can not find patch " << connection->patch_path() << ". Connection will not be made." << endl; + */ } @@ -230,7 +238,7 @@ void ControlInterface::disconnection(const string& src_port_path, const string& dst_port_path) { //cerr << "[ControlInterface] Disconnection." << endl; - string patch_path = src_port_path; +/* string patch_path = src_port_path; patch_path = patch_path.substr(0, patch_path.find_last_of("/")); patch_path = patch_path.substr(0, patch_path.find_last_of("/")); @@ -244,25 +252,25 @@ ControlInterface::disconnection(const string& src_port_path, const string& dst_p else cerr << "[Disconnection] Can not find window for patch " << patch_path << ". Connection will not be removed." << endl; + */ } void ControlInterface::metadata_update(const string& path, const string& key, const string& value) -{ +{ /* //cerr << "[ControlInterface] Metadata." << endl; - GtkObjectController* object = Store::instance().object(path); if (object != NULL) object->metadata_update(key, value); else cerr << "[MetadataUpdate] Could not find object " << path << endl; -} +*/ } void ControlInterface::control_change(const string& port_path, float value) -{ +{ /* //cerr << "[ControlInterface] Control change." << endl; PortController* port = Store::instance().port(port_path); @@ -270,12 +278,12 @@ ControlInterface::control_change(const string& port_path, float value) port->control_change(value); else cerr << "[ControlChange] Can not find port " << port_path << endl; -} +*/ } void ControlInterface::program_add(const string& path, uint32_t bank, uint32_t program, const string& name) -{ +{ /* NodeController* node = Store::instance().node(path); if (node != NULL) { node->program_add(bank, program, name); @@ -283,12 +291,12 @@ ControlInterface::program_add(const string& path, uint32_t bank, uint32_t progra } else { cerr << "[ProgramAdd] Can not find node " << path << endl; } -} +*/ } void ControlInterface::program_remove(const string& path, uint32_t bank, uint32_t program) -{ +{ /* NodeController* node = Store::instance().node(path); if (node != NULL) { node->program_remove(bank, program); @@ -296,7 +304,7 @@ ControlInterface::program_remove(const string& path, uint32_t bank, uint32_t pro } else { cerr << "[ProgramRemove] Can not find node " << path << endl; } -} +*/ } } // namespace OmGtk diff --git a/src/progs/gtk/ControlPanel.cpp b/src/progs/gtk/ControlPanel.cpp index f344e2c3..73520596 100644 --- a/src/progs/gtk/ControlPanel.cpp +++ b/src/progs/gtk/ControlPanel.cpp @@ -56,7 +56,7 @@ ControlPanel::init(NodeController* node, size_t poly) assert(node != NULL); assert(poly > 0); - NodeModel* const node_model = node->node_model(); + const CountedPtr<NodeModel> node_model = node->node_model(); if (poly > 1) { m_voice_spinbutton->set_range(0, poly - 1); @@ -91,11 +91,11 @@ ControlPanel::find_port(const Path& path) const void ControlPanel::add_port(PortController* port) { - assert(port != NULL); - assert(port->model() != NULL); + assert(port); + assert(port->model()); assert(port->control_panel() == NULL); - PortModel* const pm = port->port_model(); + const CountedPtr<PortModel> pm = port->port_model(); // Already have port, don't add another if (find_port(pm->path()) != NULL) diff --git a/src/progs/gtk/GtkObjectController.cpp b/src/progs/gtk/GtkObjectController.cpp index 7277d346..49abe58f 100644 --- a/src/progs/gtk/GtkObjectController.cpp +++ b/src/progs/gtk/GtkObjectController.cpp @@ -19,10 +19,10 @@ namespace OmGtk { -GtkObjectController::GtkObjectController(ObjectModel* model) +GtkObjectController::GtkObjectController(CountedPtr<ObjectModel> model) : m_model(model) { - assert(m_model != NULL); + assert(m_model); } diff --git a/src/progs/gtk/GtkObjectController.h b/src/progs/gtk/GtkObjectController.h index 4a09b9c7..f80db6a4 100644 --- a/src/progs/gtk/GtkObjectController.h +++ b/src/progs/gtk/GtkObjectController.h @@ -22,7 +22,7 @@ #include "ObjectModel.h" #include "ObjectController.h" - +#include "util/CountedPtr.h" using std::string; @@ -44,7 +44,7 @@ class Controller; class GtkObjectController : public LibOmClient::ObjectController { public: - GtkObjectController(ObjectModel* model); + GtkObjectController(CountedPtr<ObjectModel> model); virtual ~GtkObjectController() {} /** Destroy object. @@ -54,9 +54,10 @@ public: */ virtual void destroy() = 0; +/* virtual void add_to_store() = 0; virtual void remove_from_store() = 0; - +*/ virtual void metadata_update(const string& key, const string& value); /** Rename object */ @@ -65,10 +66,10 @@ public: const Path& path() const { return m_model->path(); } - ObjectModel* model() const { return m_model; } + CountedPtr<ObjectModel> model() const { return m_model; } protected: - ObjectModel* m_model; ///< Model for this object + CountedPtr<ObjectModel> m_model; ///< Model for this object }; diff --git a/src/progs/gtk/LoadSubpatchWindow.cpp b/src/progs/gtk/LoadSubpatchWindow.cpp index fe02d772..1c8f8fe2 100644 --- a/src/progs/gtk/LoadSubpatchWindow.cpp +++ b/src/progs/gtk/LoadSubpatchWindow.cpp @@ -128,7 +128,7 @@ void LoadSubpatchWindow::ok_clicked() { assert(m_patch_controller != NULL); - assert(m_patch_controller->model() != NULL); + assert(m_patch_controller->model()); // These values are interpreted by load_patch() as "not defined", ie load from file string name = ""; @@ -149,7 +149,7 @@ LoadSubpatchWindow::ok_clicked() PatchModel* pm = new PatchModel(m_patch_controller->model()->base_path() + name, poly); pm->filename(get_filename()); - pm->set_parent(m_patch_controller->model()); + pm->set_parent(m_patch_controller->model().get()); pm->x(m_new_module_x); pm->y(m_new_module_y); if (name == "") diff --git a/src/progs/gtk/NewSubpatchWindow.cpp b/src/progs/gtk/NewSubpatchWindow.cpp index dcc2cd2d..742f6d63 100644 --- a/src/progs/gtk/NewSubpatchWindow.cpp +++ b/src/progs/gtk/NewSubpatchWindow.cpp @@ -79,6 +79,8 @@ NewSubpatchWindow::name_changed() void NewSubpatchWindow::ok_clicked() { + cerr << "FIXME new subpatch\n"; + /* PatchModel* pm = new PatchModel( m_patch_controller->model()->base_path() + m_name_entry->get_text(), m_poly_spinbutton->get_value_as_int()); @@ -87,6 +89,7 @@ NewSubpatchWindow::ok_clicked() m_patch_controller->get_new_module_location( m_new_module_x, m_new_module_y); } + pm->set_parent(m_patch_controller->patch_model()); pm->x(m_new_module_x); pm->y(m_new_module_y); @@ -97,6 +100,7 @@ NewSubpatchWindow::ok_clicked() pm->set_metadata("module-y", temp_buf); Controller::instance().create_patch_from_model(pm); hide(); + */ } diff --git a/src/progs/gtk/NodeController.cpp b/src/progs/gtk/NodeController.cpp index 57756877..ae3e5a9e 100644 --- a/src/progs/gtk/NodeController.cpp +++ b/src/progs/gtk/NodeController.cpp @@ -38,7 +38,7 @@ using std::cerr; using std::endl; namespace OmGtk { -NodeController::NodeController(NodeModel* model) +NodeController::NodeController(CountedPtr<NodeModel> model) : GtkObjectController(model), m_controls_menuitem(NULL), m_module(NULL), @@ -50,14 +50,16 @@ NodeController::NodeController(NodeModel* model) model->set_controller(this); // Create port controllers + cerr << "FIXME: node" << endl; + /* for (list<PortModel*>::const_iterator i = node_model()->ports().begin(); i != node_model()->ports().end(); ++i) { assert((*i)->controller() == NULL); - assert((*i)->parent() == model); + assert((*i)->parent() == model.get()); PortController* const pc = new PortController(*i); assert((*i)->controller() == pc); // PortController() does this } - + // Build menu Gtk::Menu::MenuList& items = m_menu.items(); @@ -87,6 +89,7 @@ NodeController::NodeController(NodeModel* model) items.push_back(Gtk::Menu_Helpers::MenuElem("Learn", sigc::mem_fun(this, &NodeController::on_menu_learn))); } + */ } @@ -112,7 +115,7 @@ NodeController::create_module(OmFlowCanvas* canvas) m_module->move_to(node_model()->x(), node_model()->y()); } - +/* void NodeController::add_to_store() { @@ -143,11 +146,13 @@ NodeController::remove_from_store() // Remove self Store::instance().remove_object(this); } - +*/ void NodeController::set_path(const Path& new_path) { + cerr << "FIXME: rename\n"; + /* remove_from_store(); // Rename ports @@ -168,6 +173,7 @@ NodeController::set_path(const Path& new_path) GtkObjectController::set_path(new_path); add_to_store(); + */ } @@ -177,7 +183,7 @@ NodeController::destroy() PatchController* pc = ((PatchController*)m_model->parent()->controller()); assert(pc != NULL); - remove_from_store(); + //remove_from_store(); pc->remove_node(m_model->path().name()); if (m_bridge_port != NULL) @@ -222,7 +228,7 @@ NodeController::add_port(PortModel* pm) node_model()->add_port(pm); PortController* pc = new PortController(pm); assert(pm->controller() == pc); - pc->add_to_store(); + //pc->add_to_store(); if (m_module != NULL) { pc->create_port(m_module); @@ -286,7 +292,7 @@ NodeController::show_rename_window() void NodeController::on_menu_clone() { - assert(node_model() != NULL); + assert(node_model()); //assert(m_parent != NULL); //assert(m_parent->model() != NULL); @@ -377,11 +383,12 @@ NodeController::create_all_ports() bool NodeController::has_control_inputs() { +/* for (PortModelList::const_iterator i = node_model()->ports().begin(); i != node_model()->ports().end(); ++i) if ((*i)->is_input() && (*i)->is_control()) return true; - +*/ return false; } diff --git a/src/progs/gtk/NodeController.h b/src/progs/gtk/NodeController.h index ed2a6d59..7d732d2f 100644 --- a/src/progs/gtk/NodeController.h +++ b/src/progs/gtk/NodeController.h @@ -21,14 +21,16 @@ #include <gtkmm.h> #include "util/Path.h" #include "GtkObjectController.h" +#include "NodeModel.h" using std::string; using Om::Path; using namespace LibOmClient; +template <class T> class CountedPtr; + namespace LibOmClient { class MetadataModel; - class NodeModel; class PortModel; } @@ -48,13 +50,13 @@ class OmFlowCanvas; class NodeController : public GtkObjectController { public: - NodeController(NodeModel* model); + NodeController(CountedPtr<NodeModel> model); virtual ~NodeController(); virtual void destroy(); - virtual void add_to_store(); - virtual void remove_from_store(); + /*virtual void add_to_store(); + virtual void remove_from_store();*/ virtual void metadata_update(const string& key, const string& value); @@ -73,7 +75,7 @@ public: void bridge_port(PortController* port) { m_bridge_port = port; } PortController* as_port() { return m_bridge_port; } - NodeModel* node_model() { return (NodeModel*)m_model; } + CountedPtr<NodeModel> node_model() { return CountedPtr<NodeModel>((NodeModel*)m_model.get()); } NodeControlWindow* control_window() { return m_control_window; } void control_window(NodeControlWindow* cw) { m_control_window = cw; } diff --git a/src/progs/gtk/NodePropertiesWindow.cpp b/src/progs/gtk/NodePropertiesWindow.cpp index 048f2513..000fa6ac 100644 --- a/src/progs/gtk/NodePropertiesWindow.cpp +++ b/src/progs/gtk/NodePropertiesWindow.cpp @@ -26,6 +26,7 @@ using std::string; NodePropertiesWindow::NodePropertiesWindow(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& glade_xml) : Gtk::Window(cobject) +, m_node_model(NULL) { glade_xml->get_widget("node_properties_path_label", m_node_path_label); glade_xml->get_widget("node_properties_polyphonic_checkbutton", m_node_polyphonic_toggle); @@ -39,9 +40,9 @@ NodePropertiesWindow::NodePropertiesWindow(BaseObjectType* cobject, const Glib:: * This function MUST be called before using this object in any way. */ void -NodePropertiesWindow::set_node(NodeModel* node_model) +NodePropertiesWindow::set_node(CountedPtr<NodeModel> node_model) { - assert(node_model != NULL); + assert(node_model); m_node_model = node_model; diff --git a/src/progs/gtk/NodePropertiesWindow.h b/src/progs/gtk/NodePropertiesWindow.h index efff01bb..1710823b 100644 --- a/src/progs/gtk/NodePropertiesWindow.h +++ b/src/progs/gtk/NodePropertiesWindow.h @@ -19,6 +19,7 @@ #include <gtkmm.h> #include <libglademm.h> +#include "util/CountedPtr.h" namespace LibOmClient { class NodeModel; } using namespace LibOmClient; @@ -37,17 +38,16 @@ class NodePropertiesWindow : public Gtk::Window public: NodePropertiesWindow(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& refGlade); - void set_node(NodeModel* node_model); + void set_node(CountedPtr<NodeModel> node_model); private: - NodeModel* m_node_model; - - Gtk::Label* m_node_path_label; - Gtk::CheckButton* m_node_polyphonic_toggle; - Gtk::Label* m_plugin_type_label; - Gtk::Label* m_plugin_uri_label; - Gtk::Label* m_plugin_name_label; + CountedPtr<NodeModel> m_node_model; + Gtk::Label* m_node_path_label; + Gtk::CheckButton* m_node_polyphonic_toggle; + Gtk::Label* m_plugin_type_label; + Gtk::Label* m_plugin_uri_label; + Gtk::Label* m_plugin_name_label; }; } // namespace OmGtk diff --git a/src/progs/gtk/OmPort.cpp b/src/progs/gtk/OmPort.cpp index b43b8294..d51adc77 100644 --- a/src/progs/gtk/OmPort.cpp +++ b/src/progs/gtk/OmPort.cpp @@ -28,12 +28,12 @@ using namespace LibOmClient; namespace OmGtk { -OmPort::OmPort(OmModule* module, PortModel* pm) -: Port(module, pm->name(), pm->is_input(), App::instance().configuration()->get_port_color(pm)), +OmPort::OmPort(OmModule* module, CountedPtr<PortModel> pm) +: Port(module, pm->name(), pm->is_input(), App::instance().configuration()->get_port_color(pm.get())), m_port_model(pm) { - assert(module != NULL); - assert(m_port_model != NULL); + assert(module); + assert(m_port_model); } #if 0 diff --git a/src/progs/gtk/OmPort.h b/src/progs/gtk/OmPort.h index 69a867d5..a4bd653e 100644 --- a/src/progs/gtk/OmPort.h +++ b/src/progs/gtk/OmPort.h @@ -20,6 +20,7 @@ #include <cassert> #include <string> #include <flowcanvas/Port.h> +#include "util/CountedPtr.h" namespace LibOmClient { class PortModel; } using namespace LibOmClient; @@ -41,16 +42,16 @@ class OmModule; class OmPort : public LibFlowCanvas::Port { public: - OmPort(OmModule* module, PortModel* pm); + OmPort(OmModule* module, CountedPtr<PortModel> pm); virtual ~OmPort() {} //void set_name(const string& n); - PortModel* model() const { return m_port_model; } + CountedPtr<PortModel> model() const { return m_port_model; } private: - PortModel* m_port_model; + CountedPtr<PortModel> m_port_model; }; diff --git a/src/progs/gtk/PatchController.cpp b/src/progs/gtk/PatchController.cpp index 83ba62d9..cbdf1472 100644 --- a/src/progs/gtk/PatchController.cpp +++ b/src/progs/gtk/PatchController.cpp @@ -51,10 +51,11 @@ using namespace LibOmClient; namespace OmGtk { -PatchController::PatchController(PatchModel* model) +PatchController::PatchController(CountedPtr<PatchModel> model) : NodeController(model), m_window(NULL), m_patch_view(NULL), + m_patch_model(model), m_module_x(0), m_module_y(0) { @@ -62,13 +63,13 @@ PatchController::PatchController(PatchModel* model) assert(model->parent() == NULL); assert(model->controller() == this); // NodeController() does this - if (model->path() != "/") { +/* FIXME if (model->path() != "/") { PatchController* parent = Store::instance().patch(model->path().parent()); if (parent != NULL) parent->add_subpatch(this); else cerr << "[PatchController] " << path() << " ERROR: Parent not found." << endl; - } + }*/ } @@ -94,7 +95,7 @@ PatchController::~PatchController() } } - +/* void PatchController::add_to_store() { @@ -107,7 +108,7 @@ PatchController::remove_from_store() { Store::instance().remove_object(this); } - +*/ void PatchController::clear() @@ -161,7 +162,7 @@ PatchController::destroy() //patch_model()->clear(); // Remove self from object store - Store::instance().remove_object(this); + //Store::instance().remove_object(this); // Delete self from parent (this will delete model) if (patch_model()->parent() != NULL) { @@ -169,7 +170,7 @@ PatchController::destroy() assert(parent != NULL); parent->remove_node(name()); } else { - delete m_model; + //delete m_model; } } @@ -187,7 +188,7 @@ PatchController::metadata_update(const string& key, const string& value) void PatchController::set_path(const Path& new_path) { - assert(m_model != NULL); + assert(m_model); Path old_path = path(); // Rename nodes @@ -230,9 +231,9 @@ PatchController::set_path(const Path& new_path) if (parent != NULL && parent->window() != NULL) parent->window()->node_renamed(old_path, new_path); - remove_from_store(); + //remove_from_store(); GtkObjectController::set_path(new_path); - add_to_store(); + //add_to_store(); if (old_path.name() != new_path.name()) parent->patch_model()->rename_node(old_path, new_path); @@ -356,11 +357,13 @@ PatchController::create_connection(const ConnectionModel* cm) // Disable control slider from destination node control window - PortController* p = Store::instance().port(cm->dst_port_path()); + cerr << "FIXME: create_connection\n"; + /*PortController* p = Store::instance().port(cm->dst_port_path()); assert(p != NULL); if (p->control_panel() != NULL) - p->control_panel()->disable_port(p->path()); + p->control_panel()->disable_port(p->path());*/ + // FIXME: don't use canvas as a model (search object store) /*OmModule* m = (OmModule*)m_patch_view->canvas()->find_module( cm->dst_port_path().parent().name()); @@ -385,8 +388,8 @@ void PatchController::add_subpatch(PatchController* patch) { assert(patch != NULL); - assert(patch->patch_model() != NULL); - assert(patch->patch_model()->parent() == NULL); + assert(patch->patch_model()); + assert(patch->patch_model()->parent()); /*if (pm->x() == 0 && pm->y() == 0) { int x, y; @@ -395,7 +398,7 @@ PatchController::add_subpatch(PatchController* patch) pm->y(y); }*/ - patch_model()->add_node(patch->patch_model()); + //patch_model()->add_node(patch->patch_model()); if (m_patch_view != NULL) { patch->create_module(m_patch_view->canvas()); @@ -436,7 +439,7 @@ PatchController::add_node(NodeModel* nm) nc->bridge_port(pc); } - nc->add_to_store(); + //nc->add_to_store(); patch_model()->add_node(nm); if (m_patch_view != NULL) { @@ -511,7 +514,7 @@ PatchController::add_port(PortModel* pm) PortController* pc = new PortController(pm); // Handle bridge ports/nodes (this is uglier than it should be) - NodeController* nc = Store::instance().node(pm->path()); + NodeController* nc = (NodeController*)Store::instance().node(pm->path())->controller(); if (nc != NULL) nc->bridge_port(pc); @@ -593,12 +596,15 @@ PatchController::disconnection(const Path& src_port_path, const Path& dst_port_p patch_model()->remove_connection(src_port_path, dst_port_path); + cerr << "FIXME: disconnection\n"; + /* // Enable control slider in destination node control window - PortController* p = Store::instance().port(dst_port_path); + PortController* p = (PortController)Store::instance().port(dst_port_path)->controller(); assert(p != NULL); if (p->control_panel() != NULL) p->control_panel()->enable_port(p->path()); + */ } @@ -652,7 +658,7 @@ PatchController::claim_patch_view() void PatchController::show_control_window() { - assert(patch_model() != NULL); + assert(patch_model()); if (m_control_window == NULL) m_control_window = new NodeControlWindow(this, patch_model()->poly()); diff --git a/src/progs/gtk/PatchController.h b/src/progs/gtk/PatchController.h index de4af5e4..d9491571 100644 --- a/src/progs/gtk/PatchController.h +++ b/src/progs/gtk/PatchController.h @@ -20,6 +20,8 @@ #include <string> #include <gtkmm.h> #include "NodeController.h" +#include "PatchModel.h" +template <class T> class CountedPtr; namespace LibOmClient { class PatchModel; @@ -57,11 +59,13 @@ class NodeController; class PatchController : public NodeController { public: - PatchController(PatchModel* model); + PatchController(CountedPtr<PatchModel> model); virtual ~PatchController(); + /* virtual void add_to_store(); virtual void remove_from_store(); + */ virtual void destroy(); @@ -101,7 +105,7 @@ public: void enable(); void disable(); - PatchModel* patch_model() const { return (PatchModel*)m_model; } + CountedPtr<PatchModel> patch_model() const { return m_patch_model; } void enable_controls_menuitem(); void disable_controls_menuitem(); @@ -112,6 +116,8 @@ private: PatchWindow* m_window; ///< Window currently showing this patch PatchView* m_patch_view; ///< View (canvas) of this patch + CountedPtr<PatchModel> m_patch_model; + /** Invisible bin used to store patch view when not shown by a patch window */ Gtk::Alignment m_patch_view_bin; diff --git a/src/progs/gtk/PatchDescriptionWindow.cpp b/src/progs/gtk/PatchDescriptionWindow.cpp index d10a9c0e..7ae154c3 100644 --- a/src/progs/gtk/PatchDescriptionWindow.cpp +++ b/src/progs/gtk/PatchDescriptionWindow.cpp @@ -24,6 +24,7 @@ using std::string; PatchDescriptionWindow::PatchDescriptionWindow(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& glade_xml) : Gtk::Window(cobject) +, m_patch_model(NULL) { glade_xml->get_widget("description_author_entry", m_author_entry); glade_xml->get_widget("description_description_textview", m_textview); @@ -41,7 +42,7 @@ PatchDescriptionWindow::PatchDescriptionWindow(BaseObjectType* cobject, const Gl * the window in any way. */ void -PatchDescriptionWindow::patch_model(PatchModel* patch_model) +PatchDescriptionWindow::patch_model(CountedPtr<PatchModel> patch_model) { property_title() = patch_model->path() + " Properties"; m_patch_model = patch_model; diff --git a/src/progs/gtk/PatchDescriptionWindow.h b/src/progs/gtk/PatchDescriptionWindow.h index 7c00faab..0ad8b286 100644 --- a/src/progs/gtk/PatchDescriptionWindow.h +++ b/src/progs/gtk/PatchDescriptionWindow.h @@ -20,6 +20,7 @@ #include <string> #include <gtkmm.h> #include <libglademm/xml.h> +#include "util/CountedPtr.h" using std::string; namespace LibOmClient { class PatchModel; } @@ -39,13 +40,13 @@ class PatchDescriptionWindow : public Gtk::Window public: PatchDescriptionWindow(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& refGlade); - void patch_model(PatchModel* patch_model); + void patch_model(CountedPtr<PatchModel> patch_model); void cancel_clicked(); void ok_clicked(); private: - PatchModel* m_patch_model; + CountedPtr<PatchModel> m_patch_model; Gtk::Entry* m_author_entry; Gtk::TextView* m_textview; diff --git a/src/progs/gtk/PatchTreeWindow.cpp b/src/progs/gtk/PatchTreeWindow.cpp index 065f4d6a..78ee9428 100644 --- a/src/progs/gtk/PatchTreeWindow.cpp +++ b/src/progs/gtk/PatchTreeWindow.cpp @@ -66,7 +66,7 @@ PatchTreeWindow::PatchTreeWindow(BaseObjectType* cobject, void PatchTreeWindow::add_patch(PatchController* pc) { - PatchModel* const pm = pc->patch_model(); + const CountedPtr<PatchModel> pm = pc->patch_model(); if (pm->parent() == NULL) { Gtk::TreeModel::iterator iter = m_patch_treestore->append(); diff --git a/src/progs/gtk/PatchWindow.cpp b/src/progs/gtk/PatchWindow.cpp index 1513d473..9387257f 100644 --- a/src/progs/gtk/PatchWindow.cpp +++ b/src/progs/gtk/PatchWindow.cpp @@ -212,9 +212,9 @@ PatchWindow::patch_controller(PatchController* pc) old_pc->model()->path().substr(0, pc->model()->path().length()) == pc->model()->path()) { for (list<BreadCrumb*>::iterator i = m_breadcrumbs.begin(); i != m_breadcrumbs.end(); ++i) { - if ((*i)->patch() == pc) + if ((*i)->path() == pc->path()) (*i)->set_active(true); - else if ((*i)->patch() == old_pc) + else if ((*i)->path() == old_pc->path()) (*i)->set_active(false); } @@ -255,7 +255,7 @@ PatchWindow::rebuild_breadcrumbs() // Add root assert(path[0] == '/'); - BreadCrumb* but = manage(new BreadCrumb(this, Store::instance().patch("/"))); + BreadCrumb* but = manage(new BreadCrumb(this, "/")); m_breadcrumb_box->pack_start(*but, false, false, 1); m_breadcrumbs.push_back(but); path = path.substr(1); // hack off leading slash @@ -271,7 +271,7 @@ PatchWindow::rebuild_breadcrumbs() but_path += string("/") + path; path = ""; } - BreadCrumb* but = manage(new BreadCrumb(this, Store::instance().patch(but_path))); + BreadCrumb* but = manage(new BreadCrumb(this, but_path));//Store::instance().patch(but_path))); m_breadcrumb_box->pack_start(*but, false, false, 1); m_breadcrumbs.push_back(but); } @@ -283,6 +283,8 @@ PatchWindow::rebuild_breadcrumbs() void PatchWindow::breadcrumb_clicked(BreadCrumb* crumb) { + cerr << "FIXME: crumb\n"; + /* if (m_enable_signal) { PatchController* const pc = crumb->patch(); assert(pc != NULL); @@ -296,6 +298,7 @@ PatchWindow::breadcrumb_clicked(BreadCrumb* crumb) patch_controller(pc); } } + */ } @@ -324,7 +327,7 @@ void PatchWindow::node_removed(const string& name) { for (list<BreadCrumb*>::iterator i = m_breadcrumbs.begin(); i != m_breadcrumbs.end(); ++i) { - if ((*i)->patch()->path() == m_patch->model()->base_path() + name) { + if ((*i)->path() == m_patch->model()->base_path() + name) { for (list<BreadCrumb*>::iterator j = i; j != m_breadcrumbs.end(); ) { BreadCrumb* bc = *j; j = m_breadcrumbs.erase(j); @@ -342,8 +345,8 @@ void PatchWindow::node_renamed(const string& old_path, const string& new_path) { for (list<BreadCrumb*>::iterator i = m_breadcrumbs.begin(); i != m_breadcrumbs.end(); ++i) { - if ((*i)->patch()->model()->path() == old_path) - (*i)->path(new_path); + if ((*i)->path() == old_path) + (*i)->set_path(new_path); } } @@ -355,8 +358,8 @@ PatchWindow::patch_renamed(const string& new_path) { set_title(new_path); for (list<BreadCrumb*>::iterator i = m_breadcrumbs.begin(); i != m_breadcrumbs.end(); ++i) { - if ((*i)->patch() == m_patch) - (*i)->path(new_path); + if ((*i)->path() == m_patch->path()) + (*i)->set_path(new_path); } } @@ -379,7 +382,7 @@ PatchWindow::event_open_into() void PatchWindow::event_save() { - PatchModel* const model = m_patch->patch_model(); + PatchModel* const model = m_patch->patch_model().get(); if (model->filename() == "") event_save_as(); @@ -439,7 +442,7 @@ PatchWindow::event_save_as() fin.close(); if (confirm) { - Controller::instance().save_patch(m_patch->patch_model(), filename, recursive); + Controller::instance().save_patch(m_patch->patch_model().get(), filename, recursive); m_patch->patch_model()->filename(filename); } } diff --git a/src/progs/gtk/PortController.cpp b/src/progs/gtk/PortController.cpp index ec05541b..1e840583 100644 --- a/src/progs/gtk/PortController.cpp +++ b/src/progs/gtk/PortController.cpp @@ -36,7 +36,7 @@ PortController::PortController(PortModel* model) model->set_controller(this); } - +/* void PortController::add_to_store() { @@ -49,7 +49,7 @@ PortController::remove_from_store() { Store::instance().remove_object(this); } - +*/ void PortController::destroy() diff --git a/src/progs/gtk/PortController.h b/src/progs/gtk/PortController.h index cc2f9dc3..6172025f 100644 --- a/src/progs/gtk/PortController.h +++ b/src/progs/gtk/PortController.h @@ -49,9 +49,10 @@ public: virtual void destroy(); +/* virtual void add_to_store(); virtual void remove_from_store(); - +*/ virtual void metadata_update(const string& key, const string& value); void create_port(OmModule* module); @@ -62,7 +63,7 @@ public: ControlPanel* control_panel() const { return m_control_panel; } void set_control_panel(ControlPanel* cp); - PortModel* port_model() const { return (PortModel*)m_model; } + CountedPtr<PortModel> port_model() const { return CountedPtr<PortModel>((PortModel*)m_model.get()); } private: OmPort* m_port; ///< Canvas module port diff --git a/src/progs/gtk/RenameWindow.cpp b/src/progs/gtk/RenameWindow.cpp index bde9a2c1..78f4d067 100644 --- a/src/progs/gtk/RenameWindow.cpp +++ b/src/progs/gtk/RenameWindow.cpp @@ -59,17 +59,17 @@ RenameWindow::set_object(GtkObjectController* object) void RenameWindow::name_changed() { - assert(m_name_entry != NULL); - assert(m_message_label != NULL); - assert(m_object->model() != NULL); - assert(m_object->model()->parent() != NULL); + assert(m_name_entry); + assert(m_message_label); + assert(m_object->model()); + assert(m_object->model()->parent()); string name = m_name_entry->get_text(); if (name.find("/") != string::npos) { m_message_label->set_text("Name may not contain '/'"); m_ok_button->property_sensitive() = false; //} else if (m_object->parent()->patch_model()->get_node(name) != NULL) { - } else if (Store::instance().object(m_object->model()->parent()->base_path() + name) != NULL) { + } else if (Store::instance().object(m_object->model()->parent()->base_path() + name)) { m_message_label->set_text("An object already exists with that name."); m_ok_button->property_sensitive() = false; } else if (name.length() == 0) { diff --git a/src/progs/gtk/Store.cpp b/src/progs/gtk/Store.cpp index 97e556c9..c68bdc75 100644 --- a/src/progs/gtk/Store.cpp +++ b/src/progs/gtk/Store.cpp @@ -15,11 +15,12 @@ */ #include "Store.h" -#include "GtkObjectController.h" -#include "PatchController.h" -#include "NodeController.h" -#include "PortController.h" +#include "ObjectModel.h" +#include "PatchModel.h" +#include "NodeModel.h" +#include "PortModel.h" #include "PluginModel.h" +#include "PatchModel.h" #include "SigClientInterface.h" namespace OmGtk { @@ -29,10 +30,14 @@ Store::Store(SigClientInterface& emitter) //emitter.new_plugin_sig.connect(sigc::mem_fun(this, &Store::add_plugin)); emitter.object_destroyed_sig.connect(sigc::mem_fun(this, &Store::destruction_event)); emitter.new_plugin_sig.connect(sigc::mem_fun(this, &Store::new_plugin_event)); + emitter.new_patch_sig.connect(sigc::mem_fun(this, &Store::new_patch_event)); + emitter.new_node_sig.connect(sigc::mem_fun(this, &Store::new_node_event)); + emitter.new_port_sig.connect(sigc::mem_fun(this, &Store::new_port_event)); } + void -Store::add_object(GtkObjectController* object) +Store::add_object(ObjectModel* object) { assert(object->path() != ""); assert(m_objects.find(object->path()) == m_objects.end()); @@ -44,19 +49,19 @@ Store::add_object(GtkObjectController* object) void -Store::remove_object(GtkObjectController* object) +Store::remove_object(ObjectModel* object) { if (!object) return; - map<string, GtkObjectController*>::iterator i - = m_objects.find(object->model()->path()); + map<string, ObjectModel*>::iterator i + = m_objects.find(object->path()); if (i != m_objects.end()) { assert((*i).second == object); m_objects.erase(i); } else { - cerr << "[App] Unable to find object " << object->model()->path() + cerr << "[App] Unable to find object " << object->path() << " to remove." << endl; } @@ -64,11 +69,11 @@ Store::remove_object(GtkObjectController* object) } -GtkObjectController* +CountedPtr<ObjectModel> Store::object(const string& path) const { assert(path.length() > 0); - map<string, GtkObjectController*>::const_iterator i = m_objects.find(path); + map<string, ObjectModel*>::const_iterator i = m_objects.find(path); if (i == m_objects.end()) return NULL; else @@ -76,47 +81,51 @@ Store::object(const string& path) const } -PatchController* +CountedPtr<PatchModel> Store::patch(const string& path) const { assert(path.length() > 0); - map<string, GtkObjectController*>::const_iterator i = m_objects.find(path); + map<string, ObjectModel*>::const_iterator i = m_objects.find(path); if (i == m_objects.end()) return NULL; else - return dynamic_cast<PatchController*>((*i).second); + return dynamic_cast<PatchModel*>((*i).second); } -NodeController* +CountedPtr<NodeModel> Store::node(const string& path) const { assert(path.length() > 0); - map<string, GtkObjectController*>::const_iterator i = m_objects.find(path); + map<string, ObjectModel*>::const_iterator i = m_objects.find(path); if (i == m_objects.end()) return NULL; else - return dynamic_cast<NodeController*>((*i).second); + return dynamic_cast<NodeModel*>((*i).second); } -PortController* +CountedPtr<PortModel> Store::port(const string& path) const { assert(path.length() > 0); - map<string, GtkObjectController*>::const_iterator i = m_objects.find(path); + map<string, ObjectModel*>::const_iterator i = m_objects.find(path); if (i == m_objects.end()) { return NULL; } else { // Normal port - PortController* const pc = dynamic_cast<PortController*>((*i).second); - if (pc != NULL) + PortModel* const pc = dynamic_cast<PortModel*>((*i).second); + if (pc) return pc; // Patch port (corresponding Node is in store) - NodeController* const nc = dynamic_cast<NodeController*>((*i).second); - if (nc != NULL) + // FIXME + // + /* + NodeModel* const nc = dynamic_cast<NodeModel*>((*i).second); + if (nc) return nc->as_port(); // Patch port (maybe) + */ } return NULL; @@ -135,12 +144,14 @@ Store::add_plugin(const PluginModel* pm) } -/* ****** Slots ******** */ + +/* ****** Signal Handlers ******** */ + void Store::destruction_event(const string& path) { - remove_object(object(path)); + remove_object(object(path).get()); } void @@ -151,5 +162,44 @@ Store::new_plugin_event(const string& type, const string& uri, const string& nam add_plugin(p); } + +void +Store::new_patch_event(const string& path, uint32_t poly) +{ + PatchModel* const p = new PatchModel(path, poly); + add_object(p); +} + +void +Store::new_node_event(const string& plugin_type, const string& plugin_uri, const string& node_path, bool is_polyphonic, uint32_t num_ports) +{ + // FIXME: resolve plugin here + + NodeModel* const n = new NodeModel(node_path); + n->polyphonic(is_polyphonic); + // FIXME: num_ports unused + add_object(n); +} + + +void +Store::new_port_event(const string& path, const string& type, bool is_output) +{ + // FIXME: this sucks + + PortModel::Type ptype = PortModel::CONTROL; + if (type == "AUDIO") ptype = PortModel::AUDIO; + else if (type == "CONTROL") ptype = PortModel::CONTROL; + else if (type== "MIDI") ptype = PortModel::MIDI; + else cerr << "[OSCListener] WARNING: Unknown port type received (" << type << ")" << endl; + + PortModel::Direction pdir = is_output ? PortModel::OUTPUT : PortModel::INPUT; + + PortModel* const p = new PortModel(path, ptype, pdir); + add_object(p); + +} + + } // namespace OmGtk diff --git a/src/progs/gtk/Store.h b/src/progs/gtk/Store.h index 9fb4b270..d3bcbf94 100644 --- a/src/progs/gtk/Store.h +++ b/src/progs/gtk/Store.h @@ -20,17 +20,22 @@ #include <cassert> #include <string> #include <map> +#include "util/CountedPtr.h" using std::string; using std::map; -namespace LibOmClient { class PatchModel; class PluginModel; class SigClientInterface; } +namespace LibOmClient { + class SigClientInterface; + class ObjectModel; + class PluginModel; + class PatchModel; + class NodeModel; + class PortModel; +} using namespace LibOmClient; namespace OmGtk { -class GtkObjectController; -class PatchController; -class NodeController; -class PortController; + /** Singeton which holds all "Om Objects" for easy/fast lookup * @@ -38,14 +43,11 @@ class PortController; */ class Store { public: - GtkObjectController* object(const string& path) const; - PatchController* patch(const string& path) const; - NodeController* node(const string& path) const; - PortController* port(const string& path) const; + CountedPtr<ObjectModel> object(const string& path) const; + CountedPtr<PatchModel> patch(const string& path) const; + CountedPtr<NodeModel> node(const string& path) const; + CountedPtr<PortModel> port(const string& path) const; - void add_object(GtkObjectController* object); - void remove_object(GtkObjectController* object); - size_t num_objects() { return m_objects.size(); } void add_plugin(const PluginModel* pm); @@ -61,12 +63,18 @@ private: static Store* _instance; + void add_object(ObjectModel* object); + void remove_object(ObjectModel* object); + // Slots for SigClientInterface signals void destruction_event(const string& path); void new_plugin_event(const string& type, const string& uri, const string& name); + void new_patch_event(const string& path, uint32_t poly); + void new_node_event(const string& plugin_type, const string& plugin_uri, const string& node_path, bool is_polyphonic, uint32_t num_ports); + void new_port_event(const string& path, const string& data_type, bool is_output); - map<string, GtkObjectController*> m_objects; ///< Keyed by Om path - map<string, const PluginModel*> m_plugins; ///< Keyed by URI + map<string, ObjectModel*> m_objects; ///< Keyed by Om path + map<string, const PluginModel*> m_plugins; ///< Keyed by URI }; |