summaryrefslogtreecommitdiffstats
path: root/src/server/events
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-08-15 05:24:41 +0000
committerDavid Robillard <d@drobilla.net>2012-08-15 05:24:41 +0000
commit5dd1d9b720993fc7813fe12fca0844f95033ff1b (patch)
tree344151dd656894340d217a8fe33f8dba53fe160f /src/server/events
parent0a9297ed2a1622d252a389d8babc0656fedbe7fd (diff)
downloadingen-5dd1d9b720993fc7813fe12fca0844f95033ff1b.tar.gz
ingen-5dd1d9b720993fc7813fe12fca0844f95033ff1b.tar.bz2
ingen-5dd1d9b720993fc7813fe12fca0844f95033ff1b.zip
Use intrusive lists to store nodes and ports in their parent patch to avoid tedious allocated list node juggling.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4700 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/server/events')
-rw-r--r--src/server/events/CreateNode.cpp4
-rw-r--r--src/server/events/CreatePatch.cpp2
-rw-r--r--src/server/events/CreatePort.cpp4
-rw-r--r--src/server/events/CreatePort.hpp5
-rw-r--r--src/server/events/Delete.cpp107
-rw-r--r--src/server/events/Delete.hpp19
-rw-r--r--src/server/events/Get.cpp8
7 files changed, 64 insertions, 85 deletions
diff --git a/src/server/events/CreateNode.cpp b/src/server/events/CreateNode.cpp
index e88434b7..02902db5 100644
--- a/src/server/events/CreateNode.cpp
+++ b/src/server/events/CreateNode.cpp
@@ -97,8 +97,8 @@ CreateNode::pre_process()
_node->properties().insert(_properties.begin(), _properties.end());
_node->activate(*_engine.buffer_factory());
- // Add node to the store and the patch's pre-processor only node list
- _patch->add_node(new PatchImpl::Nodes::Node(_node));
+ // Add node to the store and the patch's pre-processor only node list
+ _patch->add_node(*_node);
_engine.store()->add(_node);
/* Compile patch with new node added for insertion in audio thread
diff --git a/src/server/events/CreatePatch.cpp b/src/server/events/CreatePatch.cpp
index 368f8883..25f90d5d 100644
--- a/src/server/events/CreatePatch.cpp
+++ b/src/server/events/CreatePatch.cpp
@@ -83,7 +83,7 @@ CreatePatch::pre_process()
_patch->add_property(uris.rdf_type,
Resource::Property(uris.ingen_Node, Resource::EXTERNAL));
- _parent->add_node(new PatchImpl::Nodes::Node(_patch));
+ _parent->add_node(*_patch);
if (_parent->enabled()) {
_patch->enable();
_compiled_patch = _parent->compile();
diff --git a/src/server/events/CreatePort.cpp b/src/server/events/CreatePort.cpp
index 2782d654..49ceed95 100644
--- a/src/server/events/CreatePort.cpp
+++ b/src/server/events/CreatePort.cpp
@@ -140,9 +140,9 @@ CreatePort::pre_process()
_engine.store()->add(_patch_port);
if (_is_output) {
- _patch->add_output(new Raul::List<PortImpl*>::Node(_patch_port));
+ _patch->add_output(*_patch_port);
} else {
- _patch->add_input(new Raul::List<PortImpl*>::Node(_patch_port));
+ _patch->add_input(*_patch_port);
}
if (!_patch->parent()) {
diff --git a/src/server/events/CreatePort.hpp b/src/server/events/CreatePort.hpp
index 22304b4c..c8e4c695 100644
--- a/src/server/events/CreatePort.hpp
+++ b/src/server/events/CreatePort.hpp
@@ -28,9 +28,10 @@
namespace Ingen {
namespace Server {
+class DuplexPort;
+class EnginePort;
class PatchImpl;
class PortImpl;
-class EnginePort;
namespace Events {
@@ -58,7 +59,7 @@ private:
PortType _port_type;
LV2_URID _buf_type;
PatchImpl* _patch;
- PortImpl* _patch_port;
+ DuplexPort* _patch_port;
Raul::Array<PortImpl*>* _ports_array; ///< New external port array for Patch
Raul::Array<PortImpl*>* _old_ports_array;
EnginePort* _engine_port; ///< Driver port if on the root
diff --git a/src/server/events/Delete.cpp b/src/server/events/Delete.cpp
index 84b29a6f..e7001287 100644
--- a/src/server/events/Delete.cpp
+++ b/src/server/events/Delete.cpp
@@ -42,8 +42,6 @@ Delete::Delete(Engine& engine,
: Event(engine, client, id, time)
, _uri(uri)
, _engine_port(NULL)
- , _patch_node_listnode(NULL)
- , _patch_port_listnode(NULL)
, _ports_array(NULL)
, _compiled_patch(NULL)
, _disconnect_event(NULL)
@@ -62,7 +60,7 @@ Delete::~Delete()
bool
Delete::pre_process()
{
- if (_path == "/" || _path == "/control_in" || _path == "/control_out") {
+ if (_path.is_root() || _path == "/control_in" || _path == "/control_out") {
return Event::pre_process_done(NOT_DELETABLE, _path);
}
@@ -71,49 +69,47 @@ Delete::pre_process()
_removed_bindings = _engine.control_bindings()->remove(_path);
Store::iterator iter = _engine.store()->find(_path);
- if (iter != _engine.store()->end()) {
- if (!(_node = PtrCast<NodeImpl>(iter->second))) {
- _port = PtrCast<PortImpl>(iter->second);
- }
+ if (iter == _engine.store()->end()) {
+ return Event::pre_process_done(NOT_FOUND, _path);
}
- if (iter != _engine.store()->end()) {
- _engine.store()->remove(iter, _removed_objects);
+ if (!(_node = PtrCast<NodeImpl>(iter->second))) {
+ _port = PtrCast<DuplexPort>(iter->second);
}
- if (_node && !_path.is_root()) {
- assert(_node->parent_patch());
- _patch_node_listnode = _node->parent_patch()->remove_node(Raul::Symbol(_path.symbol()));
- if (_patch_node_listnode) {
- assert(_patch_node_listnode->elem() == _node.get());
+ if (!_node && !_port) {
+ return Event::pre_process_done(NOT_DELETABLE, _path);
+ }
- _disconnect_event = new DisconnectAll(_engine, _node->parent_patch(), _node.get());
- _disconnect_event->pre_process();
+ PatchImpl* parent = _node ? _node->parent_patch() : _port->parent_patch();
+ if (!parent) {
+ return Event::pre_process_done(INTERNAL_ERROR, _path);
+ }
- if (_node->parent_patch()->enabled()) {
- _compiled_patch = _node->parent_patch()->compile();
- }
+ _engine.store()->remove(iter, _removed_objects);
+
+ if (_node) {
+ parent->remove_node(*_node);
+ _disconnect_event = new DisconnectAll(_engine, parent, _node.get());
+ _disconnect_event->pre_process();
+
+ if (parent->enabled()) {
+ _compiled_patch = parent->compile();
}
} else if (_port) {
- assert(_port->parent_patch());
- _patch_port_listnode = _port->parent_patch()->remove_port(Raul::Symbol(_path.symbol()));
- if (_patch_port_listnode) {
- assert(_patch_port_listnode->elem() == _port.get());
-
- _disconnect_event = new DisconnectAll(_engine, _port->parent_patch(), _port.get());
- _disconnect_event->pre_process();
-
- if (_port->parent_patch()->enabled()) {
- _compiled_patch = _port->parent_patch()->compile();
- _ports_array = _port->parent_patch()->build_ports_array();
- assert(_ports_array->size() == _port->parent_patch()->num_ports_non_rt());
- }
-
- if (!_port->parent_patch()->parent()) {
- _engine_port = _engine.driver()->get_port(_port->path());
- }
+ parent->remove_port(*_port);
+ _disconnect_event = new DisconnectAll(_engine, parent, _port.get());
+ _disconnect_event->pre_process();
+
+ if (parent->enabled()) {
+ _compiled_patch = parent->compile();
+ _ports_array = parent->build_ports_array();
+ assert(_ports_array->size() == parent->num_ports_non_rt());
}
+ if (!parent->parent()) {
+ _engine_port = _engine.driver()->get_port(_port->path());
+ }
}
return Event::pre_process_done(SUCCESS);
@@ -122,35 +118,23 @@ Delete::pre_process()
void
Delete::execute(ProcessContext& context)
{
- PatchImpl* parent_patch = NULL;
-
- if (_patch_node_listnode) {
- assert(_node);
-
- if (_disconnect_event)
- _disconnect_event->execute(context);
-
- parent_patch = _node->parent_patch();
-
- } else if (_patch_port_listnode) {
- assert(_port);
-
- if (_disconnect_event)
- _disconnect_event->execute(context);
-
- parent_patch = _port->parent_patch();
+ if (_disconnect_event) {
+ _disconnect_event->execute(context);
+ }
- _engine.maid()->push(_port->parent_patch()->external_ports());
- _port->parent_patch()->external_ports(_ports_array);
+ PatchImpl* parent = _node ? _node->parent_patch() : _port->parent_patch();
+ if (_port) {
+ _engine.maid()->push(parent->external_ports());
+ parent->external_ports(_ports_array);
if (_engine_port) {
_engine.driver()->remove_port(context, _engine_port);
}
}
- if (parent_patch) {
- _engine.maid()->push(parent_patch->compiled_patch());
- parent_patch->compiled_patch(_compiled_patch);
+ if (parent) {
+ _engine.maid()->push(parent->compiled_patch());
+ parent->compiled_patch(_compiled_patch);
}
}
@@ -159,12 +143,9 @@ Delete::post_process()
{
_lock.release();
_removed_bindings.reset();
- if (!respond() && (_patch_node_listnode || _patch_port_listnode)) {
- if (_patch_node_listnode) {
+ if (!respond() && (_node || _port)) {
+ if (_node) {
_node->deactivate();
- delete _patch_node_listnode;
- } else if (_patch_port_listnode) {
- delete _patch_port_listnode;
}
_engine.broadcaster()->bundle_begin();
diff --git a/src/server/events/Delete.hpp b/src/server/events/Delete.hpp
index a493fcf7..f307eba4 100644
--- a/src/server/events/Delete.hpp
+++ b/src/server/events/Delete.hpp
@@ -32,6 +32,7 @@ namespace Server {
class NodeImpl;
class PortImpl;
+class DuplexPort;
class EnginePort;
class CompiledPatch;
@@ -69,16 +70,14 @@ public:
void post_process();
private:
- Raul::URI _uri;
- Raul::Path _path;
- SharedPtr<NodeImpl> _node; ///< Non-NULL iff a node
- SharedPtr<PortImpl> _port; ///< Non-NULL iff a port
- EnginePort* _engine_port;
- PatchImpl::Nodes::Node* _patch_node_listnode;
- Raul::List<PortImpl*>::Node* _patch_port_listnode;
- Raul::Array<PortImpl*>* _ports_array; ///< New (external) ports for Patch
- CompiledPatch* _compiled_patch; ///< Patch's new process order
- DisconnectAll* _disconnect_event;
+ Raul::URI _uri;
+ Raul::Path _path;
+ SharedPtr<NodeImpl> _node; ///< Non-NULL iff a node
+ SharedPtr<DuplexPort> _port; ///< Non-NULL iff a port
+ EnginePort* _engine_port;
+ Raul::Array<PortImpl*>* _ports_array; ///< New (external) ports for Patch
+ CompiledPatch* _compiled_patch; ///< Patch's new process order
+ DisconnectAll* _disconnect_event;
SharedPtr<ControlBindings::Bindings> _removed_bindings;
Store::Objects _removed_objects;
diff --git a/src/server/events/Get.cpp b/src/server/events/Get.cpp
index b826aa5d..294a15b3 100644
--- a/src/server/events/Get.cpp
+++ b/src/server/events/Get.cpp
@@ -109,16 +109,14 @@ send_patch(Interface* client, const PatchImpl* patch)
Resource::EXTERNAL);
// Send nodes
- for (Raul::List<NodeImpl*>::const_iterator j = patch->nodes().begin();
+ for (PatchImpl::Nodes::const_iterator j = patch->nodes().begin();
j != patch->nodes().end(); ++j) {
- const NodeImpl* const node = (*j);
- send_node(client, node);
+ send_node(client, &*j);
}
// Send ports
for (uint32_t i = 0; i < patch->num_ports_non_rt(); ++i) {
- PortImpl* const port = patch->port_impl(i);
- send_port(client, port);
+ send_port(client, patch->port_impl(i));
}
// Send edges