diff options
Diffstat (limited to 'src/libs')
34 files changed, 279 insertions, 326 deletions
diff --git a/src/libs/client/ModelClientInterface.cpp b/src/libs/client/ModelClientInterface.cpp index deb37187..d29395e7 100644 --- a/src/libs/client/ModelClientInterface.cpp +++ b/src/libs/client/ModelClientInterface.cpp @@ -86,17 +86,17 @@ ModelClientInterface::new_patch(string path, uint32_t poly) void -ModelClientInterface::new_node(string plugin_type, - string plugin_uri, - string node_path, - bool is_polyphonic, - uint32_t num_ports) +ModelClientInterface::new_node(string plugin_type, + string plugin_uri, + string node_path, + bool is_polyphonic, + uint32_t num_ports) { cerr << "FIXME: NEW NODE\n"; CountedPtr<PluginModel> plugin(new PluginModel(plugin_type, plugin_uri)); - CountedPtr<NodeModel> nm(new NodeModel(plugin, node_path)); + CountedPtr<NodeModel> nm(new NodeModel(plugin, node_path, is_polyphonic)); new_node_model(nm); } diff --git a/src/libs/client/ModelEngineInterface.cpp b/src/libs/client/ModelEngineInterface.cpp index ca92b1ac..7cc2ae22 100644 --- a/src/libs/client/ModelEngineInterface.cpp +++ b/src/libs/client/ModelEngineInterface.cpp @@ -65,8 +65,8 @@ ModelEngineInterface::create_patch_from_model(const PatchModel* pm) void ModelEngineInterface::set_all_metadata(const ObjectModel* m) { - for (map<string, string>::const_iterator i = m->metadata().begin(); i != m->metadata().end(); ++i) - set_metadata(m->path(), (*i).first, (*i).second.c_str()); + for (MetadataMap::const_iterator i = m->metadata().begin(); i != m->metadata().end(); ++i) + set_metadata(m->path(), i->first, i->second); } diff --git a/src/libs/client/NodeModel.cpp b/src/libs/client/NodeModel.cpp index 8d9d8697..55f70130 100644 --- a/src/libs/client/NodeModel.cpp +++ b/src/libs/client/NodeModel.cpp @@ -22,22 +22,18 @@ namespace Ingen { namespace Client { -NodeModel::NodeModel(CountedPtr<PluginModel> plugin, const Path& path) +NodeModel::NodeModel(CountedPtr<PluginModel> plugin, const Path& path, bool polyphonic) : ObjectModel(path), - m_polyphonic(false), + m_polyphonic(polyphonic), m_plugin_uri(plugin->uri()), - m_plugin(plugin), - m_x(0.0f), - m_y(0.0f) + m_plugin(plugin) { } -NodeModel::NodeModel(const string& plugin_uri, const Path& path) +NodeModel::NodeModel(const string& plugin_uri, const Path& path, bool polyphonic) : ObjectModel(path), - m_polyphonic(false), - m_plugin_uri(plugin_uri), - m_x(0.0f), - m_y(0.0f) + m_polyphonic(polyphonic), + m_plugin_uri(plugin_uri) { } @@ -52,6 +48,7 @@ void NodeModel::remove_port(CountedPtr<PortModel> port) { m_ports.remove(port); + removed_port_sig.emit(port); } @@ -78,12 +75,13 @@ NodeModel::clear() void NodeModel::set_path(const Path& p) { - const string old_path = m_path; + const string old_path = _path; ObjectModel::set_path(p); - for (PortModelList::iterator i = m_ports.begin(); i != m_ports.end(); ++i) - (*i)->set_path(m_path + "/" + (*i)->path().name()); + // FIXME: rename +// for (PortModelList::iterator i = m_ports.begin(); i != m_ports.end(); ++i) +// (*i)->set_path(_path + "/" + (*i)->path().name()); //if (m_parent && old_path.length() > 0) // parent_patch()->rename_node(old_path, p); @@ -104,7 +102,7 @@ NodeModel::add_child(CountedPtr<ObjectModel> c) void NodeModel::remove_child(CountedPtr<ObjectModel> c) { - assert(c->path().is_child_of(m_path)); + assert(c->path().is_child_of(_path)); assert(c->parent().get() == this); CountedPtr<PortModel> pm = PtrCast<PortModel>(c); @@ -117,7 +115,7 @@ void NodeModel::add_port(CountedPtr<PortModel> pm) { assert(pm); - assert(pm->path().is_child_of(m_path)); + assert(pm->path().is_child_of(_path)); assert(pm->parent().get() == this); PortModelList::iterator existing = m_ports.end(); @@ -129,7 +127,7 @@ NodeModel::add_port(CountedPtr<PortModel> pm) } if (existing != m_ports.end()) { - cerr << "Warning: port clash, assimilating old port " << m_path << endl; + cerr << "Warning: port clash, assimilating old port " << _path << endl; pm->assimilate(*existing); *existing = pm; } else { @@ -140,10 +138,10 @@ NodeModel::add_port(CountedPtr<PortModel> pm) CountedPtr<PortModel> -NodeModel::get_port(const string& port_name) +NodeModel::get_port(const string& port_name) const { assert(port_name.find("/") == string::npos); - for (PortModelList::iterator i = m_ports.begin(); i != m_ports.end(); ++i) + for (PortModelList::const_iterator i = m_ports.begin(); i != m_ports.end(); ++i) if ((*i)->path().name() == port_name) return (*i); return CountedPtr<PortModel>(); @@ -166,29 +164,5 @@ NodeModel::remove_program(int bank, int program) } -void -NodeModel::x(float a) -{ - if (m_x != a) { - m_x = a; - char temp_buf[16]; - snprintf(temp_buf, 16, "%f", a); - set_metadata("module-x", temp_buf); - } -} - - -void -NodeModel::y(float a) -{ - if (m_y != a) { - m_y = a; - char temp_buf[16]; - snprintf(temp_buf, 16, "%f", a); - set_metadata("module-y", temp_buf); - } -} - - } // namespace Client } // namespace Ingen diff --git a/src/libs/client/NodeModel.h b/src/libs/client/NodeModel.h index 60973d95..f9c87f6e 100644 --- a/src/libs/client/NodeModel.h +++ b/src/libs/client/NodeModel.h @@ -44,55 +44,50 @@ class PluginModel; class NodeModel : public ObjectModel { public: - NodeModel(const string& plugin_uri, const Path& path); - NodeModel(CountedPtr<PluginModel> plugin, const Path& path); + NodeModel(const string& plugin_uri, const Path& path, bool polyphonic); + NodeModel(CountedPtr<PluginModel> plugin, const Path& path, bool polyphonic); virtual ~NodeModel(); - - void add_child(CountedPtr<ObjectModel> c); - void remove_child(CountedPtr<ObjectModel> c); - - CountedPtr<PortModel> get_port(const string& port_name); - void add_port(CountedPtr<PortModel> pm); - void remove_port(CountedPtr<PortModel> pm); - void remove_port(const string& port_path); - - virtual void clear(); - - const map<int, map<int, string> >& get_programs() const { return m_banks; } - void add_program(int bank, int program, const string& name); - void remove_program(int bank, int program); - - string plugin_uri() { return m_plugin_uri; } - CountedPtr<PluginModel> plugin() const { return m_plugin; } - //void plugin(CountedPtr<PluginModel> p) { m_plugin = p; } + CountedPtr<PortModel> get_port(const string& port_name) const; - virtual void set_path(const Path& p); - - int num_ports() const { return m_ports.size(); } - const PortModelList& ports() const { return m_ports; } - virtual bool polyphonic() const { return m_polyphonic; } - void polyphonic(bool b) { m_polyphonic = b; } - float x() const { return m_x; } - float y() const { return m_y; } - void x(float a); - void y(float a); + const map<int, map<int, string> >& get_programs() const { return m_banks; } + const string& plugin_uri() const { return m_plugin_uri; } + CountedPtr<PluginModel> plugin() const { return m_plugin; } + int num_ports() const { return m_ports.size(); } + const PortModelList& ports() const { return m_ports; } + virtual bool polyphonic() const { return m_polyphonic; } // Signals sigc::signal<void, CountedPtr<PortModel> > new_port_sig; + sigc::signal<void, CountedPtr<PortModel> > removed_port_sig; protected: + friend class Store; NodeModel(const Path& path); + void add_child(CountedPtr<ObjectModel> c); + void remove_child(CountedPtr<ObjectModel> c); + void add_port(CountedPtr<PortModel> pm); + void remove_port(CountedPtr<PortModel> pm); + void remove_port(const string& port_path); + void add_program(int bank, int program, const string& name); + void remove_program(int bank, int program); + + + //void plugin(CountedPtr<PluginModel> p) { m_plugin = p; } + virtual void clear(); + + friend class PatchModel; + void set_path(const Path& p); bool m_polyphonic; - PortModelList m_ports; ///< List of ports (instead of map to preserve order) - string m_plugin_uri; ///< Plugin URI (not redundant if PluginModel unknown - CountedPtr<PluginModel> m_plugin; ///< The plugin this node is an instance of - float m_x; ///< Just metadata, here as an optimization for GUI - float m_y; ///< Just metadata, here as an optimization for GUI - map<int, map<int, string> > m_banks; ///< DSSI banks + PortModelList m_ports; ///< List of ports (not a map to preserve order) + string m_plugin_uri; ///< Plugin URI (if PluginModel is unknown) + CountedPtr<PluginModel> m_plugin; ///< The plugin this node is an instance of + map<int, map<int, string> > m_banks; ///< DSSI banks private: + friend class PatchLibrarian; // FIXME: remove + // Prevent copies (undefined) NodeModel(const NodeModel& copy); NodeModel& operator=(const NodeModel& copy); diff --git a/src/libs/client/OSCClientReceiver.cpp b/src/libs/client/OSCClientReceiver.cpp index ae607af1..4c715c76 100644 --- a/src/libs/client/OSCClientReceiver.cpp +++ b/src/libs/client/OSCClientReceiver.cpp @@ -15,8 +15,7 @@ */ #include "OSCClientReceiver.h" -//#include "NodeModel.h" -//#include "PluginModel.h" +#include "util/LibloAtom.h" #include <list> #include <cassert> #include <cstring> @@ -154,7 +153,7 @@ OSCClientReceiver::setup_callbacks() lo_server_thread_add_method(_st, "/om/disconnection", "ss", disconnection_cb, this); lo_server_thread_add_method(_st, "/om/new_node", "sssii", new_node_cb, this); lo_server_thread_add_method(_st, "/om/new_port", "ssi", new_port_cb, this); - lo_server_thread_add_method(_st, "/om/metadata/update", "sss", metadata_update_cb, this); + lo_server_thread_add_method(_st, "/om/metadata/update", NULL, metadata_update_cb, this); lo_server_thread_add_method(_st, "/om/control_change", "sf", control_change_cb, this); lo_server_thread_add_method(_st, "/om/program_add", "siis", program_add_cb, this); lo_server_thread_add_method(_st, "/om/program_remove", "sii", program_remove_cb, this); @@ -337,9 +336,13 @@ OSCClientReceiver::m_new_port_cb(const char* path, const char* types, lo_arg** a int OSCClientReceiver::m_metadata_update_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg) { + if (argc != 3 || types[0] != 's' || types[1] != 's') + return 1; + const char* obj_path = &argv[0]->s; const char* key = &argv[1]->s; - const char* value = &argv[2]->s; + + Atom value = LibloAtom::lo_arg_to_atom(types[2], argv[2]); metadata_update(obj_path, key, value); diff --git a/src/libs/client/OSCEngineSender.cpp b/src/libs/client/OSCEngineSender.cpp index 10d9ab2e..447fa934 100644 --- a/src/libs/client/OSCEngineSender.cpp +++ b/src/libs/client/OSCEngineSender.cpp @@ -17,6 +17,7 @@ #include <iostream> #include "OSCEngineSender.h" #include "interface/ClientKey.h" +#include "util/LibloAtom.h" using std::cout; using std::cerr; using std::endl; namespace Ingen { @@ -374,14 +375,16 @@ OSCEngineSender::midi_learn(const string& node_path) void OSCEngineSender::set_metadata(const string& obj_path, const string& predicate, - const string& value) + const Atom& value) { + assert(_engine_addr); - lo_send(_engine_addr, "/om/metadata/set", "isss", - next_id(), - obj_path.c_str(), - predicate.c_str(), - value.c_str()); + lo_message m = lo_message_new(); + lo_message_add_int32(m, next_id()); + lo_message_add_string(m, obj_path.c_str()); + lo_message_add_string(m, predicate.c_str()); + LibloAtom::lo_message_add_atom(m, value); + lo_send_message(_engine_addr, "/om/metadata/set", m); } diff --git a/src/libs/client/OSCEngineSender.h b/src/libs/client/OSCEngineSender.h index 2603667a..f514097d 100644 --- a/src/libs/client/OSCEngineSender.h +++ b/src/libs/client/OSCEngineSender.h @@ -126,7 +126,7 @@ public: void set_metadata(const string& obj_path, const string& predicate, - const string& value); + const Atom& value); // Requests // diff --git a/src/libs/client/ObjectController.h b/src/libs/client/ObjectController.h deleted file mode 100644 index fca59a80..00000000 --- a/src/libs/client/ObjectController.h +++ /dev/null @@ -1,45 +0,0 @@ -/* This file is part of Ingen. Copyright (C) 2006 Dave Robillard. - * - * Ingen 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. - * - * Ingen 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 OBJECTCONTROLLER_H -#define OBJECTCONTROLLER_H - -namespace Ingen { -namespace Client { - - -/** A trivial base class for controllers of an ObjectModel. - * - * This is so ObjectModels can have pointers to app-specified controllers, - * and the pointer relationships in models (ie PatchModel has pointers to - * all it's NodeModel children, etc) can be used to find controllers of - * Models, rather than having a parallel structure of pointers in the - * app's controllers. - * - * \ingroup IngenClient - */ -class ObjectController -{ -public: - virtual ~ObjectController() {} -}; - - -} // namespace Client -} // namespace Ingen - - -#endif // OBJECTCONTROLLER_H diff --git a/src/libs/client/ObjectModel.cpp b/src/libs/client/ObjectModel.cpp index 4a0eca0d..6e18e680 100644 --- a/src/libs/client/ObjectModel.cpp +++ b/src/libs/client/ObjectModel.cpp @@ -21,34 +21,38 @@ namespace Client { ObjectModel::ObjectModel(const Path& path) -: m_path(path) +: _path(path) { } + ObjectModel::~ObjectModel() { - m_controller.reset(); } -/** Get a piece of metadata for this objeect. +/** Get a piece of metadata for this object. * * @return Metadata value with key @a key, empty string otherwise. */ -string +const Atom& ObjectModel::get_metadata(const string& key) const { - map<string,string>::const_iterator i = m_metadata.find(key); - if (i != m_metadata.end()) + static const Atom null_atom; + + MetadataMap::const_iterator i = _metadata.find(key); + if (i != _metadata.end()) return i->second; else - return ""; + return null_atom; } void -ObjectModel::set_controller(CountedPtr<ObjectController> c) +ObjectModel::add_metadata(const MetadataMap& data) { - m_controller = c; + for (MetadataMap::const_iterator i = data.begin(); i != data.end(); ++i) { + _metadata[i->first] = i->second; + } } @@ -60,13 +64,13 @@ ObjectModel::set_controller(CountedPtr<ObjectController> c) void ObjectModel::assimilate(CountedPtr<ObjectModel> model) { - assert(m_path == model->path()); + assert(_path == model->path()); - for (map<string,string>::const_iterator i = model->metadata().begin(); + for (MetadataMap::const_iterator i = model->metadata().begin(); i != model->metadata().end(); ++i) { - map<string,string>::const_iterator i = m_metadata.find(i->first); - if (i == m_metadata.end()) - m_metadata[i->first] = i->second; + MetadataMap::const_iterator i = _metadata.find(i->first); + if (i == _metadata.end()) + _metadata[i->first] = i->second; } } diff --git a/src/libs/client/ObjectModel.h b/src/libs/client/ObjectModel.h index da3764d1..79d551f5 100644 --- a/src/libs/client/ObjectModel.h +++ b/src/libs/client/ObjectModel.h @@ -24,59 +24,66 @@ #include <algorithm> #include <cassert> #include <sigc++/sigc++.h> +#include "util/Atom.h" #include "util/Path.h" #include "util/CountedPtr.h" -#include "ObjectController.h" using std::string; using std::map; using std::find; using std::cout; using std::cerr; using std::endl; namespace Ingen { namespace Client { -class ObjectController; +typedef map<string, Atom> MetadataMap; + - /** Base class for all GraphObject models (NodeModel, PatchModel, PortModel). * + * There are no non-const public methods intentionally, models are not allowed + * to be manipulated directly by anything (but the Store) because of the + * asynchronous nature of engine control. To change something, use the + * controller (which the model probably shouldn't have a reference to but oh + * well, it reduces Collection Hell) and wait for the result (as a signal + * from this Model). + * * \ingroup IngenClient */ class ObjectModel { public: ObjectModel(const Path& path); - ObjectModel() : m_path("/UNINITIALIZED") {} // FIXME: remove virtual ~ObjectModel(); - - const map<string, string>& metadata() const { return m_metadata; } - string get_metadata(const string& key) const; - void set_metadata(const string& key, const string& value) - { assert(value.length() > 0); m_metadata[key] = value; metadata_update_sig.emit(key, value); } - - inline const Path& path() const { return m_path; } - virtual void set_path(const Path& p) { m_path = p; } - - CountedPtr<ObjectModel> parent() const { return m_parent; } - virtual void set_parent(CountedPtr<ObjectModel> p) { m_parent = p; } - - virtual void add_child(CountedPtr<ObjectModel> c) = 0; - virtual void remove_child(CountedPtr<ObjectModel> c) = 0; - CountedPtr<ObjectController> controller() const { return m_controller; } - - void set_controller(CountedPtr<ObjectController> c); + const Atom& get_metadata(const string& key) const; + void add_metadata(const MetadataMap& data); + + const MetadataMap& metadata() const { return _metadata; } + inline const Path& path() const { return _path; } + CountedPtr<ObjectModel> parent() const { return _parent; } void assimilate(CountedPtr<ObjectModel> model); // Signals - sigc::signal<void, const string&, const string&> metadata_update_sig; - sigc::signal<void> destroyed_sig; + sigc::signal<void, const string&, const Atom&> metadata_update_sig; + sigc::signal<void> destroyed_sig; + + // FIXME: make private + void set_metadata(const string& key, const Atom& value) + { _metadata[key] = value; metadata_update_sig.emit(key, value); } + + protected: - Path m_path; - CountedPtr<ObjectModel> m_parent; - CountedPtr<ObjectController> m_controller; + friend class Store; + friend class PatchLibrarian; // FIXME: remove + virtual void set_path(const Path& p) { _path = p; } + virtual void set_parent(CountedPtr<ObjectModel> p) { _parent = p; } + virtual void add_child(CountedPtr<ObjectModel> c) = 0; + virtual void remove_child(CountedPtr<ObjectModel> c) = 0; + + Path _path; + CountedPtr<ObjectModel> _parent; - map<string,string> m_metadata; + MetadataMap _metadata; private: // Prevent copies (undefined) diff --git a/src/libs/client/PatchLibrarian.cpp b/src/libs/client/PatchLibrarian.cpp index 07a98526..4db47b5b 100644 --- a/src/libs/client/PatchLibrarian.cpp +++ b/src/libs/client/PatchLibrarian.cpp @@ -136,7 +136,7 @@ PatchLibrarian::save_patch(CountedPtr<PatchModel> patch_model, const string& fil xmlNodePtr xml_root_node = NULL; xmlNodePtr xml_node = NULL; xmlNodePtr xml_child_node = NULL; - xmlNodePtr xml_grandchild_node = NULL; + //xmlNodePtr xml_grandchild_node = NULL; xml_doc = xmlNewDoc((xmlChar*)"1.0"); xml_root_node = xmlNewNode(NULL, (xmlChar*)"patch"); @@ -164,13 +164,14 @@ PatchLibrarian::save_patch(CountedPtr<PatchModel> patch_model, const string& fil xml_node = xmlNewChild(xml_root_node, NULL, (xmlChar*)"polyphony", (xmlChar*)temp_buf); // Write metadata - for (map<string, string>::const_iterator i = patch_model->metadata().begin(); + for (MetadataMap::const_iterator i = patch_model->metadata().begin(); i != patch_model->metadata().end(); ++i) { + cerr << "FIXME: metadata save" << endl; // Dirty hack, don't save coordinates in patch file - if ((*i).first != "module-x" && (*i).first != "module-y" - && (*i).first != "filename") - xml_node = xmlNewChild(xml_root_node, NULL, - (xmlChar*)(*i).first.c_str(), (xmlChar*)(*i).second.c_str()); + //if (i->first != "module-x" && i->first != "module-y" + // && i->first != "filename") + // xml_node = xmlNewChild(xml_root_node, NULL, + // (xmlChar*)(*i).first.c_str(), (xmlChar*)(*i).second.c_str()); assert((*i).first != "node"); assert((*i).first != "subpatch"); @@ -215,13 +216,14 @@ PatchLibrarian::save_patch(CountedPtr<PatchModel> patch_model, const string& fil xml_child_node = xmlNewChild(xml_node, NULL, (xmlChar*)"polyphony", (xmlChar*)temp_buf); // Write metadata - for (map<string, string>::const_iterator i = nm->metadata().begin(); + for (MetadataMap::const_iterator i = nm->metadata().begin(); i != nm->metadata().end(); ++i) { + cerr << "FIXME: save metadata\n"; // Dirty hack, don't save metadata that would be in patch file - if ((*i).first != "polyphony" && (*i).first != "filename" + /*if ((*i).first != "polyphony" && (*i).first != "filename" && (*i).first != "author" && (*i).first != "description") xml_child_node = xmlNewChild(xml_node, NULL, - (xmlChar*)(*i).first.c_str(), (xmlChar*)(*i).second.c_str()); + (xmlChar*)(*i).first.c_str(), (xmlChar*)(*i).second.c_str());*/ } if (recursive) @@ -251,7 +253,9 @@ PatchLibrarian::save_patch(CountedPtr<PatchModel> patch_model, const string& fil (xmlChar*)(nm->plugin()->uri().c_str())); // Write metadata - for (map<string, string>::const_iterator i = nm->metadata().begin(); i != nm->metadata().end(); ++i) { + for (MetadataMap::const_iterator i = nm->metadata().begin(); i != nm->metadata().end(); ++i) { + cerr << "FIXME: Save metadata\n"; + /* // DSSI _hack_ (FIXME: fix OSC to be more like this and not smash DSSI into metadata?) if ((*i).first.substr(0, 16) == "dssi-configure--") { xml_child_node = xmlNewChild(xml_node, NULL, (xmlChar*)"dssi-configure", NULL); @@ -269,11 +273,14 @@ PatchLibrarian::save_patch(CountedPtr<PatchModel> patch_model, const string& fil xml_child_node = xmlNewChild(xml_node, NULL, (xmlChar*)(*i).first.c_str(), (xmlChar*)(*i).second.c_str()); } + */ } // Write port metadata, if necessary for (PortModelList::const_iterator i = nm->ports().begin(); i != nm->ports().end(); ++i) { - const PortModel* const pm = (*i).get(); + cerr << "FIXME: save metadata\n"; + /* + const PortModel* const pm = i->get(); if (pm->is_input() && pm->user_min() != pm->min_val() || pm->user_max() != pm->max_val()) { xml_child_node = xmlNewChild(xml_node, NULL, (xmlChar*)"port", NULL); xml_grandchild_node = xmlNewChild(xml_child_node, NULL, (xmlChar*)"name", @@ -282,7 +289,7 @@ PatchLibrarian::save_patch(CountedPtr<PatchModel> patch_model, const string& fil xml_grandchild_node = xmlNewChild(xml_child_node, NULL, (xmlChar*)"user-min", (xmlChar*)temp_buf); snprintf(temp_buf, temp_buf_length, "%f", pm->user_max()); xml_grandchild_node = xmlNewChild(xml_child_node, NULL, (xmlChar*)"user-max", (xmlChar*)temp_buf); - } + }*/ } } } @@ -385,8 +392,8 @@ PatchLibrarian::load_patch(CountedPtr<PatchModel> pm, bool wait, bool existing) //cerr << "[PatchLibrarian] Loading patch " << filename << "" << endl; - const size_t temp_buf_length = 255; - char temp_buf[temp_buf_length]; + //const size_t temp_buf_length = 255; + //char temp_buf[temp_buf_length]; bool load_name = (pm->path() == ""); bool load_poly = (poly == 0); @@ -447,8 +454,11 @@ PatchLibrarian::load_patch(CountedPtr<PatchModel> pm, bool wait, bool existing) // Don't know what this tag is, add it as metadata without overwriting // (so caller can set arbitrary parameters which will be preserved) if (key != NULL) + cerr << "FIXME: save metadata\n"; + /* if (pm->get_metadata((const char*)cur->name) == "") pm->set_metadata((const char*)cur->name, (const char*)key); + */ } xmlFree(key); @@ -483,7 +493,7 @@ PatchLibrarian::load_patch(CountedPtr<PatchModel> pm, bool wait, bool existing) // This isn't so good, considering multiple clients on multiple machines, and // absolute filesystem paths obviously aren't going to be correct. But for now // this is all I can figure out to have Save/Save As work properly for subpatches - _engine->set_metadata(pm->path(), "filename", pm->filename()); + _engine->set_metadata(pm->path(), "filename", Atom(pm->filename().c_str())); // Load nodes cur = xmlDocGetRootElement(doc)->xmlChildrenNode; @@ -494,13 +504,15 @@ PatchLibrarian::load_patch(CountedPtr<PatchModel> pm, bool wait, bool existing) if (nm) { _engine->create_node_from_model(nm.get()); _engine->set_all_metadata(nm.get()); - for (PortModelList::const_iterator j = nm->ports().begin(); j != nm->ports().end(); ++j) { + cerr << "FIXME: max min\n"; + /* + //for (PortModelList::const_iterator j = nm->ports().begin(); j != nm->ports().end(); ++j) { // FIXME: ew snprintf(temp_buf, temp_buf_length, "%f", (*j)->user_min()); _engine->set_metadata((*j)->path(), "user-min", temp_buf); snprintf(temp_buf, temp_buf_length, "%f", (*j)->user_max()); _engine->set_metadata((*j)->path(), "user-max", temp_buf); - } + }*/ } } cur = cur->next; @@ -562,19 +574,23 @@ PatchLibrarian::load_patch(CountedPtr<PatchModel> pm, bool wait, bool existing) CountedPtr<NodeModel> PatchLibrarian::parse_node(const CountedPtr<const PatchModel> parent, xmlDocPtr doc, const xmlNodePtr node) { +cerr << "FIXME: load node\n"; +#if 0 CountedPtr<PluginModel> plugin(new PluginModel()); - CountedPtr<NodeModel> nm(new NodeModel(plugin, "/UNINITIALIZED")); // FIXME: ew xmlChar* key; xmlNodePtr cur = node->xmlChildrenNode; + string path = ""' + bool polyphonic = false; + while (cur != NULL) { key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); if ((!xmlStrcmp(cur->name, (const xmlChar*)"name"))) { - nm->set_path(parent->path().base() + Path::nameify((char*)key)); + path = parent->path().base() + Path::nameify((char*)key)); } else if ((!xmlStrcmp(cur->name, (const xmlChar*)"polyphonic"))) { - nm->polyphonic(!strcmp((char*)key, "true")); + polyphonic = !strcmp((char*)key, "true"); } else if ((!xmlStrcmp(cur->name, (const xmlChar*)"type"))) { plugin->set_type((const char*)key); } else if ((!xmlStrcmp(cur->name, (const xmlChar*)"library-name"))) { @@ -586,7 +602,7 @@ PatchLibrarian::parse_node(const CountedPtr<const PatchModel> parent, xmlDocPtr } else if ((!xmlStrcmp(cur->name, (const xmlChar*)"port"))) { xmlNodePtr child = cur->xmlChildrenNode; - string path; + string port_name; float user_min = 0.0; float user_max = 0.0; @@ -594,7 +610,7 @@ PatchLibrarian::parse_node(const CountedPtr<const PatchModel> parent, xmlDocPtr key = xmlNodeListGetString(doc, child->xmlChildrenNode, 1); if ((!xmlStrcmp(child->name, (const xmlChar*)"name"))) { - path = nm->path().base() + Path::nameify((char*)key); + port_name = Path::nameify((char*)key); } else if ((!xmlStrcmp(child->name, (const xmlChar*)"user-min"))) { user_min = atof((char*)key); } else if ((!xmlStrcmp(child->name, (const xmlChar*)"user-max"))) { @@ -607,11 +623,14 @@ PatchLibrarian::parse_node(const CountedPtr<const PatchModel> parent, xmlDocPtr child = child->next; } - // FIXME: nasty assumptions - CountedPtr<PortModel> pm(new PortModel(path, + assert(path.length() > 0); + assert(Path::is_valid(path)); + + // FIXME: /nasty/ assumptions + CountedPtr<PortModel> pm(new PortModel(Path(path).base() + port_name, PortModel::CONTROL, PortModel::INPUT, PortModel::NONE, 0.0, user_min, user_max)); - pm->set_parent(nm); + //pm->set_parent(nm); nm->add_port(pm); // DSSI hacks. Stored in the patch files as special elements, but sent to @@ -637,7 +656,7 @@ PatchLibrarian::parse_node(const CountedPtr<const PatchModel> parent, xmlDocPtr key = NULL; // Avoid a (possible?) double free child = child->next; } - nm->set_metadata("dssi-program", bank +"/"+ program); + nm->set_metadata("dssi-program", Atom(bank.append("/").append(program).c_str())); } else if ((!xmlStrcmp(cur->name, (const xmlChar*)"dssi-configure"))) { xmlNodePtr child = cur->xmlChildrenNode; @@ -659,7 +678,7 @@ PatchLibrarian::parse_node(const CountedPtr<const PatchModel> parent, xmlDocPtr child = child->next; } - nm->set_metadata(string("dssi-configure--").append(dssi_key), dssi_value); + nm->set_metadata(string("dssi-configure--").append(dssi_key), Atom(dssi_value.c_str())); } else { // Don't know what this tag is, add it as metadata if (key != NULL) @@ -729,7 +748,10 @@ PatchLibrarian::parse_node(const CountedPtr<const PatchModel> parent, xmlDocPtr } //nm->plugin(plugin); + return nm; +#endif + return CountedPtr<NodeModel>(); } diff --git a/src/libs/client/PatchModel.cpp b/src/libs/client/PatchModel.cpp index a65f1c49..21e47089 100644 --- a/src/libs/client/PatchModel.cpp +++ b/src/libs/client/PatchModel.cpp @@ -31,13 +31,13 @@ PatchModel::set_path(const Path& new_path) { // FIXME: haack if (new_path == "") { - m_path = ""; + _path = ""; return; } NodeModel::set_path(new_path); for (NodeModelMap::iterator i = m_nodes.begin(); i != m_nodes.end(); ++i) - (*i).second->set_path(m_path +"/"+ (*i).second->path().name()); + (*i).second->set_path(_path +"/"+ (*i).second->path().name()); #ifdef DEBUG // Be sure connection paths are updated and sane @@ -72,7 +72,7 @@ PatchModel::add_child(CountedPtr<ObjectModel> c) void PatchModel::remove_child(CountedPtr<ObjectModel> c) { - assert(c->path().is_child_of(m_path)); + assert(c->path().is_child_of(_path)); assert(c->parent().get() == this); CountedPtr<PortModel> pm = PtrCast<PortModel>(c); @@ -102,13 +102,13 @@ void PatchModel::add_node(CountedPtr<NodeModel> nm) { assert(nm); - assert(nm->path().is_child_of(m_path)); + assert(nm->path().is_child_of(_path)); assert(nm->parent().get() == this); NodeModelMap::iterator existing = m_nodes.find(nm->path().name()); if (existing != m_nodes.end()) { - cerr << "Warning: node clash, assimilating old node " << m_path << endl; + cerr << "Warning: node clash, assimilating old node " << _path << endl; nm->assimilate((*existing).second); (*existing).second = nm; } else { @@ -121,23 +121,23 @@ PatchModel::add_node(CountedPtr<NodeModel> nm) void PatchModel::remove_node(CountedPtr<NodeModel> nm) { - assert(nm->path().is_child_of(m_path)); + assert(nm->path().is_child_of(_path)); assert(nm->parent().get() == this); NodeModelMap::iterator i = m_nodes.find(nm->path().name()); if (i != m_nodes.end()) { assert(i->second == nm); m_nodes.erase(i); - removed_node_sig.emit(nm->path().name()); + removed_node_sig.emit(nm); i->second->parent().reset(); return; } - cerr << "[PatchModel::remove_node] " << m_path + cerr << "[PatchModel::remove_node] " << _path << ": failed to find node " << nm->path().name() << endl; } - +#if 0 void PatchModel::remove_node(const string& name) { @@ -151,9 +151,9 @@ PatchModel::remove_node(const string& name) return; } - cerr << "[PatchModel::remove_node] " << m_path << ": failed to find node " << name << endl; + cerr << "[PatchModel::remove_node] " << _path << ": failed to find node " << name << endl; } - +#endif void PatchModel::clear() @@ -204,7 +204,7 @@ PatchModel::rename_node(const Path& old_path, const Path& new_path) return; } - cerr << "[PatchModel::rename_node] " << m_path << ": failed to find node " << old_path << endl; + cerr << "[PatchModel::rename_node] " << _path << ": failed to find node " << old_path << endl; } @@ -229,8 +229,8 @@ void PatchModel::add_connection(CountedPtr<ConnectionModel> cm) { assert(cm); - //assert(cm->src_port_path().parent().parent() == m_path); - //assert(cm->dst_port_path().parent().parent() == m_path); + //assert(cm->src_port_path().parent().parent() == _path); + //assert(cm->dst_port_path().parent().parent() == _path); assert(cm->patch_path() == path()); //cerr << "PatchModel::add_connection: " << cm->src_port_path() << " -> " << cm->dst_port_path() << endl; @@ -314,9 +314,9 @@ PatchModel::disable() bool PatchModel::polyphonic() const { - return (!m_parent) + return (!_parent) ? (m_poly > 1) - : (m_poly > 1) && m_poly == ((PatchModel*)m_parent.get())->poly() && m_poly > 1; + : (m_poly > 1) && m_poly == ((PatchModel*)_parent.get())->poly() && m_poly > 1; } diff --git a/src/libs/client/PatchModel.h b/src/libs/client/PatchModel.h index 6ca8ed8f..49a45503 100644 --- a/src/libs/client/PatchModel.h +++ b/src/libs/client/PatchModel.h @@ -39,11 +39,13 @@ namespace Client { class PatchModel : public NodeModel { public: - PatchModel(const string& patch_path, uint poly) - : NodeModel("ingen:patch", patch_path), + PatchModel(const string& patch_path, size_t internal_poly) + : NodeModel("ingen:patch", patch_path, false ), // FIXME m_enabled(false), - m_poly(poly) - {} + m_poly(internal_poly) + { + cerr << "FIXME: patch poly\n"; + } const NodeModelMap& nodes() const { return m_nodes; } const list<CountedPtr<ConnectionModel> >& connections() const { return m_connections; } @@ -55,7 +57,7 @@ public: CountedPtr<NodeModel> get_node(const string& node_name); void add_node(CountedPtr<NodeModel> nm); - void remove_node(const string& name); + //void remove_node(const string& name); void remove_node(CountedPtr<NodeModel> nm); void rename_node(const Path& old_path, const Path& new_path); @@ -77,12 +79,12 @@ public: bool polyphonic() const; // Signals - sigc::signal<void, CountedPtr<NodeModel> > new_node_sig; - sigc::signal<void, const string& > removed_node_sig; - sigc::signal<void, CountedPtr<ConnectionModel> > new_connection_sig; - sigc::signal<void, const string&, const string& > removed_connection_sig; - sigc::signal<void> enabled_sig; - sigc::signal<void> disabled_sig; + sigc::signal<void, CountedPtr<NodeModel> > new_node_sig; + sigc::signal<void, CountedPtr<NodeModel> > removed_node_sig; + sigc::signal<void, CountedPtr<ConnectionModel> > new_connection_sig; + sigc::signal<void, const Path&, const Path& > removed_connection_sig; + sigc::signal<void> enabled_sig; + sigc::signal<void> disabled_sig; private: // Prevent copies (undefined) diff --git a/src/libs/client/PortModel.h b/src/libs/client/PortModel.h index 1f816748..dd0a208b 100644 --- a/src/libs/client/PortModel.h +++ b/src/libs/client/PortModel.h @@ -35,22 +35,17 @@ namespace Client { class PortModel : public ObjectModel { public: + // FIXME: metadataify enum Type { CONTROL, AUDIO, MIDI }; enum Direction { INPUT, OUTPUT }; enum Hint { NONE, INTEGER, TOGGLE, LOGARITHMIC }; - PortModel(const string& path, Type type, Direction dir, Hint hint, - float default_val, float min, float max) + PortModel(const string& path, Type type, Direction dir, Hint hint) : ObjectModel(path), m_type(type), m_direction(dir), m_hint(hint), - m_default_val(default_val), - m_min_val(min), - //m_user_min(min), - m_max_val(max), - //m_user_max(max), - m_current_val(default_val), + m_current_val(0.0f), m_connections(0) { } @@ -60,11 +55,6 @@ public: m_type(type), m_direction(dir), m_hint(NONE), - m_default_val(0.0f), - m_min_val(0.0f), - //m_user_min(0.0f), - m_max_val(0.0f), - //m_user_max(0.0f), m_current_val(0.0f), m_connections(0) { @@ -73,14 +63,6 @@ public: void add_child(CountedPtr<ObjectModel> c) { throw; } void remove_child(CountedPtr<ObjectModel> c) { throw; } - inline float min_val() const { return m_min_val; } - inline float user_min() const { return atof(get_metadata("min").c_str()); } // FIXME: haaack - //inline void user_min(float f) { m_user_min = f; } - inline float default_val() const { return m_default_val; } - inline void default_val(float f) { m_default_val = f; } - inline float max_val() const { return m_max_val; } - inline float user_max() const { return atof(get_metadata("max").c_str()); } - //inline void user_max(float f) { m_user_max = f; } inline float value() const { return m_current_val; } inline void value(float f) { m_current_val = f; control_change_sig.emit(f); } inline bool connected() { return (m_connections > 0); } @@ -96,7 +78,7 @@ public: inline bool is_toggle() const { return (m_hint == TOGGLE); } inline bool operator==(const PortModel& pm) - { return (m_path == pm.m_path); } + { return (_path == pm._path); } void connected_to(CountedPtr<PortModel> p) { ++m_connections; connection_sig.emit(p); } void disconnected_from(CountedPtr<PortModel> p) { --m_connections; disconnection_sig.emit(p); } @@ -114,11 +96,6 @@ private: Type m_type; Direction m_direction; Hint m_hint; - float m_default_val; - float m_min_val; - //float m_user_min; - float m_max_val; - //float m_user_max; float m_current_val; size_t m_connections; }; diff --git a/src/libs/client/SigClientInterface.h b/src/libs/client/SigClientInterface.h index cef7d27d..a28b1a1d 100644 --- a/src/libs/client/SigClientInterface.h +++ b/src/libs/client/SigClientInterface.h @@ -55,7 +55,7 @@ public: sigc::signal<void, string> object_destroyed_sig; sigc::signal<void, string, string> connection_sig; sigc::signal<void, string, string> disconnection_sig; - sigc::signal<void, string, string, string> metadata_update_sig; + sigc::signal<void, string, string, Atom> metadata_update_sig; sigc::signal<void, string, float> control_change_sig; sigc::signal<void, string, uint32_t, uint32_t, string> program_add_sig; sigc::signal<void, string, uint32_t, uint32_t> program_remove_sig; diff --git a/src/libs/client/Store.cpp b/src/libs/client/Store.cpp index df0bdd95..e2637c0f 100644 --- a/src/libs/client/Store.cpp +++ b/src/libs/client/Store.cpp @@ -212,11 +212,11 @@ void Store::destruction_event(const Path& path) { CountedPtr<ObjectModel> removed = remove_object(path); - removed->controller().reset(); - cerr << "Store removed object " << path - << " controller count: " << removed->controller().use_count(); + removed.reset(); - cerr << ", model count: " << removed.use_count() << endl; + + cerr << "Store removed object " << path + << ", count: " << removed.use_count(); } void @@ -244,12 +244,10 @@ Store::new_node_event(const string& plugin_type, const string& plugin_uri, const CountedPtr<PluginModel> plug = plugin(plugin_uri); if (!plug) { - CountedPtr<NodeModel> n(new NodeModel(plugin_uri, node_path)); - n->polyphonic(is_polyphonic); + CountedPtr<NodeModel> n(new NodeModel(plugin_uri, node_path, is_polyphonic)); add_plugin_orphan(n); } else { - CountedPtr<NodeModel> n(new NodeModel(plug, node_path)); - n->polyphonic(is_polyphonic); + CountedPtr<NodeModel> n(new NodeModel(plug, node_path, is_polyphonic)); add_object(n); } } @@ -292,7 +290,7 @@ Store::patch_disabled_event(const Path& path) void -Store::metadata_update_event(const Path& subject_path, const string& predicate, const string& value) +Store::metadata_update_event(const Path& subject_path, const string& predicate, const Atom& value) { CountedPtr<ObjectModel> subject = object(subject_path); if (subject) diff --git a/src/libs/client/Store.h b/src/libs/client/Store.h index e70c5bc0..99466b1d 100644 --- a/src/libs/client/Store.h +++ b/src/libs/client/Store.h @@ -24,6 +24,7 @@ #include "util/CountedPtr.h" #include <sigc++/sigc++.h> #include "util/Path.h" +#include "util/Atom.h" using std::string; using std::map; using std::list; namespace Ingen { @@ -75,7 +76,7 @@ private: void new_port_event(const Path& path, const string& data_type, bool is_output); void patch_enabled_event(const Path& path); void patch_disabled_event(const Path& path); - void metadata_update_event(const Path& subject_path, const string& predicate, const string& value); + void metadata_update_event(const Path& subject_path, const string& predicate, const Atom& value); void control_change_event(const Path& port_path, float value); void connection_event(const Path& src_port_path, const Path& dst_port_path); void disconnection_event(const Path& src_port_path, const Path& dst_port_path); diff --git a/src/libs/client/ThreadedSigClientInterface.h b/src/libs/client/ThreadedSigClientInterface.h index 5a677034..981b038d 100644 --- a/src/libs/client/ThreadedSigClientInterface.h +++ b/src/libs/client/ThreadedSigClientInterface.h @@ -23,6 +23,7 @@ #include "interface/ClientInterface.h" #include "SigClientInterface.h" #include "util/Queue.h" +#include "util/Atom.h" using std::string; /** Returns nothing and takes no parameters (because they have all been bound) */ @@ -114,7 +115,7 @@ public: void disconnection(string src_port_path, string dst_port_path) { push_sig(sigc::bind(disconnection_slot, src_port_path, dst_port_path)); } - void metadata_update(string path, string key, string value) + void metadata_update(string path, string key, Atom value) { push_sig(sigc::bind(metadata_update_slot, path, key, value)); } void control_change(string port_path, float value) @@ -151,7 +152,7 @@ private: sigc::slot<void, string> object_destroyed_slot; sigc::slot<void, string, string> object_renamed_slot; sigc::slot<void, string, string> disconnection_slot; - sigc::slot<void, string, string, string> metadata_update_slot; + sigc::slot<void, string, string, Atom> metadata_update_slot; sigc::slot<void, string, float> control_change_slot; sigc::slot<void, string, uint32_t, uint32_t, string> program_add_slot; sigc::slot<void, string, uint32_t, uint32_t> program_remove_slot; diff --git a/src/libs/engine/ClientBroadcaster.cpp b/src/libs/engine/ClientBroadcaster.cpp index 1b4a2bd2..7a21c38b 100644 --- a/src/libs/engine/ClientBroadcaster.cpp +++ b/src/libs/engine/ClientBroadcaster.cpp @@ -258,7 +258,7 @@ ClientBroadcaster::send_patch_disable(const string& patch_path) * Like control changes, does not send update to client that set the metadata, if applicable. */ void -ClientBroadcaster::send_metadata_update(const string& node_path, const string& key, const string& value) +ClientBroadcaster::send_metadata_update(const string& node_path, const string& key, const Atom& value) { for (ClientList::const_iterator i = _clients.begin(); i != _clients.end(); ++i) (*i).second->metadata_update(node_path, key, value); diff --git a/src/libs/engine/ClientBroadcaster.h b/src/libs/engine/ClientBroadcaster.h index ed4bec4e..47ad75b4 100644 --- a/src/libs/engine/ClientBroadcaster.h +++ b/src/libs/engine/ClientBroadcaster.h @@ -82,7 +82,7 @@ public: void send_all_objects(); void send_patch_enable(const string& patch_path); void send_patch_disable(const string& patch_path); - void send_metadata_update(const string& node_path, const string& key, const string& value); + void send_metadata_update(const string& node_path, const string& key, const Atom& value); void send_control_change(const string& port_path, float value); void send_program_add(const string& node_path, int bank, int program, const string& name); void send_program_remove(const string& node_path, int bank, int program); diff --git a/src/libs/engine/DSSINode.h b/src/libs/engine/DSSINode.h index 3c8dc841..1ef58d58 100644 --- a/src/libs/engine/DSSINode.h +++ b/src/libs/engine/DSSINode.h @@ -37,7 +37,7 @@ class DSSINode : public LADSPANode { public: - typedef map<int, string> Bank; + typedef std::map<int, string> Bank; DSSINode(const Plugin* plugin, const string& name, size_t poly, Patch* parent, DSSI_Descriptor* descriptor, SampleRate srate, size_t buffer_size); ~DSSINode(); @@ -57,7 +57,7 @@ public: bool update_programs(bool send_events); void set_default_program(); - const map<int, Bank>& get_programs() const; + const std::map<int, Bank>& get_programs() const; //void send_creation_messages(ClientInterface* client) const; @@ -90,10 +90,10 @@ private: lo_address _ui_addr; // Current values - int _bank; - int _program; - map<string, string> _configures; - map<int, Bank> _banks; + int _bank; + int _program; + std::map<string, string> _configures; + std::map<int, Bank> _banks; InputPort<MidiMessage>* _midi_in_port; snd_seq_event_t* _alsa_events; diff --git a/src/libs/engine/GraphObject.h b/src/libs/engine/GraphObject.h index 3b0c27b1..4f72a2e6 100644 --- a/src/libs/engine/GraphObject.h +++ b/src/libs/engine/GraphObject.h @@ -23,8 +23,9 @@ #include <cassert> #include "MaidObject.h" #include "util/Path.h" +#include "util/Atom.h" #include "types.h" -using std::string; using std::map; +using std::string; namespace Ingen { @@ -45,6 +46,8 @@ class ObjectStore; class GraphObject : public MaidObject { public: + typedef std::map<string, Atom> MetadataMap; + GraphObject(GraphObject* parent, const string& name) : _parent(parent), _name(name) { @@ -67,16 +70,16 @@ public: assert(_name.find("/") == string::npos); } - void set_metadata(const string& key, const string& value) + void set_metadata(const string& key, const Atom& value) { _metadata[key] = value; } - const string& get_metadata(const string& key) { - static const string empty_string = ""; - map<string, string>::iterator i = _metadata.find(key); - return (i != _metadata.end()) ? (*i).second : empty_string; + const Atom& get_metadata(const string& key) { + static Atom null_atom; + MetadataMap::iterator i = _metadata.find(key); + return (i != _metadata.end()) ? (*i).second : null_atom; } - const map<string, string>& metadata() const { return _metadata; } + const MetadataMap& metadata() const { return _metadata; } /** Patch and Node override this to recursively add their children. */ @@ -104,7 +107,7 @@ private: GraphObject(const GraphObject&); GraphObject& operator=(const GraphObject& copy); - map<string, string> _metadata; + MetadataMap _metadata; }; diff --git a/src/libs/engine/LADSPANode.cpp b/src/libs/engine/LADSPANode.cpp index 76550d0b..00cfd450 100644 --- a/src/libs/engine/LADSPANode.cpp +++ b/src/libs/engine/LADSPANode.cpp @@ -123,11 +123,10 @@ LADSPANode::instantiate() ((TypedPort<Sample>*)port)->set_value(0.0f, 0); } - char tmp_buf[16]; - snprintf(tmp_buf, 16, "%f", min); - port->set_metadata("min", tmp_buf); - snprintf(tmp_buf, 16, "%f", max); - port->set_metadata("max", tmp_buf); + if (port->is_input() && port->buffer_size() == 1) { + port->set_metadata("min", min); + port->set_metadata("max", max); + } } return true; diff --git a/src/libs/engine/OSCClientSender.cpp b/src/libs/engine/OSCClientSender.cpp index 068c461a..538630c0 100644 --- a/src/libs/engine/OSCClientSender.cpp +++ b/src/libs/engine/OSCClientSender.cpp @@ -29,7 +29,7 @@ #include "AudioDriver.h" #include "interface/ClientInterface.h" #include "Responder.h" - +#include "util/LibloAtom.h" using std::cout; using std::cerr; using std::endl; namespace Ingen { @@ -421,9 +421,13 @@ OSCClientSender::disconnection(string src_port_path, string dst_port_path) * \arg \b value (string)</p> \n \n */ void -OSCClientSender::metadata_update(string path, string key, string value) +OSCClientSender::metadata_update(string path, string key, Atom value) { - lo_send(_address, "/om/metadata/update", "sss", path.c_str(), key.c_str(), value.c_str()); + lo_message m = lo_message_new(); + lo_message_add_string(m, path.c_str()); + lo_message_add_string(m, key.c_str()); + LibloAtom::lo_message_add_atom(m, value); + lo_send_message(_address, "/om/metadata/update", m); } diff --git a/src/libs/engine/OSCClientSender.h b/src/libs/engine/OSCClientSender.h index e2404c1a..260dba63 100644 --- a/src/libs/engine/OSCClientSender.h +++ b/src/libs/engine/OSCClientSender.h @@ -107,7 +107,7 @@ public: virtual void metadata_update(string subject_path, string predicate, - string value); + Atom value); virtual void control_change(string port_path, float value); diff --git a/src/libs/engine/OSCEngineReceiver.cpp b/src/libs/engine/OSCEngineReceiver.cpp index 2eb68d70..afed89fd 100644 --- a/src/libs/engine/OSCEngineReceiver.cpp +++ b/src/libs/engine/OSCEngineReceiver.cpp @@ -22,6 +22,7 @@ #include "types.h" #include "util/Queue.h" #include "util/CountedPtr.h" +#include "util/LibloAtom.h" #include "QueuedEventSource.h" #include "interface/ClientKey.h" #include "interface/ClientInterface.h" @@ -106,7 +107,7 @@ OSCEngineReceiver::OSCEngineReceiver(CountedPtr<Engine> engine, size_t queue_siz #endif lo_server_add_method(_server, "/om/metadata/request", "isss", metadata_get_cb, this); - lo_server_add_method(_server, "/om/metadata/set", "isss", metadata_set_cb, this); + lo_server_add_method(_server, "/om/metadata/set", NULL, metadata_set_cb, this); // Queries lo_server_add_method(_server, "/om/request/plugins", "i", request_plugins_cb, this); @@ -758,9 +759,13 @@ OSCEngineReceiver::m_lash_restore_done_cb(const char* path, const char* types, l int OSCEngineReceiver::m_metadata_set_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg) { + if (argc != 4 || types[0] != 'i' || types[1] != 's' || types[2] != 's') + return 1; + const char* node_path = &argv[1]->s; const char* key = &argv[2]->s; - const char* value = &argv[3]->s; + + Atom value = LibloAtom::lo_arg_to_atom(types[3], argv[3]); set_metadata(node_path, key, value); diff --git a/src/libs/engine/ObjectSender.cpp b/src/libs/engine/ObjectSender.cpp index 063a2d1d..1e6b93c5 100644 --- a/src/libs/engine/ObjectSender.cpp +++ b/src/libs/engine/ObjectSender.cpp @@ -45,8 +45,8 @@ ObjectSender::send_patch(ClientInterface* client, const Patch* patch) send_port(client, port); /* // Send metadata - const map<string, string>& data = port->metadata(); - for (map<string, string>::const_iterator i = data.begin(); i != data.end(); ++i) + const GraphObject::MetadataMap& data = port->metadata(); + for (GraphObject::MetadataMap::const_iterator i = data.begin(); i != data.end(); ++i) client->metadata_update(port->path(), (*i).first, (*i).second); // Control port, send value @@ -64,8 +64,8 @@ ObjectSender::send_patch(ClientInterface* client, const Patch* patch) // Send metadata - const map<string, string>& data = patch->metadata(); - for (map<string, string>::const_iterator j = data.begin(); j != data.end(); ++j) + const GraphObject::MetadataMap& data = patch->metadata(); + for (GraphObject::MetadataMap::const_iterator j = data.begin(); j != data.end(); ++j) client->metadata_update(patch->path(), (*j).first, (*j).second); if (patch->enabled()) @@ -118,8 +118,8 @@ ObjectSender::send_node(ClientInterface* client, const Node* node) client->bundle_end(); // Send metadata - const map<string, string>& data = node->metadata(); - for (map<string, string>::const_iterator j = data.begin(); j != data.end(); ++j) + const GraphObject::MetadataMap& data = node->metadata(); + for (GraphObject::MetadataMap::const_iterator j = data.begin(); j != data.end(); ++j) client->metadata_update(node->path(), (*j).first, (*j).second); } @@ -149,8 +149,8 @@ ObjectSender::send_port(ClientInterface* client, const Port* port) } // Send metadata - const map<string, string>& data = port->metadata(); - for (map<string, string>::const_iterator j = data.begin(); j != data.end(); ++j) + const GraphObject::MetadataMap& data = port->metadata(); + for (GraphObject::MetadataMap::const_iterator j = data.begin(); j != data.end(); ++j) client->metadata_update(port->path(), (*j).first, (*j).second); } diff --git a/src/libs/engine/QueuedEngineInterface.cpp b/src/libs/engine/QueuedEngineInterface.cpp index 35e1c99a..b0903e29 100644 --- a/src/libs/engine/QueuedEngineInterface.cpp +++ b/src/libs/engine/QueuedEngineInterface.cpp @@ -275,7 +275,7 @@ QueuedEngineInterface::midi_learn(const string& node_path) void QueuedEngineInterface::set_metadata(const string& path, const string& predicate, - const string& value) + const Atom& value) { push_queued(new SetMetadataEvent(*_engine.get(), _responder, now(), path, predicate, value)); } diff --git a/src/libs/engine/QueuedEngineInterface.h b/src/libs/engine/QueuedEngineInterface.h index 1e35738f..f9aaa0b4 100644 --- a/src/libs/engine/QueuedEngineInterface.h +++ b/src/libs/engine/QueuedEngineInterface.h @@ -137,7 +137,7 @@ public: virtual void set_metadata(const string& path, const string& predicate, - const string& value); + const Atom& value); // Requests // diff --git a/src/libs/engine/events/DSSIConfigureEvent.cpp b/src/libs/engine/events/DSSIConfigureEvent.cpp index fb9dc727..9a26de0c 100644 --- a/src/libs/engine/events/DSSIConfigureEvent.cpp +++ b/src/libs/engine/events/DSSIConfigureEvent.cpp @@ -64,7 +64,7 @@ DSSIConfigureEvent::post_process() } else { string key = "dssi-configure--"; key += m_key; - _engine.broadcaster()->send_metadata_update(m_node_path, key, m_val); + _engine.broadcaster()->send_metadata_update(m_node_path, key, Atom(m_val.c_str())); } } diff --git a/src/libs/engine/events/RequestMetadataEvent.cpp b/src/libs/engine/events/RequestMetadataEvent.cpp index f6f1bdf9..aaea89c6 100644 --- a/src/libs/engine/events/RequestMetadataEvent.cpp +++ b/src/libs/engine/events/RequestMetadataEvent.cpp @@ -31,7 +31,6 @@ RequestMetadataEvent::RequestMetadataEvent(Engine& engine, CountedPtr<Responder> : QueuedEvent(engine, responder, timestamp), m_path(node_path), m_key(key), - m_value(""), m_object(NULL), m_client(CountedPtr<ClientInterface>()) { @@ -61,8 +60,8 @@ void RequestMetadataEvent::post_process() { if (m_client) { - if (m_value == "") { - string msg = "Unable to find object "; + if (!m_object) { + string msg = "Unable to find metadata subject "; msg += m_path; _responder->respond_error(msg); } else { diff --git a/src/libs/engine/events/RequestMetadataEvent.h b/src/libs/engine/events/RequestMetadataEvent.h index 4f99e023..f4296ac2 100644 --- a/src/libs/engine/events/RequestMetadataEvent.h +++ b/src/libs/engine/events/RequestMetadataEvent.h @@ -19,7 +19,7 @@ #include <string> #include "QueuedEvent.h" - +#include "util/Atom.h" using std::string; namespace Ingen { @@ -45,8 +45,8 @@ public: private: string m_path; string m_key; - string m_value; - GraphObject* m_object; + Atom m_value; + GraphObject* m_object; CountedPtr<ClientInterface> m_client; }; diff --git a/src/libs/engine/events/SetMetadataEvent.cpp b/src/libs/engine/events/SetMetadataEvent.cpp index db8e0118..c4937df5 100644 --- a/src/libs/engine/events/SetMetadataEvent.cpp +++ b/src/libs/engine/events/SetMetadataEvent.cpp @@ -27,7 +27,7 @@ using std::string; namespace Ingen { -SetMetadataEvent::SetMetadataEvent(Engine& engine, CountedPtr<Responder> responder, SampleCount timestamp, const string& path, const string& key, const string& value) +SetMetadataEvent::SetMetadataEvent(Engine& engine, CountedPtr<Responder> responder, SampleCount timestamp, const string& path, const string& key, const Atom& value) : QueuedEvent(engine, responder, timestamp), m_path(path), m_key(key), diff --git a/src/libs/engine/events/SetMetadataEvent.h b/src/libs/engine/events/SetMetadataEvent.h index 855aeb62..b78f2502 100644 --- a/src/libs/engine/events/SetMetadataEvent.h +++ b/src/libs/engine/events/SetMetadataEvent.h @@ -19,6 +19,7 @@ #include <string> #include "QueuedEvent.h" +#include "util/Atom.h" using std::string; @@ -34,16 +35,16 @@ class GraphObject; class SetMetadataEvent : public QueuedEvent { public: - SetMetadataEvent(Engine& engine, CountedPtr<Responder> responder, SampleCount timestamp, const string& path, const string& key, const string& value); + SetMetadataEvent(Engine& engine, CountedPtr<Responder> responder, SampleCount timestamp, const string& path, const string& key, const Atom& value); void pre_process(); void execute(SampleCount nframes, FrameTime start, FrameTime end); void post_process(); private: - string m_path; - string m_key; - string m_value; + string m_path; + string m_key; + Atom m_value; GraphObject* m_object; }; |