summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/ingen/Port.hpp7
-rw-r--r--include/ingen/client/ObjectModel.hpp2
-rw-r--r--include/ingen/client/PortModel.hpp15
-rw-r--r--src/client/ClientStore.cpp27
-rw-r--r--src/client/ObjectModel.cpp6
-rw-r--r--src/client/PortModel.cpp1
-rw-r--r--src/gui/App.cpp6
-rw-r--r--src/gui/App.hpp2
-rw-r--r--src/gui/Configuration.cpp4
-rw-r--r--src/gui/ControlPanel.cpp3
-rw-r--r--src/gui/Port.cpp2
-rw-r--r--src/gui/PortMenu.cpp4
-rw-r--r--src/serialisation/Serialiser.cpp20
-rw-r--r--src/server/Buffer.hpp4
-rw-r--r--src/server/BufferFactory.hpp2
-rw-r--r--src/server/CompiledPatch.hpp7
-rw-r--r--src/server/ConnectionImpl.hpp8
-rw-r--r--src/server/Driver.hpp5
-rw-r--r--src/server/Engine.cpp6
-rw-r--r--src/server/EventBuffer.hpp2
-rw-r--r--src/server/InputPort.cpp4
-rw-r--r--src/server/NodeImpl.hpp12
-rw-r--r--src/server/ObjectBuffer.hpp2
-rw-r--r--src/server/ObjectSender.cpp2
-rw-r--r--src/server/PatchImpl.hpp8
-rw-r--r--src/server/PortImpl.cpp3
-rw-r--r--src/server/PortImpl.hpp6
-rw-r--r--src/server/PortType.hpp (renamed from include/ingen/PortType.hpp)0
-rw-r--r--src/server/events/CreatePort.cpp35
-rw-r--r--src/server/events/CreatePort.hpp9
-rw-r--r--src/server/events/SetMetadata.cpp12
-rw-r--r--src/server/mix.hpp4
-rw-r--r--src/shared/ResourceImpl.cpp40
-rw-r--r--src/shared/ResourceImpl.hpp13
34 files changed, 142 insertions, 141 deletions
diff --git a/include/ingen/Port.hpp b/include/ingen/Port.hpp
index 5d04d0f1..6780f635 100644
--- a/include/ingen/Port.hpp
+++ b/include/ingen/Port.hpp
@@ -23,7 +23,6 @@
#include <set>
#include "ingen/GraphObject.hpp"
-#include "ingen/PortType.hpp"
namespace Raul { class Atom; }
@@ -38,12 +37,6 @@ namespace Ingen {
class Port : public virtual GraphObject
{
public:
- typedef std::set<PortType> PortTypes;
-
- virtual const PortTypes& types() const = 0;
-
- inline bool is_a(PortType type) const { return types().find(type) != types().end(); }
-
virtual bool supports(const Raul::URI& value_type) const = 0;
virtual uint32_t index() const = 0;
diff --git a/include/ingen/client/ObjectModel.hpp b/include/ingen/client/ObjectModel.hpp
index 50ba2805..6d4fbae5 100644
--- a/include/ingen/client/ObjectModel.hpp
+++ b/include/ingen/client/ObjectModel.hpp
@@ -55,6 +55,8 @@ class ObjectModel : virtual public GraphObject
public:
virtual ~ObjectModel();
+ bool is_a(const Raul::URI& type) const;
+
const Raul::Atom& get_property(const Raul::URI& key) const;
const Raul::Atom& set_property(const Raul::URI& key,
diff --git a/include/ingen/client/PortModel.hpp b/include/ingen/client/PortModel.hpp
index 7fd4d746..900d576e 100644
--- a/include/ingen/client/PortModel.hpp
+++ b/include/ingen/client/PortModel.hpp
@@ -41,8 +41,6 @@ class PortModel : public ObjectModel, public Ingen::Port
public:
enum Direction { INPUT, OUTPUT };
- const PortTypes& types() const { return _types; }
-
bool supports(const Raul::URI& value_type) const;
inline uint32_t index() const { return _index; }
@@ -53,7 +51,7 @@ public:
bool port_property(const Raul::URI& uri) const;
- bool is_numeric() const { return is_a(PortType::CONTROL); }
+ bool is_numeric() const { return ObjectModel::is_a("http://lv2plug.in/ns/lv2core#ControlPort"); }
bool is_logarithmic() const { return port_property("http://drobilla.net/ns/ingen#logarithmic"); }
bool is_integer() const { return port_property("http://lv2plug.in/ns/lv2core#integer"); }
bool is_toggle() const { return port_property("http://lv2plug.in/ns/lv2core#toggled"); }
@@ -90,17 +88,15 @@ private:
friend class ClientStore;
PortModel(Shared::LV2URIMap& uris,
- const Raul::Path& path, uint32_t index, PortType type, Direction dir)
+ const Raul::Path& path,
+ uint32_t index,
+ Direction dir)
: ObjectModel(uris, path)
, _index(index)
, _direction(dir)
, _current_val(0.0f)
, _connections(0)
- {
- _types.insert(type);
- if (type == PortType::UNKNOWN)
- Raul::warn << "[PortModel] Unknown port type" << std::endl;
- }
+ {}
void add_child(SharedPtr<ObjectModel> c) { throw; }
bool remove_child(SharedPtr<ObjectModel> c) { throw; }
@@ -111,7 +107,6 @@ private:
void set(SharedPtr<ObjectModel> model);
uint32_t _index;
- std::set<PortType> _types;
Direction _direction;
Raul::Atom _current_val;
size_t _connections;
diff --git a/src/client/ClientStore.cpp b/src/client/ClientStore.cpp
index fb90f390..ed1fde66 100644
--- a/src/client/ClientStore.cpp
+++ b/src/client/ClientStore.cpp
@@ -284,10 +284,9 @@ ClientStore::put(const URI& uri,
#endif
bool is_patch, is_node, is_port, is_output;
- PortType data_type(PortType::UNKNOWN);
ResourceImpl::type(uris(), properties,
- is_patch, is_node, is_port, is_output,
- data_type);
+ is_patch, is_node, is_port, is_output);
+
// Check if uri is a plugin
const Atom& type = properties.find(_uris->rdf_type)->second;
if (type.type() == Atom::URI) {
@@ -344,20 +343,16 @@ ClientStore::put(const URI& uri,
LOG(warn) << "Node " << path << " has no plugin" << endl;
}
} else if (is_port) {
- if (data_type != PortType::UNKNOWN) {
- PortModel::Direction pdir = is_output ? PortModel::OUTPUT : PortModel::INPUT;
- const Iterator i = properties.find(_uris->lv2_index);
- if (i != properties.end() && i->second.type() == Atom::INT) {
- const uint32_t index = i->second.get_int32();
- SharedPtr<PortModel> p(
- new PortModel(uris(), path, index, data_type, pdir));
- p->set_properties(properties);
- add_object(p);
- } else {
- LOG(error) << "Port " << path << " has no index" << endl;
- }
+ PortModel::Direction pdir = is_output ? PortModel::OUTPUT : PortModel::INPUT;
+ const Iterator i = properties.find(_uris->lv2_index);
+ if (i != properties.end() && i->second.type() == Atom::INT) {
+ const uint32_t index = i->second.get_int32();
+ SharedPtr<PortModel> p(
+ new PortModel(uris(), path, index, pdir));
+ p->set_properties(properties);
+ add_object(p);
} else {
- LOG(warn) << "Port " << path << " has no type" << endl;
+ LOG(error) << "Port " << path << " has no index" << endl;
}
} else {
LOG(warn) << "Ignoring object " << path << " with unknown type "
diff --git a/src/client/ObjectModel.cpp b/src/client/ObjectModel.cpp
index de783ac2..f09af326 100644
--- a/src/client/ObjectModel.cpp
+++ b/src/client/ObjectModel.cpp
@@ -47,6 +47,12 @@ ObjectModel::~ObjectModel()
{
}
+bool
+ObjectModel::is_a(const Raul::URI& type) const
+{
+ return has_property(_uris.rdf_type, type);
+}
+
const Raul::Atom&
ObjectModel::set_property(const Raul::URI& key, const Raul::Atom& value,
Resource::Graph ctx)
diff --git a/src/client/PortModel.cpp b/src/client/PortModel.cpp
index 8404d60e..3d84de53 100644
--- a/src/client/PortModel.cpp
+++ b/src/client/PortModel.cpp
@@ -51,7 +51,6 @@ PortModel::set(SharedPtr<ObjectModel> model)
SharedPtr<PortModel> port = PtrCast<PortModel>(model);
if (port) {
_index = port->_index;
- _types = port->_types;
_direction = port->_direction;
_current_val = port->_current_val;
_connections = port->_connections;
diff --git a/src/gui/App.cpp b/src/gui/App.cpp
index 055b4ef7..8e234031 100644
--- a/src/gui/App.cpp
+++ b/src/gui/App.cpp
@@ -386,10 +386,10 @@ App::icon_destroyed(void* data)
}
bool
-App::can_control(const Ingen::Port* port) const
+App::can_control(const Client::PortModel* port) const
{
- return port->is_a(PortType::CONTROL)
- || (port->is_a(PortType::VALUE)
+ return port->is_a(uris().lv2_ControlPort)
+ || (port->is_a(uris().atom_ValuePort)
&& (port->supports(uris().atom_Float32)
|| port->supports(uris().atom_String)));
}
diff --git a/src/gui/App.hpp b/src/gui/App.hpp
index bd753078..2f26716f 100644
--- a/src/gui/App.hpp
+++ b/src/gui/App.hpp
@@ -86,7 +86,7 @@ public:
void port_activity(Port* port);
void activity_port_destroyed(Port* port);
- bool can_control(const Ingen::Port* port) const;
+ bool can_control(const Client::PortModel* port) const;
bool signal() const { return _enable_signal; }
bool disable_signals() { bool old = _enable_signal; _enable_signal = false; return old; }
diff --git a/src/gui/Configuration.cpp b/src/gui/Configuration.cpp
index 5018cbf1..5e300bc1 100644
--- a/src/gui/Configuration.cpp
+++ b/src/gui/Configuration.cpp
@@ -84,13 +84,13 @@ Configuration::get_port_color(const PortModel* p)
{
assert(p != NULL);
const Shared::LV2URIMap& uris = App::instance().uris();
- if (p->is_a(PortType::AUDIO)) {
+ if (p->is_a(uris.lv2_AudioPort)) {
return _audio_port_color;
} else if (p->supports(uris.atom_String)) {
return _string_port_color;
} else if (App::instance().can_control(p)) {
return _control_port_color;
- } else if (p->is_a(PortType::EVENTS) || p->is_a(PortType::MESSAGE)) {
+ } else if (p->is_a(uris.ev_EventPort) || p->is_a(uris.atom_MessagePort)) {
return _event_port_color;
}
diff --git a/src/gui/ControlPanel.cpp b/src/gui/ControlPanel.cpp
index 00ae05c8..06ae6491 100644
--- a/src/gui/ControlPanel.cpp
+++ b/src/gui/ControlPanel.cpp
@@ -16,7 +16,6 @@
*/
#include "ingen/ServerInterface.hpp"
-#include "ingen/PortType.hpp"
#include "shared/LV2URIMap.hpp"
#include "ingen/client/NodeModel.hpp"
#include "ingen/client/PortModel.hpp"
@@ -91,7 +90,7 @@ ControlPanel::add_port(SharedPtr<const PortModel> pm)
ToggleControl* tc;
WidgetFactory::get_widget_derived("toggle_control", tc);
control = tc;
- } else if (pm->is_a(PortType::CONTROL)
+ } else if (pm->is_a(App::instance().uris().lv2_ControlPort)
|| pm->supports(App::instance().uris().atom_Float32)) {
SliderControl* sc;
WidgetFactory::get_widget_derived("control_strip", sc);
diff --git a/src/gui/Port.cpp b/src/gui/Port.cpp
index b0c4ffcb..a3a7afb2 100644
--- a/src/gui/Port.cpp
+++ b/src/gui/Port.cpp
@@ -214,7 +214,7 @@ peak_color(float peak)
void
Port::activity(const Raul::Atom& value)
{
- if (model()->is_a(PortType::AUDIO)) {
+ if (model()->is_a(App::instance().uris().lv2_AudioPort)) {
set_fill_color(peak_color(value.get_float()));
} else {
App::instance().port_activity(this);
diff --git a/src/gui/PortMenu.cpp b/src/gui/PortMenu.cpp
index 8dafd83f..6e51ee45 100644
--- a/src/gui/PortMenu.cpp
+++ b/src/gui/PortMenu.cpp
@@ -43,6 +43,8 @@ PortMenu::PortMenu(BaseObjectType* cobject,
void
PortMenu::init(SharedPtr<const PortModel> port, bool patch_port)
{
+ const LV2URIMap& uris = App::instance().uris();
+
ObjectMenu::init(port);
_patch_port = patch_port;
@@ -61,7 +63,7 @@ PortMenu::init(SharedPtr<const PortModel> port, bool patch_port)
_destroy_menuitem->set_sensitive(false);
}
- if (port->is_a(PortType::EVENTS))
+ if (port->is_a(uris.ev_EventPort))
_polyphonic_menuitem->hide();
const bool is_control = App::instance().can_control(port.get())
diff --git a/src/serialisation/Serialiser.cpp b/src/serialisation/Serialiser.cpp
index 22632810..f216028e 100644
--- a/src/serialisation/Serialiser.cpp
+++ b/src/serialisation/Serialiser.cpp
@@ -522,13 +522,6 @@ Serialiser::Impl::serialise_port(const Port* port,
Sord::Curie(world, "lv2:OutputPort"));
}
- for (Port::PortTypes::const_iterator i = port->types().begin();
- i != port->types().end(); ++i) {
- _model->add_statement(port_id,
- Sord::Curie(world, "rdf:type"),
- Sord::URI(world, i->uri().str()));
- }
-
_model->add_statement(port_id,
Sord::Curie(world, "lv2:symbol"),
Sord::Literal(world, port->path().symbol()));
@@ -540,19 +533,6 @@ Serialiser::Impl::serialise_port(const Port* port,
port_id,
Sord::Curie(world, "lv2:index"),
AtomRDF::atom_to_node(*_model, Atom((int)port->index())));
-
- if (!port->get_property(NS_LV2 "default").is_valid()) {
- if (port->is_input()) {
- if (port->value().is_valid()) {
- _model->add_statement(
- port_id,
- Sord::Curie(world, "lv2:default"),
- AtomRDF::atom_to_node(*_model, port->value()));
- } else if (port->is_a(PortType::CONTROL)) {
- LOG(warn) << "Port " << port->path() << " has no lv2:default" << endl;
- }
- }
- }
}
}
diff --git a/src/server/Buffer.hpp b/src/server/Buffer.hpp
index 45afa6aa..0b3c9348 100644
--- a/src/server/Buffer.hpp
+++ b/src/server/Buffer.hpp
@@ -24,13 +24,13 @@
#include <boost/intrusive_ptr.hpp>
#include <boost/utility.hpp>
-#include "ingen/PortType.hpp"
#include "raul/AtomicInt.hpp"
#include "raul/Deletable.hpp"
#include "raul/SharedPtr.hpp"
-#include "types.hpp"
#include "BufferFactory.hpp"
+#include "PortType.hpp"
+#include "types.hpp"
namespace Ingen {
namespace Server {
diff --git a/src/server/BufferFactory.hpp b/src/server/BufferFactory.hpp
index 58dc55af..5690113c 100644
--- a/src/server/BufferFactory.hpp
+++ b/src/server/BufferFactory.hpp
@@ -20,10 +20,10 @@
#include <map>
#include <boost/intrusive_ptr.hpp>
-#include "ingen/PortType.hpp"
#include "glibmm/thread.h"
#include "raul/RingBuffer.hpp"
#include "raul/AtomicPtr.hpp"
+#include "PortType.hpp"
#include "types.hpp"
namespace Ingen {
diff --git a/src/server/CompiledPatch.hpp b/src/server/CompiledPatch.hpp
index 65ee9fad..519b5a2a 100644
--- a/src/server/CompiledPatch.hpp
+++ b/src/server/CompiledPatch.hpp
@@ -19,14 +19,17 @@
#define INGEN_ENGINE_COMPILEDPATCH_HPP
#include <vector>
-#include "raul/List.hpp"
-#include "raul/Deletable.hpp"
+
#include <boost/utility.hpp>
+#include "raul/Deletable.hpp"
+#include "raul/List.hpp"
+
namespace Ingen {
namespace Server {
class ConnectionImpl;
+class NodeImpl;
/** All information required about a node to execute it in an audio thread.
*/
diff --git a/src/server/ConnectionImpl.hpp b/src/server/ConnectionImpl.hpp
index 9dd71233..33ec0608 100644
--- a/src/server/ConnectionImpl.hpp
+++ b/src/server/ConnectionImpl.hpp
@@ -19,13 +19,15 @@
#define INGEN_ENGINE_CONNECTIONIMPL_HPP
#include <cstdlib>
+
#include <boost/intrusive_ptr.hpp>
#include <boost/utility.hpp>
-#include "raul/log.hpp"
-#include "raul/Deletable.hpp"
-#include "ingen/PortType.hpp"
+
#include "ingen/Connection.hpp"
#include "lv2/lv2plug.in/ns/ext/atom/atom.h"
+#include "raul/Deletable.hpp"
+#include "raul/log.hpp"
+
#include "PortImpl.hpp"
using namespace std;
diff --git a/src/server/Driver.hpp b/src/server/Driver.hpp
index f9416e3e..0178b4f0 100644
--- a/src/server/Driver.hpp
+++ b/src/server/Driver.hpp
@@ -21,7 +21,6 @@
#include <string>
#include <boost/utility.hpp>
#include "raul/Deletable.hpp"
-#include "ingen/PortType.hpp"
#include "ingen/EventType.hpp"
#include "DuplexPort.hpp"
@@ -96,10 +95,6 @@ public:
virtual Raul::Deletable* remove_port(const Raul::Path& path,
DriverPort** port=NULL) = 0;
- /** Return true iff this driver supports the given type of I/O */
- virtual bool supports(PortType port_type,
- EventType event_type) = 0;
-
virtual void set_root_patch(PatchImpl* patch) = 0;
virtual PatchImpl* root_patch() = 0;
diff --git a/src/server/Engine.cpp b/src/server/Engine.cpp
index 301d90e1..5d27ae2e 100644
--- a/src/server/Engine.cpp
+++ b/src/server/Engine.cpp
@@ -177,6 +177,7 @@ Engine::activate()
// Add control input
Resource::Properties in_properties(control_properties);
in_properties.insert(make_pair(uris.rdf_type, uris.lv2_InputPort));
+ in_properties.insert(make_pair(uris.rdf_type, uris.ev_EventPort));
in_properties.insert(make_pair(uris.lv2_index, 0));
in_properties.insert(make_pair(uris.ingenui_canvas_x,
Resource::Property(32.0f, Resource::EXTERNAL)));
@@ -185,11 +186,12 @@ Engine::activate()
execute_and_delete_event(context, new Events::CreatePort(
*this, SharedPtr<Request>(), 0,
- "/control_in", uris.ev_EventPort, false, in_properties));
+ "/control_in", false, in_properties));
// Add control out
Resource::Properties out_properties(control_properties);
out_properties.insert(make_pair(uris.rdf_type, uris.lv2_OutputPort));
+ out_properties.insert(make_pair(uris.rdf_type, uris.ev_EventPort));
out_properties.insert(make_pair(uris.lv2_index, 1));
out_properties.insert(make_pair(uris.ingenui_canvas_x,
Resource::Property(128.0f, Resource::EXTERNAL)));
@@ -198,7 +200,7 @@ Engine::activate()
execute_and_delete_event(context, new Events::CreatePort(
*this, SharedPtr<Request>(), 0,
- "/control_out", uris.ev_EventPort, true, out_properties));
+ "/control_out", true, out_properties));
}
_driver->activate();
diff --git a/src/server/EventBuffer.hpp b/src/server/EventBuffer.hpp
index de67ae0c..668a0c6b 100644
--- a/src/server/EventBuffer.hpp
+++ b/src/server/EventBuffer.hpp
@@ -21,7 +21,7 @@
#include "lv2/lv2plug.in/ns/ext/atom/atom.h"
#include "lv2/lv2plug.in/ns/ext/event/event.h"
#include "lv2/lv2plug.in/ns/ext/event/event-helpers.h"
-#include "ingen/PortType.hpp"
+
#include "Buffer.hpp"
namespace Ingen {
diff --git a/src/server/InputPort.cpp b/src/server/InputPort.cpp
index 4a1c9d25..2abd17eb 100644
--- a/src/server/InputPort.cpp
+++ b/src/server/InputPort.cpp
@@ -72,8 +72,8 @@ InputPort::apply_poly(Maid& maid, uint32_t poly)
return true;
}
-/** Set \a buffers appropriately if this port has \a num_connections connections.
- * \return true iff buffers are locally owned by the port
+/** Set @a buffers to the buffers to be used for this port.
+ * @return true iff buffers are locally owned by the port
*/
bool
InputPort::get_buffers(BufferFactory& bufs,
diff --git a/src/server/NodeImpl.hpp b/src/server/NodeImpl.hpp
index 0009316e..3fc4a5d6 100644
--- a/src/server/NodeImpl.hpp
+++ b/src/server/NodeImpl.hpp
@@ -19,12 +19,16 @@
#define INGEN_ENGINE_NODEIMPL_HPP
#include <string>
+
#include <boost/intrusive_ptr.hpp>
+
+#include "ingen/Node.hpp"
#include "raul/Array.hpp"
#include "raul/AtomicInt.hpp"
#include "raul/Semaphore.hpp"
-#include "ingen/Node.hpp"
+
#include "GraphObjectImpl.hpp"
+#include "PortType.hpp"
#include "types.hpp"
namespace Raul { template <typename T> class List; class Maid; }
@@ -183,8 +187,10 @@ public:
virtual void plugin(PluginImpl* pi) { _plugin = pi; }
- virtual void set_buffer_size(Context& context, BufferFactory& bufs,
- PortType type, size_t size);
+ virtual void set_buffer_size(Context& context,
+ BufferFactory& bufs,
+ PortType type,
+ size_t size);
/** The Patch this Node belongs to. */
inline PatchImpl* parent_patch() const { return (PatchImpl*)_parent; }
diff --git a/src/server/ObjectBuffer.hpp b/src/server/ObjectBuffer.hpp
index 11481ad1..93dc746b 100644
--- a/src/server/ObjectBuffer.hpp
+++ b/src/server/ObjectBuffer.hpp
@@ -19,7 +19,7 @@
#define INGEN_ENGINE_OBJECTBUFFER_HPP
#include "lv2/lv2plug.in/ns/ext/atom/atom.h"
-#include "ingen/PortType.hpp"
+
#include "Buffer.hpp"
namespace Ingen {
diff --git a/src/server/ObjectSender.cpp b/src/server/ObjectSender.cpp
index a166a885..16255135 100644
--- a/src/server/ObjectSender.cpp
+++ b/src/server/ObjectSender.cpp
@@ -24,7 +24,7 @@
#include "PortImpl.hpp"
#include "ConnectionImpl.hpp"
#include "NodeFactory.hpp"
-#include "ingen/PortType.hpp"
+#include "PortType.hpp"
#include "AudioBuffer.hpp"
using namespace std;
diff --git a/src/server/PatchImpl.hpp b/src/server/PatchImpl.hpp
index 20ff59a6..5795a066 100644
--- a/src/server/PatchImpl.hpp
+++ b/src/server/PatchImpl.hpp
@@ -20,12 +20,14 @@
#include <cstdlib>
#include <string>
-#include "raul/List.hpp"
-#include "ingen/PortType.hpp"
+
#include "ingen/Patch.hpp"
+#include "raul/List.hpp"
+
+#include "CompiledPatch.hpp"
#include "NodeImpl.hpp"
#include "PluginImpl.hpp"
-#include "CompiledPatch.hpp"
+#include "PortType.hpp"
namespace Ingen {
diff --git a/src/server/PortImpl.cpp b/src/server/PortImpl.cpp
index 73953b5c..ce75321d 100644
--- a/src/server/PortImpl.cpp
+++ b/src/server/PortImpl.cpp
@@ -22,8 +22,6 @@
#include "shared/LV2URIMap.hpp"
-#include "ingen/PortType.hpp"
-
#include "AudioBuffer.hpp"
#include "BufferFactory.hpp"
#include "Engine.hpp"
@@ -33,6 +31,7 @@
#include "Notification.hpp"
#include "ObjectBuffer.hpp"
#include "PortImpl.hpp"
+#include "PortType.hpp"
#include "ThreadManager.hpp"
using namespace std;
diff --git a/src/server/PortImpl.hpp b/src/server/PortImpl.hpp
index caf291f0..7baaf089 100644
--- a/src/server/PortImpl.hpp
+++ b/src/server/PortImpl.hpp
@@ -26,11 +26,11 @@
#include "raul/Atom.hpp"
#include "ingen/Port.hpp"
-#include "ingen/PortType.hpp"
#include "Buffer.hpp"
#include "Context.hpp"
#include "GraphObjectImpl.hpp"
+#include "PortType.hpp"
#include "types.hpp"
namespace Raul { class Maid; }
@@ -123,8 +123,12 @@ public:
uint32_t index() const { return _index; }
+ typedef std::set<PortType> PortTypes;
+
const PortTypes& types() const { return _types; }
+ inline bool is_a(PortType type) const { return _types.find(type) != _types.end(); }
+
PortType buffer_type() const;
bool supports(const Raul::URI& value_type) const;
diff --git a/include/ingen/PortType.hpp b/src/server/PortType.hpp
index 1fc9f995..1fc9f995 100644
--- a/include/ingen/PortType.hpp
+++ b/src/server/PortType.hpp
diff --git a/src/server/events/CreatePort.cpp b/src/server/events/CreatePort.cpp
index 5c3ecbd2..c6d7c296 100644
--- a/src/server/events/CreatePort.cpp
+++ b/src/server/events/CreatePort.cpp
@@ -46,21 +46,46 @@ CreatePort::CreatePort(
SharedPtr<Request> request,
SampleCount timestamp,
const Raul::Path& path,
- const Raul::URI& type,
bool is_output,
const Resource::Properties& properties)
: QueuedEvent(engine, request, timestamp)
, _path(path)
- , _type(type)
- , _is_output(is_output)
- , _data_type(type)
+ , _data_type(PortType::UNKNOWN)
, _patch(NULL)
, _patch_port(NULL)
+ , _ports_array(NULL)
, _driver_port(NULL)
, _properties(properties)
+ , _is_output(is_output)
{
- if (_data_type == PortType::UNKNOWN)
+ const Ingen::Shared::LV2URIMap& uris = *_engine.world()->uris().get();
+
+ typedef Resource::Properties::const_iterator Iterator;
+ typedef std::pair<Iterator, Iterator> Range;
+ const Range types = properties.equal_range(uris.rdf_type);
+ for (Iterator i = types.first; i != types.second; ++i) {
+ const Raul::Atom& type = i->second;
+ if (type.type() != Atom::URI) {
+ warn << "Non-URI port type " << type << endl;
+ continue;
+ }
+
+ if (type == uris.lv2_AudioPort) {
+ _data_type = PortType::AUDIO;
+ } else if (type == uris.lv2_ControlPort) {
+ _data_type = PortType::CONTROL;
+ } else if (type == uris.ev_EventPort) {
+ _data_type = PortType::EVENTS;
+ } else if (type == uris.atom_ValuePort) {
+ _data_type = PortType::VALUE;
+ } else if (type == uris.atom_MessagePort) {
+ _data_type = PortType::MESSAGE;
+ }
+ }
+
+ if (_data_type == PortType::UNKNOWN) {
_error = UNKNOWN_TYPE;
+ }
}
void
diff --git a/src/server/events/CreatePort.hpp b/src/server/events/CreatePort.hpp
index 56c0f0a0..4b1b03fa 100644
--- a/src/server/events/CreatePort.hpp
+++ b/src/server/events/CreatePort.hpp
@@ -21,9 +21,9 @@
#include "raul/Array.hpp"
#include "raul/Path.hpp"
-#include "ingen/PortType.hpp"
#include "ingen/Resource.hpp"
+#include "PortType.hpp"
#include "QueuedEvent.hpp"
namespace Ingen {
@@ -47,7 +47,6 @@ public:
SharedPtr<Request> request,
SampleCount timestamp,
const Raul::Path& path,
- const Raul::URI& type,
bool is_output,
const Resource::Properties& properties);
@@ -65,15 +64,13 @@ private:
Raul::Path _path;
Raul::URI _type;
- bool _is_output;
PortType _data_type;
PatchImpl* _patch;
PortImpl* _patch_port;
Raul::Array<PortImpl*>* _ports_array; ///< New (external) ports array for Patch
DriverPort* _driver_port; ///< Driver (eg Jack) port if this is a toplevel port
- bool _succeeded;
-
- Resource::Properties _properties;
+ Resource::Properties _properties;
+ bool _is_output;
};
} // namespace Server
diff --git a/src/server/events/SetMetadata.cpp b/src/server/events/SetMetadata.cpp
index bef968fc..4e40baeb 100644
--- a/src/server/events/SetMetadata.cpp
+++ b/src/server/events/SetMetadata.cpp
@@ -16,11 +16,12 @@
*/
#include <string>
+
#include <boost/format.hpp>
+
#include "raul/log.hpp"
#include "raul/Maid.hpp"
-#include "ingen/PortType.hpp"
-#include "shared/LV2URIMap.hpp"
+
#include "ClientBroadcaster.hpp"
#include "ControlBindings.hpp"
#include "CreateNode.hpp"
@@ -33,9 +34,11 @@
#include "PatchImpl.hpp"
#include "PluginImpl.hpp"
#include "PortImpl.hpp"
+#include "PortType.hpp"
#include "Request.hpp"
#include "SetMetadata.hpp"
#include "SetPortValue.hpp"
+#include "shared/LV2URIMap.hpp"
#define LOG(s) s << "[SetMetadata] "
@@ -120,8 +123,7 @@ SetMetadata::pre_process()
if (is_graph_object && !_object) {
Path path(_subject.str());
bool is_patch = false, is_node = false, is_port = false, is_output = false;
- PortType data_type(PortType::UNKNOWN);
- Shared::ResourceImpl::type(uris, _properties, is_patch, is_node, is_port, is_output, data_type);
+ Shared::ResourceImpl::type(uris, _properties, is_patch, is_node, is_port, is_output);
// Create a separate request without a source so EventSource isn't unblocked twice
SharedPtr<Request> sub_request(new Request(NULL, _request->client(), _request->id()));
@@ -139,7 +141,7 @@ SetMetadata::pre_process()
path, p->second.get_uri(), _properties);
} else if (is_port) {
_create_event = new CreatePort(_engine, sub_request, _time,
- path, data_type.uri(), is_output, _properties);
+ path, is_output, _properties);
}
if (_create_event) {
_create_event->pre_process();
diff --git a/src/server/mix.hpp b/src/server/mix.hpp
index 79b02477..c90c0e17 100644
--- a/src/server/mix.hpp
+++ b/src/server/mix.hpp
@@ -19,10 +19,12 @@
#define INGEN_ENGINE_MIX_HPP
#include <boost/intrusive_ptr.hpp>
+
#include "raul/log.hpp"
-#include "ingen/PortType.hpp"
+
#include "Buffer.hpp"
#include "Context.hpp"
+#include "PortType.hpp"
using namespace Raul;
diff --git a/src/shared/ResourceImpl.cpp b/src/shared/ResourceImpl.cpp
index d2b94294..29b464ee 100644
--- a/src/shared/ResourceImpl.cpp
+++ b/src/shared/ResourceImpl.cpp
@@ -103,18 +103,17 @@ ResourceImpl::get_property(const Raul::URI& uri) const
}
bool
-ResourceImpl::type(
- const LV2URIMap& uris,
- const Properties& properties,
- bool& patch,
- bool& node,
- bool& port, bool& is_output, PortType& data_type)
+ResourceImpl::type(const LV2URIMap& uris,
+ const Properties& properties,
+ bool& patch,
+ bool& node,
+ bool& port,
+ bool& is_output)
{
typedef Resource::Properties::const_iterator iterator;
const std::pair<iterator,iterator> types_range = properties.equal_range(uris.rdf_type);
patch = node = port = is_output = false;
- data_type = PortType::UNKNOWN;
for (iterator i = types_range.first; i != types_range.second; ++i) {
const Atom& atom = i->second;
if (atom.type() != Atom::URI) {
@@ -132,21 +131,6 @@ ResourceImpl::type(
} else if (atom == uris.lv2_OutputPort) {
port = true;
is_output = true;
- } else if (atom == uris.lv2_AudioPort) {
- port = true;
- data_type = PortType::AUDIO;
- } else if (atom == uris.lv2_ControlPort) {
- port = true;
- data_type = PortType::CONTROL;
- } else if (atom == uris.ev_EventPort) {
- data_type = PortType::EVENTS;
- port = true;
- } else if (atom == uris.atom_ValuePort) {
- data_type = PortType::VALUE;
- port = true;
- } else if (atom == uris.atom_MessagePort) {
- data_type = PortType::MESSAGE;
- port = true;
}
}
@@ -166,9 +150,17 @@ ResourceImpl::type(
void
ResourceImpl::set_properties(const Properties& p)
{
- for (Resource::Properties::const_iterator i = p.begin(); i != p.end(); ++i) {
- set_property(i->first, i->second, i->second.context());
+ /* Note a simple loop that calls set_property is inappropriate here since
+ it will not correctly set multiple properties in p (notably rdf:type)
+ */
+
+ // Erase existing properties with matching keys
+ for (Properties::const_iterator i = p.begin(); i != p.end(); ++i) {
+ _properties.erase(i->first);
}
+
+ // Set new properties
+ add_properties(p);
}
void
diff --git a/src/shared/ResourceImpl.hpp b/src/shared/ResourceImpl.hpp
index 6f5a2ed2..da358c0a 100644
--- a/src/shared/ResourceImpl.hpp
+++ b/src/shared/ResourceImpl.hpp
@@ -22,7 +22,6 @@
#include "raul/SharedPtr.hpp"
#include "ingen/Resource.hpp"
-#include "ingen/PortType.hpp"
namespace Ingen {
namespace Shared {
@@ -62,12 +61,12 @@ public:
* If some coherent ingen type is found, true is returned and the appropriate
* output parameter set to true. Otherwise false is returned.
*/
- static bool type(
- const LV2URIMap& uris,
- const Properties& properties,
- bool& patch,
- bool& node,
- bool& port, bool& is_output, PortType& data_type);
+ static bool type(const LV2URIMap& uris,
+ const Properties& properties,
+ bool& patch,
+ bool& node,
+ bool& port,
+ bool& is_output);
protected:
const Raul::Atom& set_property(const Raul::URI& uri, const Raul::Atom& value) const;