diff options
author | David Robillard <d@drobilla.net> | 2007-10-08 00:50:13 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2007-10-08 00:50:13 +0000 |
commit | a421a44310ee472fbee15f150d32b826a8371dbf (patch) | |
tree | d160bb1704a26524dee8746e3f7dd69494460cd6 | |
parent | 19a9eb15d1c918b10fe169db1b8f4fd0c6ffe8fa (diff) | |
download | ingen-a421a44310ee472fbee15f150d32b826a8371dbf.tar.gz ingen-a421a44310ee472fbee15f150d32b826a8371dbf.tar.bz2 ingen-a421a44310ee472fbee15f150d32b826a8371dbf.zip |
Fix serialization/connection bugs resulting from refactoring.
git-svn-id: http://svn.drobilla.net/lad/ingen@842 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r-- | src/common/interface/Plugin.hpp | 8 | ||||
-rw-r--r-- | src/libs/client/NodeModel.cpp | 1 | ||||
-rw-r--r-- | src/libs/client/PluginModel.hpp | 16 | ||||
-rw-r--r-- | src/libs/client/PortModel.hpp | 30 | ||||
-rw-r--r-- | src/libs/client/Serializer.cpp | 16 | ||||
-rw-r--r-- | src/libs/client/Serializer.hpp | 23 | ||||
-rw-r--r-- | src/libs/engine/BufferFactory.cpp | 2 | ||||
-rw-r--r-- | src/libs/engine/Connection.cpp | 4 | ||||
-rw-r--r-- | src/libs/engine/JackAudioDriver.cpp | 2 | ||||
-rw-r--r-- | src/libs/engine/JackMidiDriver.cpp | 2 | ||||
-rw-r--r-- | src/libs/gui/App.cpp | 1 | ||||
-rw-r--r-- | src/libs/gui/Configuration.cpp | 14 | ||||
-rw-r--r-- | src/libs/gui/ControlPanel.cpp | 2 | ||||
-rw-r--r-- | src/libs/gui/NodeControlWindow.cpp | 2 | ||||
-rw-r--r-- | src/libs/gui/NodeMenu.cpp | 2 | ||||
-rw-r--r-- | src/libs/gui/NodeModule.cpp | 6 | ||||
-rw-r--r-- | src/libs/gui/PatchCanvas.cpp | 2 | ||||
-rw-r--r-- | src/libs/gui/PatchWindow.cpp | 8 | ||||
-rw-r--r-- | src/libs/gui/Port.cpp | 2 | ||||
-rw-r--r-- | src/libs/gui/Port.hpp | 6 | ||||
-rw-r--r-- | src/libs/serialisation/Loader.cpp | 10 |
21 files changed, 76 insertions, 83 deletions
diff --git a/src/common/interface/Plugin.hpp b/src/common/interface/Plugin.hpp index d9665662..691fb523 100644 --- a/src/common/interface/Plugin.hpp +++ b/src/common/interface/Plugin.hpp @@ -32,6 +32,14 @@ public: virtual Type type() const = 0; virtual const std::string& uri() const = 0; virtual const std::string& name() const = 0; + + inline const char* type_uri() const { + if (type() == LV2) return "ingen:LV2"; + else if (type() == LADSPA) return "ingen:LADSPA"; + else if (type() == Internal) return "ingen:Internal"; + else if (type() == Patch) return "ingen:Patch"; + else return ""; + } }; diff --git a/src/libs/client/NodeModel.cpp b/src/libs/client/NodeModel.cpp index 87b62dd9..52a4e1e9 100644 --- a/src/libs/client/NodeModel.cpp +++ b/src/libs/client/NodeModel.cpp @@ -141,6 +141,7 @@ NodeModel::get_port(const string& port_name) const Shared::Port* NodeModel::port(uint32_t index) const { + assert(index < num_ports()); return dynamic_cast<Shared::Port*>(_ports[index].get()); } diff --git a/src/libs/client/PluginModel.hpp b/src/libs/client/PluginModel.hpp index b4b0ab96..ce268a06 100644 --- a/src/libs/client/PluginModel.hpp +++ b/src/libs/client/PluginModel.hpp @@ -62,22 +62,6 @@ public: const string& name() const { return _name; } void name(const string& s) { _name = s; } - /*const char* const type_string() const { - if (_type == LV2) return "LV2"; - else if (_type == LADSPA) return "LADSPA"; - else if (_type == Internal) return "Internal"; - else if (_type == Patch) return "Patch"; - else return ""; - }*/ - - const char* const type_uri() const { - if (_type == LV2) return "ingen:LV2"; - else if (_type == LADSPA) return "ingen:LADSPA"; - else if (_type == Internal) return "ingen:Internal"; - else if (_type == Patch) return "ingen:Patch"; - else return ""; - } - /** DEPRECATED */ void set_type(const string& type_string) { if (type_string == "LV2") _type = LV2; diff --git a/src/libs/client/PortModel.hpp b/src/libs/client/PortModel.hpp index d6a766d8..8624c031 100644 --- a/src/libs/client/PortModel.hpp +++ b/src/libs/client/PortModel.hpp @@ -23,10 +23,12 @@ #include <string> #include <vector> #include <sigc++/sigc++.h> -#include "ObjectModel.hpp" #include <raul/SharedPtr.hpp> #include <raul/Path.hpp> -using std::string; using std::vector; using std::cerr; using std::endl; +#include "interface/Port.hpp" +#include "ObjectModel.hpp" + +using std::string; using std::vector; namespace Ingen { namespace Client { @@ -36,20 +38,16 @@ namespace Client { * * \ingroup IngenClient */ -class PortModel : public ObjectModel +class PortModel : public ObjectModel, public Shared::Port { public: enum Direction { INPUT, OUTPUT }; - inline string type() const { return _type; } - inline float value() const { return _current_val; } - inline bool connected() const { return (_connections > 0); } - inline bool is_input() const { return (_direction == INPUT); } - inline bool is_output() const { return (_direction == OUTPUT); } - inline bool is_audio() const { return (_type == "ingen:AudioPort"); } - inline bool is_control() const { return (_type == "ingen:ControlPort"); } - inline bool is_midi() const { return (_type == "ingen:MidiPort"); } - inline bool is_osc() const { return (_type == "ingen:OSCPort"); } + inline DataType type() const { return _type; } + inline Atom value() const { return Atom(_current_val); } + inline bool connected() const { return (_connections > 0); } + inline bool is_input() const { return (_direction == INPUT); } + inline bool is_output() const { return (_direction == OUTPUT); } bool is_logarithmic() const; bool is_integer() const; @@ -76,15 +74,15 @@ public: private: friend class Store; - PortModel(const Path& path, const string& type, Direction dir) + PortModel(const Path& path, DataType type, Direction dir) : ObjectModel(path, true), _type(type), _direction(dir), _current_val(0.0f), _connections(0) { - if (!is_audio() && !is_control() && !is_input()) - cerr << "[PortModel] Warning: Unknown port type" << endl; + if (_type == DataType::UNKNOWN) + std::cerr << "[PortModel] Warning: Unknown port type" << std::endl; } void add_child(SharedPtr<ObjectModel> c) { throw; } @@ -93,7 +91,7 @@ private: void connected_to(SharedPtr<PortModel> p) { ++_connections; signal_connection.emit(p); } void disconnected_from(SharedPtr<PortModel> p) { --_connections; signal_disconnection.emit(p); } - string _type; + DataType _type; Direction _direction; float _current_val; size_t _connections; diff --git a/src/libs/client/Serializer.cpp b/src/libs/client/Serializer.cpp index d367733d..a5fbb614 100644 --- a/src/libs/client/Serializer.cpp +++ b/src/libs/client/Serializer.cpp @@ -37,11 +37,7 @@ #include "interface/EngineInterface.hpp" #include "interface/Port.hpp" #include "ConnectionModel.hpp" -#include "NodeModel.hpp" #include "PatchModel.hpp" -#include "PluginModel.hpp" -#include "PortModel.hpp" -#include "PresetModel.hpp" #include "Serializer.hpp" using namespace std; @@ -60,7 +56,7 @@ Serializer::Serializer(Raul::RDF::World& world) } void -Serializer::to_file(SharedPtr<ObjectModel> object, const string& filename) +Serializer::to_file(SharedPtr<GraphObject> object, const string& filename) { _root_object = object; start_to_filename(filename); @@ -70,7 +66,7 @@ Serializer::to_file(SharedPtr<ObjectModel> object, const string& filename) string -Serializer::to_string(SharedPtr<ObjectModel> object) +Serializer::to_string(SharedPtr<GraphObject> object) { _root_object = object; start_to_string(); @@ -216,7 +212,7 @@ Serializer::find_file(const string& filename, const string& additional_path) #endif void -Serializer::serialize(SharedPtr<ObjectModel> object) throw (std::logic_error) +Serializer::serialize(SharedPtr<GraphObject> object) throw (std::logic_error) { if (!_model) throw std::logic_error("serialize called without serialization in progress"); @@ -322,7 +318,7 @@ Serializer::serialize_patch(SharedPtr<PatchModel> patch) void -Serializer::serialize_plugin(SharedPtr<PluginModel> plugin) +Serializer::serialize_plugin(SharedPtr<Shared::Plugin> plugin) { assert(_model); @@ -370,6 +366,7 @@ Serializer::serialize_node(SharedPtr<Shared::Node> node, const RDF::Node& node_i for (uint32_t i=0; i < node->num_ports(); ++i) { Port* p = node->port(i); + assert(p); const RDF::Node port_id = path_to_node_id(p->path()); serialize_port(p, port_id); _model->add_statement(node_id, "ingen:port", port_id); @@ -402,7 +399,8 @@ Serializer::serialize_port(const Port* port, const RDF::Node& port_id) _model->add_statement(port_id, "ingen:name", Atom(port->path().name().c_str())); - _model->add_statement(port_id, "rdf:type", Atom(port->type().uri())); + _model->add_statement(port_id, "rdf:type", + RDF::Node(_model->world(), RDF::Node::RESOURCE, port->type().uri())); if (port->type() == DataType::CONTROL && port->is_input()) _model->add_statement(port_id, "ingen:value", port->value()); diff --git a/src/libs/client/Serializer.hpp b/src/libs/client/Serializer.hpp index d40e77ae..fafedfa5 100644 --- a/src/libs/client/Serializer.hpp +++ b/src/libs/client/Serializer.hpp @@ -28,22 +28,23 @@ #include <raul/Atom.hpp> #include <raul/RDFWorld.hpp> #include <raul/RDFModel.hpp> -#include "ObjectModel.hpp" +using namespace Raul; using namespace Ingen::Shared; namespace Ingen { -namespace Shared { class Node; class Port; } +namespace Shared { + class Plugin; + class GraphObject; + class Node; + class Port; +} namespace Client { -class PluginModel; class PatchModel; -class NodeModel; -class PortModel; class ConnectionModel; -class PresetModel; /** Serializes Ingen objects (patches, nodes, etc) to RDF. @@ -55,11 +56,11 @@ class Serializer public: Serializer(Raul::RDF::World& world); - void to_file(SharedPtr<ObjectModel> object, const string& filename); - string to_string(SharedPtr<ObjectModel> object); + void to_file(SharedPtr<GraphObject> object, const string& filename); + string to_string(SharedPtr<GraphObject> object); void start_to_string(); - void serialize(SharedPtr<ObjectModel> object) throw (std::logic_error); + void serialize(SharedPtr<GraphObject> object) throw (std::logic_error); void serialize_connection(SharedPtr<ConnectionModel> c) throw (std::logic_error); string finish(); @@ -70,7 +71,7 @@ private: void setup_prefixes(); - void serialize_plugin(SharedPtr<PluginModel> p); + void serialize_plugin(SharedPtr<Shared::Plugin> p); void serialize_patch(SharedPtr<PatchModel> p); void serialize_node(SharedPtr<Shared::Node> n, const Raul::RDF::Node& id); @@ -81,7 +82,7 @@ private: typedef std::map<Raul::Path, Raul::RDF::Node> NodeMap; - SharedPtr<ObjectModel> _root_object; + SharedPtr<GraphObject> _root_object; Mode _mode; NodeMap _node_map; string _base_uri; diff --git a/src/libs/engine/BufferFactory.cpp b/src/libs/engine/BufferFactory.cpp index 84ff721b..25b09a56 100644 --- a/src/libs/engine/BufferFactory.cpp +++ b/src/libs/engine/BufferFactory.cpp @@ -34,7 +34,7 @@ create(DataType type, size_t size) else if (type.is_osc()) return new OSCBuffer(size); else - return NULL; + throw; } diff --git a/src/libs/engine/Connection.cpp b/src/libs/engine/Connection.cpp index 0d54fe9f..894a9db7 100644 --- a/src/libs/engine/Connection.cpp +++ b/src/libs/engine/Connection.cpp @@ -123,10 +123,12 @@ Connection::process(ProcessContext& context) * would avoid having to mix multiple times. Probably not a very common * case, but it would be faster anyway. */ - if (_must_mix && type() == DataType::CONTROL || type() == DataType::AUDIO) { + if (_must_mix && (type() == DataType::CONTROL || type() == DataType::AUDIO)) { const AudioBuffer* const src_buffer = (AudioBuffer*)src_port()->buffer(0); AudioBuffer* mix_buf = (AudioBuffer*)_local_buffer; + + assert(mix_buf); const size_t copy_size = std::min(src_buffer->size(), mix_buf->size()); diff --git a/src/libs/engine/JackAudioDriver.cpp b/src/libs/engine/JackAudioDriver.cpp index d1cde5ca..ce35ce9c 100644 --- a/src/libs/engine/JackAudioDriver.cpp +++ b/src/libs/engine/JackAudioDriver.cpp @@ -226,7 +226,7 @@ JackAudioDriver::remove_port(const Path& path) if ((*i)->patch_port()->path() == path) return _ports.erase(i)->elem(); // FIXME: LEAK - cerr << "[JackAudioDriver::remove_port] WARNING: Failed to find Jack port to remove!" << endl; + cerr << "[JackAudioDriver::remove_port] WARNING: Unable to find Jack port " << path << endl; return NULL; } diff --git a/src/libs/engine/JackMidiDriver.cpp b/src/libs/engine/JackMidiDriver.cpp index b07a4e37..448a84e6 100644 --- a/src/libs/engine/JackMidiDriver.cpp +++ b/src/libs/engine/JackMidiDriver.cpp @@ -235,7 +235,7 @@ JackMidiDriver::remove_port(const Path& path) if ((*i)->patch_port()->path() == path) return _out_ports.erase(i)->elem(); // FIXME: LEAK - cerr << "[JackMidiDriver::remove_input] WARNING: Failed to find Jack port to remove!" << endl; + cerr << "[JackMidiDriver::remove_input] WARNING: Unable to find Jack port " << path << endl; return NULL; } diff --git a/src/libs/gui/App.cpp b/src/libs/gui/App.cpp index 8c7c365c..255af745 100644 --- a/src/libs/gui/App.cpp +++ b/src/libs/gui/App.cpp @@ -41,6 +41,7 @@ #include "ConnectWindow.hpp" #include "ThreadedLoader.hpp" #include "WindowFactory.hpp" +#include "Port.hpp" /*#ifdef HAVE_LASH #include "LashController.hpp" #endif*/ diff --git a/src/libs/gui/Configuration.cpp b/src/libs/gui/Configuration.cpp index f4c00545..e5b4fbd3 100644 --- a/src/libs/gui/Configuration.cpp +++ b/src/libs/gui/Configuration.cpp @@ -87,20 +87,20 @@ Configuration::get_port_color(const PortModel* p) { assert(p != NULL); - if (p->is_control()) { + if (p->type().is_control()) { return _control_port_color; - } else if (p->is_audio()) { + } else if (p->type().is_audio()) { return _audio_port_color; - } else if (p->is_midi()) { + } else if (p->type().is_midi()) { return _midi_port_color; - } else if (p->is_osc()) { + } else if (p->type().is_osc()) { return _osc_port_color; } - cerr << "[Configuration] Unknown port type " << p->type() << ", port will appear bright red." - << endl; + cerr << "[Configuration] Unknown port type " << p->type().uri() + << ", port will appear black." << endl; - return 0xFF0000B0; + return 0x000000FF; } diff --git a/src/libs/gui/ControlPanel.cpp b/src/libs/gui/ControlPanel.cpp index bef5e18b..422a4614 100644 --- a/src/libs/gui/ControlPanel.cpp +++ b/src/libs/gui/ControlPanel.cpp @@ -107,7 +107,7 @@ ControlPanel::add_port(SharedPtr<PortModel> pm) return; // Add port - if (pm->is_control() && pm->is_input()) { + if (pm->type().is_control() && pm->is_input()) { SliderControlGroup* cg = NULL; #if 0 if (pm->is_integer()) diff --git a/src/libs/gui/NodeControlWindow.cpp b/src/libs/gui/NodeControlWindow.cpp index 853a15bb..cfa22b10 100644 --- a/src/libs/gui/NodeControlWindow.cpp +++ b/src/libs/gui/NodeControlWindow.cpp @@ -114,7 +114,7 @@ NodeControlWindow::on_show() { for (PortModelList::const_iterator i = _node->ports().begin(); i != _node->ports().end(); ++i) - if ((*i)->is_control() && (*i)->is_input()) + if ((*i)->type().is_control() && (*i)->is_input()) App::instance().engine()->request_port_value((*i)->path()); if (_position_stored) diff --git a/src/libs/gui/NodeMenu.cpp b/src/libs/gui/NodeMenu.cpp index bd82fcca..cbb4c0df 100644 --- a/src/libs/gui/NodeMenu.cpp +++ b/src/libs/gui/NodeMenu.cpp @@ -131,7 +131,7 @@ NodeMenu::has_control_inputs() { const NodeModel* const nm = (NodeModel*)_object.get(); for (PortModelList::const_iterator i = nm->ports().begin(); i != nm->ports().end(); ++i) - if ((*i)->is_input() && (*i)->is_control()) + if ((*i)->is_input() && (*i)->type().is_control()) return true; return false; diff --git a/src/libs/gui/NodeModule.cpp b/src/libs/gui/NodeModule.cpp index 875a6d8c..b4309dfa 100644 --- a/src/libs/gui/NodeModule.cpp +++ b/src/libs/gui/NodeModule.cpp @@ -177,7 +177,7 @@ NodeModule::embed_gui(bool embed) sigc::mem_fun(this, &NodeModule::gui_size_request), false)); for (PortModelList::const_iterator p = _node->ports().begin(); p != _node->ports().end(); ++p) - if ((*p)->is_control() && (*p)->is_output()) + if ((*p)->type().is_control() && (*p)->is_output()) App::instance().engine()->enable_port_broadcasting((*p)->path()); } else { @@ -198,7 +198,7 @@ NodeModule::embed_gui(bool embed) _minimum_width = 0; // resize() takes care of it.. for (PortModelList::const_iterator p = _node->ports().begin(); p != _node->ports().end(); ++p) - if ((*p)->is_control() && (*p)->is_output()) + if ((*p)->type().is_control() && (*p)->is_output()) App::instance().engine()->disable_port_broadcasting((*p)->path()); } @@ -314,7 +314,7 @@ NodeModule::initialise_gui_values() { uint32_t index=0; for (PortModelList::const_iterator p = _node->ports().begin(); p != _node->ports().end(); ++p) { - if ((*p)->is_control()) + if ((*p)->type().is_control()) control_change(index, (*p)->value()); ++index; } diff --git a/src/libs/gui/PatchCanvas.cpp b/src/libs/gui/PatchCanvas.cpp index 5e3c7f78..e2e176cb 100644 --- a/src/libs/gui/PatchCanvas.cpp +++ b/src/libs/gui/PatchCanvas.cpp @@ -346,7 +346,7 @@ PatchCanvas::connect(boost::shared_ptr<FlowCanvas::Connectable> src_port, return; // Midi binding/learn shortcut - if (src->model()->is_midi() && dst->model()->is_control()) + if (src->model()->type().is_midi() && dst->model()->type().is_control()) { cerr << "[PatchCanvas] FIXME: MIDI binding shortcut" << endl; #if 0 diff --git a/src/libs/gui/PatchWindow.cpp b/src/libs/gui/PatchWindow.cpp index 6260221d..3566d83d 100644 --- a/src/libs/gui/PatchWindow.cpp +++ b/src/libs/gui/PatchWindow.cpp @@ -207,7 +207,7 @@ PatchWindow::set_patch(SharedPtr<PatchModel> patch, SharedPtr<PatchView> view) for (PortModelList::const_iterator p = patch->ports().begin(); p != patch->ports().end(); ++p) { - if ((*p)->is_control() && (*p)->is_input()) { + if ((*p)->type().is_control() && (*p)->is_input()) { _menu_view_control_window->property_sensitive() = true; break; } @@ -239,7 +239,7 @@ PatchWindow::set_patch(SharedPtr<PatchModel> patch, SharedPtr<PatchView> view) void PatchWindow::patch_port_added(SharedPtr<PortModel> port) { - if (port->is_control() && port->is_input()) { + if (port->type().is_control() && port->is_input()) { _menu_view_control_window->property_sensitive() = true; } } @@ -248,12 +248,12 @@ PatchWindow::patch_port_added(SharedPtr<PortModel> port) void PatchWindow::patch_port_removed(SharedPtr<PortModel> port) { - if (port->is_control() && port->is_input()) { + if (port->type().is_control() && port->is_input()) { bool found_control = false; for (PortModelList::const_iterator i = _patch->ports().begin(); i != _patch->ports().end(); ++i) { - if ((*i)->is_control() && (*i)->is_input()) { + if ((*i)->type().is_control() && (*i)->is_input()) { found_control = true; break; } diff --git a/src/libs/gui/Port.cpp b/src/libs/gui/Port.cpp index ccd9652c..e3dd0fd4 100644 --- a/src/libs/gui/Port.cpp +++ b/src/libs/gui/Port.cpp @@ -51,7 +51,7 @@ Port::Port(boost::shared_ptr<FlowCanvas::Module> module, SharedPtr<PortModel> pm _port_model->signal_renamed.connect(sigc::mem_fun(this, &Port::renamed)); - if (pm->is_control()) { + if (pm->type().is_control()) { show_control(); float min = 0.0f, max = 1.0f; diff --git a/src/libs/gui/Port.hpp b/src/libs/gui/Port.hpp index e381c59b..dbbf64d3 100644 --- a/src/libs/gui/Port.hpp +++ b/src/libs/gui/Port.hpp @@ -15,8 +15,8 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef PORT_H -#define PORT_H +#ifndef GUI_PORT_H +#define GUI_PORT_H #include <cassert> #include <string> @@ -63,4 +63,4 @@ private: } // namespace GUI } // namespace Ingen -#endif // PORT_H +#endif // GUI_PORT_H diff --git a/src/libs/serialisation/Loader.cpp b/src/libs/serialisation/Loader.cpp index 45d66740..30958198 100644 --- a/src/libs/serialisation/Loader.cpp +++ b/src/libs/serialisation/Loader.cpp @@ -215,8 +215,9 @@ Loader::load(SharedPtr<EngineInterface> engine, "SELECT DISTINCT ?port ?type ?name ?datatype ?floatkey ?floatval ?portval WHERE {\n") + patch_uri + " ingen:port ?port .\n" "?port a ?type ;\n" - " ingen:name ?name ;\n" - " ingen:dataType ?datatype .\n" + " a ?datatype ;\n" + " ingen:name ?name .\n" + " FILTER (?type != ?datatype && ((?type = ingen:InputPort) || (?type = ingen:OutputPort)))\n" "OPTIONAL { ?port ?floatkey ?floatval . \n" " FILTER ( datatype(?floatval) = xsd:decimal ) }\n" "OPTIONAL { ?port ingen:value ?portval . \n" @@ -228,12 +229,11 @@ Loader::load(SharedPtr<EngineInterface> engine, for (RDF::Query::Results::iterator i = results.begin(); i != results.end(); ++i) { const string name = (*i)["name"].to_string(); const string type = rdf_world->qualify((*i)["type"].to_string()); - const string datatype = (*i)["datatype"].to_string(); + const string datatype = rdf_world->qualify((*i)["datatype"].to_string()); const Path port_path = patch_path.base() + (string)name; - + if (created.find(port_path) == created.end()) { - //cerr << "TYPE: " << type << endl; bool is_output = (type == "ingen:OutputPort"); // FIXME: check validity engine->create_port(port_path, datatype, is_output); created.insert(port_path); |