summaryrefslogtreecommitdiffstats
path: root/src/engine
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2008-11-16 05:34:01 +0000
committerDavid Robillard <d@drobilla.net>2008-11-16 05:34:01 +0000
commit0fd3c583e032a3cd5af877902d4561a45179a232 (patch)
treee6bc62875842fda0908f1aea3a51b67740825d71 /src/engine
parent24d998447070dbfef3eaf7762dce7e97c3903801 (diff)
downloadingen-0fd3c583e032a3cd5af877902d4561a45179a232.tar.gz
ingen-0fd3c583e032a3cd5af877902d4561a45179a232.tar.bz2
ingen-0fd3c583e032a3cd5af877902d4561a45179a232.zip
Follow new object creation via HTTP (serialising/parsing RDF to communicate between client and engine).
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@1722 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/engine')
-rw-r--r--src/engine/ClientBroadcaster.cpp14
-rw-r--r--src/engine/ClientBroadcaster.hpp6
-rw-r--r--src/engine/HTTPClientSender.cpp20
-rw-r--r--src/engine/HTTPClientSender.hpp8
-rw-r--r--src/engine/HTTPEngineReceiver.cpp2
-rw-r--r--src/engine/OSCClientSender.cpp25
-rw-r--r--src/engine/OSCClientSender.hpp3
-rw-r--r--src/engine/ObjectSender.cpp25
-rw-r--r--src/engine/ObjectSender.hpp5
-rw-r--r--src/engine/QueuedEngineInterface.cpp7
-rw-r--r--src/engine/QueuedEngineInterface.hpp2
-rw-r--r--src/engine/events/CreateNodeEvent.cpp2
-rw-r--r--src/engine/events/CreatePatchEvent.cpp3
-rw-r--r--src/engine/events/CreatePortEvent.cpp2
14 files changed, 112 insertions, 12 deletions
diff --git a/src/engine/ClientBroadcaster.cpp b/src/engine/ClientBroadcaster.cpp
index 19cb0cd4..aaee7b4a 100644
--- a/src/engine/ClientBroadcaster.cpp
+++ b/src/engine/ClientBroadcaster.cpp
@@ -245,9 +245,21 @@ ClientBroadcaster::send_program_remove(const string& node_path, int bank, int pr
}
+/** Send an object.
+ *
+ * @param recursive If true send all children of object
+ */
+void
+ClientBroadcaster::send_object(const GraphObjectImpl* p, bool recursive)
+{
+ for (Clients::const_iterator i = _clients.begin(); i != _clients.end(); ++i)
+ ObjectSender::send_object((*i).second, p, recursive);
+}
+
+
/** Send a patch.
*
- * Sends all objects underneath Patch - contained Nodes, etc.
+ * @param recursive If true send all children of object
*/
void
ClientBroadcaster::send_patch(const PatchImpl* p, bool recursive)
diff --git a/src/engine/ClientBroadcaster.hpp b/src/engine/ClientBroadcaster.hpp
index 2de4b1b9..9ddf1ed7 100644
--- a/src/engine/ClientBroadcaster.hpp
+++ b/src/engine/ClientBroadcaster.hpp
@@ -31,6 +31,7 @@ using std::string;
namespace Ingen {
+class GraphObjectImpl;
class NodeImpl;
class PortImpl;
class PluginImpl;
@@ -61,11 +62,12 @@ public:
void bundle_begin();
void bundle_end();
-
+
// Error that isn't the direct result of a request
void send_error(const string& msg);
-
+
void send_plugins(const NodeFactory::Plugins& plugin_list);
+ void send_object(const GraphObjectImpl* p, bool recursive);
void send_patch(const PatchImpl* p, bool recursive);
void send_node(const NodeImpl* node, bool recursive);
void send_port(const PortImpl* port);
diff --git a/src/engine/HTTPClientSender.cpp b/src/engine/HTTPClientSender.cpp
index ec60cb44..413dfe7f 100644
--- a/src/engine/HTTPClientSender.cpp
+++ b/src/engine/HTTPClientSender.cpp
@@ -17,7 +17,10 @@
#include <string>
#include "raul/Atom.hpp"
+#include "serialisation/Serialiser.hpp"
+#include "module/World.hpp"
#include "HTTPClientSender.hpp"
+#include "Engine.hpp"
using namespace std;
using namespace Raul;
@@ -74,6 +77,7 @@ HTTPClientSender::destroy(const std::string& path)
void
HTTPClientSender::patch_cleared(const std::string& patch_path)
{
+ send_chunk(string("<").append(patch_path).append("> ingen:empty true ."));
//send("/ingen/patch_cleared", "s", patch_path.c_str(), LO_ARGS_END);
}
@@ -140,6 +144,20 @@ HTTPClientSender::activity(const std::string& path)
//lo_send(_address, "/ingen/activity", "s", port_path.c_str(), LO_ARGS_END);
}
+static void null_deleter(const Shared::GraphObject*) {}
+
+void
+HTTPClientSender::new_object(const Shared::GraphObject* object)
+{
+ SharedPtr<Serialisation::Serialiser> serialiser = _engine.world()->serialiser;
+ serialiser->start_to_string("/", "");
+ // FIXME
+ boost::shared_ptr<Shared::GraphObject> obj((Shared::GraphObject*)object, null_deleter);
+ serialiser->serialise(obj);
+ string str = serialiser->finish();
+ send_chunk(str);
+}
+
void
HTTPClientSender::new_plugin(const std::string& uri,
@@ -159,7 +177,7 @@ HTTPClientSender::new_plugin(const std::string& uri,
void
HTTPClientSender::new_patch(const std::string& path, uint32_t poly)
{
- send_chunk(string("<").append(path).append("> a ingen:Patch"));
+ //send_chunk(string("<").append(path).append("> a ingen:Patch"));
}
diff --git a/src/engine/HTTPClientSender.hpp b/src/engine/HTTPClientSender.hpp
index 57aaed0e..5dc658d7 100644
--- a/src/engine/HTTPClientSender.hpp
+++ b/src/engine/HTTPClientSender.hpp
@@ -30,6 +30,8 @@
namespace Ingen {
+class Engine;
+
namespace Shared { class EngineInterface; }
@@ -44,7 +46,8 @@ class HTTPClientSender
, public Shared::HTTPSender
{
public:
- HTTPClientSender()
+ HTTPClientSender(Engine& engine)
+ : _engine(engine)
{}
bool enabled() const { return _enabled; }
@@ -69,6 +72,8 @@ public:
void response_error(int32_t id, const std::string& msg);
void error(const std::string& msg);
+
+ virtual void new_object(const Shared::GraphObject* object);
virtual void new_plugin(const std::string& uri,
const std::string& type_uri,
@@ -125,6 +130,7 @@ public:
uint32_t program);
private:
+ Engine& _engine;
std::string _url;
bool _enabled;
};
diff --git a/src/engine/HTTPEngineReceiver.cpp b/src/engine/HTTPEngineReceiver.cpp
index 82bebc0c..bda30264 100644
--- a/src/engine/HTTPEngineReceiver.cpp
+++ b/src/engine/HTTPEngineReceiver.cpp
@@ -150,7 +150,7 @@ HTTPEngineReceiver::message_callback(SoupServer* server, SoupMessage* msg, const
path = '/' + path.substr(6);
} else if (path.substr(0, 7) == "/stream") {
- HTTPClientSender* client = new HTTPClientSender();
+ HTTPClientSender* client = new HTTPClientSender(me->_engine);
me->register_client(client);
// Respond with port number of stream for client
diff --git a/src/engine/OSCClientSender.cpp b/src/engine/OSCClientSender.cpp
index aa99c1d8..fb87ba23 100644
--- a/src/engine/OSCClientSender.cpp
+++ b/src/engine/OSCClientSender.cpp
@@ -313,6 +313,31 @@ OSCClientSender::new_plugin(const std::string& uri,
}
+void
+OSCClientSender::new_object(const Shared::GraphObject* object)
+{
+ using namespace Shared;
+
+ const Patch* patch = dynamic_cast<const Patch*>(object);
+ if (patch) {
+ new_patch(patch->path(), patch->internal_polyphony());
+ return;
+ }
+
+ const Node* node = dynamic_cast<const Node*>(object);
+ if (node) {
+ new_node(node->path(), node->plugin()->uri());
+ return;
+ }
+
+ const Port* port = dynamic_cast<const Port*>(object);
+ if (port) {
+ new_port(port->path(), port->type().uri(), port->index(), !port->is_input());
+ return;
+ }
+}
+
+
/** \page client_osc_namespace
* <p> \b /ingen/new_patch - Notification of a new patch
* \arg \b path (string) - Path of new patch
diff --git a/src/engine/OSCClientSender.hpp b/src/engine/OSCClientSender.hpp
index 879484c8..04f240fe 100644
--- a/src/engine/OSCClientSender.hpp
+++ b/src/engine/OSCClientSender.hpp
@@ -25,6 +25,7 @@
#include <pthread.h>
#include "types.hpp"
#include "interface/ClientInterface.hpp"
+#include "interface/GraphObject.hpp"
#include "shared/OSCSender.hpp"
namespace Ingen {
@@ -76,6 +77,8 @@ public:
const std::string& symbol,
const std::string& name);
+ virtual void new_object(const Shared::GraphObject* object);
+
virtual void new_patch(const std::string& path, uint32_t poly);
virtual void new_node(const std::string& path,
diff --git a/src/engine/ObjectSender.cpp b/src/engine/ObjectSender.cpp
index bb2de6f8..8f38b738 100644
--- a/src/engine/ObjectSender.cpp
+++ b/src/engine/ObjectSender.cpp
@@ -31,6 +31,31 @@ namespace Ingen {
void
+ObjectSender::send_object(ClientInterface* client, const GraphObjectImpl* object, bool recursive)
+{
+ client->new_object(object);
+
+ const PatchImpl* patch = dynamic_cast<const PatchImpl*>(object);
+ if (patch) {
+ send_patch(client, patch, recursive);
+ return;
+ }
+
+ const NodeImpl* node = dynamic_cast<const NodeImpl*>(object);
+ if (node) {
+ send_node(client, node, recursive);
+ return;
+ }
+
+ const PortImpl* port = dynamic_cast<const PortImpl*>(object);
+ if (port) {
+ send_port(client, port);
+ return;
+ }
+}
+
+
+void
ObjectSender::send_patch(ClientInterface* client, const PatchImpl* patch, bool recursive)
{
client->bundle_begin();
diff --git a/src/engine/ObjectSender.hpp b/src/engine/ObjectSender.hpp
index 9b6eb000..e546fe2f 100644
--- a/src/engine/ObjectSender.hpp
+++ b/src/engine/ObjectSender.hpp
@@ -26,6 +26,7 @@ namespace Shared {
class ClientInterface;
} using Shared::ClientInterface;
+class GraphObjectImpl;
class PatchImpl;
class NodeImpl;
class PortImpl;
@@ -43,9 +44,7 @@ class PluginImpl;
*/
class ObjectSender {
public:
-
- // FIXME: Make all object parameters const
-
+ static void send_object(ClientInterface* client, const GraphObjectImpl* object, bool recursive);
static void send_patch(ClientInterface* client, const PatchImpl* patch, bool recursive);
static void send_node(ClientInterface* client, const NodeImpl* node, bool recursive);
static void send_port(ClientInterface* client, const PortImpl* port);
diff --git a/src/engine/QueuedEngineInterface.cpp b/src/engine/QueuedEngineInterface.cpp
index 76866198..62828102 100644
--- a/src/engine/QueuedEngineInterface.cpp
+++ b/src/engine/QueuedEngineInterface.cpp
@@ -139,6 +139,13 @@ QueuedEngineInterface::bundle_end()
// Object commands
void
+QueuedEngineInterface::new_object(const GraphObject* object)
+{
+ cout << "NEW OBJECT" << endl;
+}
+
+
+void
QueuedEngineInterface::new_patch(const string& path,
uint32_t poly)
{
diff --git a/src/engine/QueuedEngineInterface.hpp b/src/engine/QueuedEngineInterface.hpp
index 82513cb2..e7268e9e 100644
--- a/src/engine/QueuedEngineInterface.hpp
+++ b/src/engine/QueuedEngineInterface.hpp
@@ -73,6 +73,8 @@ public:
// Object commands
+ virtual void new_object(const Shared::GraphObject* object);
+
virtual void new_patch(const string& path,
uint32_t poly);
diff --git a/src/engine/events/CreateNodeEvent.cpp b/src/engine/events/CreateNodeEvent.cpp
index d616ce1f..29f7f96e 100644
--- a/src/engine/events/CreateNodeEvent.cpp
+++ b/src/engine/events/CreateNodeEvent.cpp
@@ -142,7 +142,7 @@ CreateNodeEvent::post_process()
_responder->respond_error(msg);
} else {
_responder->respond_ok();
- _engine.broadcaster()->send_node(_node, true); // yes, send ports
+ _engine.broadcaster()->send_object(_node, true); // yes, send ports
}
}
diff --git a/src/engine/events/CreatePatchEvent.cpp b/src/engine/events/CreatePatchEvent.cpp
index b390770a..56796557 100644
--- a/src/engine/events/CreatePatchEvent.cpp
+++ b/src/engine/events/CreatePatchEvent.cpp
@@ -127,7 +127,8 @@ CreatePatchEvent::post_process()
// Don't send ports/nodes that have been added since prepare()
// (otherwise they would be sent twice)
- _engine.broadcaster()->send_patch(_patch, false);
+ //_engine.broadcaster()->send_patch(_patch, false);
+ _engine.broadcaster()->send_object(_patch, false);
} else if (_error == INVALID_PATH) {
string msg = "Attempt to create patch with illegal path ";
diff --git a/src/engine/events/CreatePortEvent.cpp b/src/engine/events/CreatePortEvent.cpp
index b02bec2a..8cb30a4b 100644
--- a/src/engine/events/CreatePortEvent.cpp
+++ b/src/engine/events/CreatePortEvent.cpp
@@ -154,7 +154,7 @@ CreatePortEvent::post_process()
_responder->respond_error(msg);
} else {
_responder->respond_ok();
- _engine.broadcaster()->send_port(_patch_port);
+ _engine.broadcaster()->send_object(_patch_port, true);
}
}