summaryrefslogtreecommitdiffstats
path: root/src/libs/engine/events
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2006-06-19 06:17:49 +0000
committerDavid Robillard <d@drobilla.net>2006-06-19 06:17:49 +0000
commit2db1897709eba0e80677bd09e8444e7320e15120 (patch)
tree8062b5ede632c1c084a2c3b43bbd1a3d9991734e /src/libs/engine/events
parent4adc4f4a2b4f57f43affcd48f2c01c60f471b20a (diff)
downloadingen-2db1897709eba0e80677bd09e8444e7320e15120.tar.gz
ingen-2db1897709eba0e80677bd09e8444e7320e15120.tar.bz2
ingen-2db1897709eba0e80677bd09e8444e7320e15120.zip
Connecting of patch ports internally (seemingly anyway, data not flowing yet)
git-svn-id: http://svn.drobilla.net/lad/grauph@61 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/libs/engine/events')
-rw-r--r--src/libs/engine/events/ConnectionEvent.cpp48
-rw-r--r--src/libs/engine/events/ConnectionEvent.h6
-rw-r--r--src/libs/engine/events/DisconnectNodeEvent.cpp2
-rw-r--r--src/libs/engine/events/DisconnectNodeEvent.h2
-rw-r--r--src/libs/engine/events/DisconnectionEvent.cpp8
-rw-r--r--src/libs/engine/events/DisconnectionEvent.h2
6 files changed, 42 insertions, 26 deletions
diff --git a/src/libs/engine/events/ConnectionEvent.cpp b/src/libs/engine/events/ConnectionEvent.cpp
index fcfa3bbc..1d5b3ba1 100644
--- a/src/libs/engine/events/ConnectionEvent.cpp
+++ b/src/libs/engine/events/ConnectionEvent.cpp
@@ -19,7 +19,7 @@
#include "Responder.h"
#include "Om.h"
#include "OmApp.h"
-#include "ConnectionBase.h"
+#include "TypedConnection.h"
#include "InputPort.h"
#include "OutputPort.h"
#include "Patch.h"
@@ -58,7 +58,9 @@ ConnectionEvent::~ConnectionEvent()
void
ConnectionEvent::pre_process()
{
- if (m_src_port_path.parent().parent() != m_dst_port_path.parent().parent()) {
+ if (m_src_port_path.parent().parent() != m_dst_port_path.parent().parent()
+ && m_src_port_path.parent() != m_dst_port_path.parent().parent()
+ && m_src_port_path.parent().parent() != m_dst_port_path.parent()) {
m_error = PARENT_PATCH_DIFFERENT;
QueuedEvent::pre_process();
return;
@@ -72,22 +74,22 @@ ConnectionEvent::pre_process()
return;
}*/
- Port* port1 = om->object_store()->find_port(m_src_port_path);
- Port* port2 = om->object_store()->find_port(m_dst_port_path);
+ m_src_port = om->object_store()->find_port(m_src_port_path);
+ m_dst_port = om->object_store()->find_port(m_dst_port_path);
- if (port1 == NULL || port2 == NULL) {
+ if (m_src_port == NULL || m_dst_port == NULL) {
m_error = PORT_NOT_FOUND;
QueuedEvent::pre_process();
return;
}
- if (port1->type() != port2->type()) {
+ if (m_src_port->type() != m_dst_port->type() || m_src_port->buffer_size() != m_dst_port->buffer_size()) {
m_error = TYPE_MISMATCH;
QueuedEvent::pre_process();
return;
}
- if (port1->is_output() && port2->is_input()) {
+ /*if (port1->is_output() && port2->is_input()) {
m_src_port = port1;
m_dst_port = port2;
} else if (port2->is_output() && port1->is_input()) {
@@ -97,16 +99,16 @@ ConnectionEvent::pre_process()
m_error = TYPE_MISMATCH;
QueuedEvent::pre_process();
return;
- }
+ }*/
// Create the typed event to actually do the work
- const DataType type = port1->type();
+ const DataType type = m_src_port->type();
if (type == DataType::FLOAT) {
m_typed_event = new TypedConnectionEvent<sample>(m_responder,
- (OutputPort<sample>*)m_src_port, (InputPort<sample>*)m_dst_port);
+ dynamic_cast<OutputPort<sample>*>(m_src_port), dynamic_cast<InputPort<sample>*>(m_dst_port));
} else if (type == DataType::MIDI) {
m_typed_event = new TypedConnectionEvent<MidiMessage>(m_responder,
- (OutputPort<MidiMessage>*)m_src_port, (InputPort<MidiMessage>*)m_dst_port);
+ dynamic_cast<OutputPort<MidiMessage>*>(m_src_port), dynamic_cast<InputPort<MidiMessage>*>(m_dst_port));
} else {
m_error = TYPE_MISMATCH;
QueuedEvent::pre_process();
@@ -177,23 +179,37 @@ TypedConnectionEvent<T>::pre_process()
{
Node* const src_node = m_src_port->parent_node();
Node* const dst_node = m_dst_port->parent_node();
-
- m_patch = src_node->parent_patch();
+
+ if (src_node->parent_patch() != dst_node->parent_patch()) {
+ // Connection to a patch port from inside the patch
+ assert(src_node->parent() == dst_node || dst_node->parent() == src_node);
+ if (src_node->parent() == dst_node)
+ m_patch = dynamic_cast<Patch*>(dst_node);
+ else
+ m_patch = dynamic_cast<Patch*>(src_node);
+ } else {
+ // Normal connection between nodes with the same parent
+ m_patch = src_node->parent_patch();
+ }
+
+ assert(m_patch);
if (src_node == NULL || dst_node == NULL) {
+ cerr << "ERR 1\n";
m_succeeded = false;
QueuedEvent::pre_process();
return;
}
- if (src_node->parent() != m_patch || dst_node->parent() != m_patch) {
+ if (src_node->parent() != m_patch && dst_node->parent() != m_patch) {
+ cerr << "ERR 2\n";
m_succeeded = false;
QueuedEvent::pre_process();
return;
}
- m_connection = new ConnectionBase<T>(m_src_port, m_dst_port);
- m_port_listnode = new ListNode<ConnectionBase<T>*>(m_connection);
+ m_connection = new TypedConnection<T>(m_src_port, m_dst_port);
+ m_port_listnode = new ListNode<TypedConnection<T>*>(m_connection);
m_patch_listnode = new ListNode<Connection*>(m_connection);
dst_node->providers()->push_back(new ListNode<Node*>(src_node));
diff --git a/src/libs/engine/events/ConnectionEvent.h b/src/libs/engine/events/ConnectionEvent.h
index 369a3903..e2a50d53 100644
--- a/src/libs/engine/events/ConnectionEvent.h
+++ b/src/libs/engine/events/ConnectionEvent.h
@@ -33,7 +33,7 @@ class Node;
class Connection;
class MidiMessage;
class Port;
-template <typename T> class ConnectionBase;
+template <typename T> class TypedConnection;
template <typename T> class InputPort;
template <typename T> class OutputPort;
template <typename T> class TypedConnectionEvent; // helper, defined below
@@ -93,9 +93,9 @@ private:
Patch* m_patch;
Array<Node*>* m_process_order; ///< New process order for Patch
- ConnectionBase<T>* m_connection;
+ TypedConnection<T>* m_connection;
ListNode<Connection*>* m_patch_listnode;
- ListNode<ConnectionBase<T>*>* m_port_listnode;
+ ListNode<TypedConnection<T>*>* m_port_listnode;
bool m_succeeded;
};
diff --git a/src/libs/engine/events/DisconnectNodeEvent.cpp b/src/libs/engine/events/DisconnectNodeEvent.cpp
index 4c4e19a7..e430acc5 100644
--- a/src/libs/engine/events/DisconnectNodeEvent.cpp
+++ b/src/libs/engine/events/DisconnectNodeEvent.cpp
@@ -22,7 +22,7 @@
#include "Maid.h"
#include "List.h"
#include "Node.h"
-#include "ConnectionBase.h"
+#include "TypedConnection.h"
#include "DisconnectionEvent.h"
#include "Port.h"
#include "Array.h"
diff --git a/src/libs/engine/events/DisconnectNodeEvent.h b/src/libs/engine/events/DisconnectNodeEvent.h
index a82fbaec..4bcbdf94 100644
--- a/src/libs/engine/events/DisconnectNodeEvent.h
+++ b/src/libs/engine/events/DisconnectNodeEvent.h
@@ -29,7 +29,7 @@ class DisconnectionEvent;
class Patch;
class Node;
class Connection;
-template <typename T> class ConnectionBase;
+template <typename T> class TypedConnection;
class Port;
template <typename T> class InputPort;
template <typename T> class OutputPort;
diff --git a/src/libs/engine/events/DisconnectionEvent.cpp b/src/libs/engine/events/DisconnectionEvent.cpp
index 0a3a4f7b..34570537 100644
--- a/src/libs/engine/events/DisconnectionEvent.cpp
+++ b/src/libs/engine/events/DisconnectionEvent.cpp
@@ -19,7 +19,7 @@
#include "Responder.h"
#include "Om.h"
#include "OmApp.h"
-#include "ConnectionBase.h"
+#include "TypedConnection.h"
#include "InputPort.h"
#include "OutputPort.h"
#include "Patch.h"
@@ -124,10 +124,10 @@ DisconnectionEvent::pre_process()
const DataType type = m_src_port->type();
if (type == DataType::FLOAT) {
m_typed_event = new TypedDisconnectionEvent<sample>(m_responder,
- (OutputPort<sample>*)m_src_port, (InputPort<sample>*)m_dst_port);
+ dynamic_cast<OutputPort<sample>*>(m_src_port), dynamic_cast<InputPort<sample>*>(m_dst_port));
} else if (type == DataType::MIDI) {
m_typed_event = new TypedDisconnectionEvent<MidiMessage>(m_responder,
- (OutputPort<MidiMessage>*)m_src_port, (InputPort<MidiMessage>*)m_dst_port);
+ dynamic_cast<OutputPort<MidiMessage>*>(m_src_port), dynamic_cast<InputPort<MidiMessage>*>(m_dst_port));
} else {
m_error = TYPE_MISMATCH;
QueuedEvent::pre_process();
@@ -250,7 +250,7 @@ TypedDisconnectionEvent<T>::execute(samplecount offset)
{
if (m_succeeded) {
- ListNode<ConnectionBase<T>*>* const port_connection
+ ListNode<TypedConnection<T>*>* const port_connection
= m_dst_port->remove_connection(m_src_port);
if (port_connection != NULL) {
diff --git a/src/libs/engine/events/DisconnectionEvent.h b/src/libs/engine/events/DisconnectionEvent.h
index 77d4aabe..445815dd 100644
--- a/src/libs/engine/events/DisconnectionEvent.h
+++ b/src/libs/engine/events/DisconnectionEvent.h
@@ -33,7 +33,7 @@ class Node;
class Connection;
class MidiMessage;
class Port;
-template <typename T> class ConnectionBase;
+template <typename T> class TypedConnection;
template <typename T> class InputPort;
template <typename T> class OutputPort;
template <typename T> class TypedDisconnectionEvent; // helper, defined below