summaryrefslogtreecommitdiffstats
path: root/src/server
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-05-15 18:40:44 +0000
committerDavid Robillard <d@drobilla.net>2012-05-15 18:40:44 +0000
commit49b9a38100f66c66aee6531bf83e0527ea0386b5 (patch)
tree63ef643aca90f1b9c36e7a58f87a9140424e0ce7 /src/server
parentee62a6fdb161987fe3bddce7b71a49b3fe393bc5 (diff)
downloadingen-49b9a38100f66c66aee6531bf83e0527ea0386b5.tar.gz
ingen-49b9a38100f66c66aee6531bf83e0527ea0386b5.tar.bz2
ingen-49b9a38100f66c66aee6531bf83e0527ea0386b5.zip
Remove ClientSender and move code to Get.cpp (the only place it was used).
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4421 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/server')
-rw-r--r--src/server/Broadcaster.cpp1
-rw-r--r--src/server/ObjectSender.cpp154
-rw-r--r--src/server/ObjectSender.hpp65
-rw-r--r--src/server/events/Get.cpp84
-rw-r--r--src/server/wscript1
5 files changed, 82 insertions, 223 deletions
diff --git a/src/server/Broadcaster.cpp b/src/server/Broadcaster.cpp
index dcb78ea5..d65c48ac 100644
--- a/src/server/Broadcaster.cpp
+++ b/src/server/Broadcaster.cpp
@@ -23,7 +23,6 @@
#include "Broadcaster.hpp"
#include "EdgeImpl.hpp"
#include "EngineStore.hpp"
-#include "ObjectSender.hpp"
#include "PluginImpl.hpp"
#include "util.hpp"
diff --git a/src/server/ObjectSender.cpp b/src/server/ObjectSender.cpp
deleted file mode 100644
index e3ab1f5a..00000000
--- a/src/server/ObjectSender.cpp
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- This file is part of Ingen.
- Copyright 2007-2012 David Robillard <http://drobilla.net/>
-
- Ingen is free software: you can redistribute it and/or modify it under the
- terms of the GNU Affero General Public License as published by the Free
- Software Foundation, either version 3 of the License, or any later version.
-
- Ingen is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU Affero General Public License for details.
-
- You should have received a copy of the GNU Affero General Public License
- along with Ingen. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "ObjectSender.hpp"
-#include "ingen/Interface.hpp"
-#include "ingen/shared/URIs.hpp"
-#include "EngineStore.hpp"
-#include "PatchImpl.hpp"
-#include "NodeImpl.hpp"
-#include "PortImpl.hpp"
-#include "EdgeImpl.hpp"
-#include "NodeFactory.hpp"
-#include "PortType.hpp"
-#include "AudioBuffer.hpp"
-
-using namespace std;
-
-namespace Ingen {
-namespace Server {
-
-void
-ObjectSender::send_object(Interface* client,
- const GraphObjectImpl* object,
- bool recursive)
-{
- 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(Interface* client,
- const PatchImpl* patch,
- bool recursive,
- bool bundle)
-{
- if (bundle)
- client->bundle_begin();
-
- client->put(patch->path(),
- patch->properties(Resource::INTERNAL),
- Resource::INTERNAL);
-
- client->put(patch->path(),
- patch->properties(Resource::EXTERNAL),
- Resource::EXTERNAL);
-
- if (recursive) {
- // Send nodes
- for (Raul::List<NodeImpl*>::const_iterator j = patch->nodes().begin();
- j != patch->nodes().end(); ++j) {
- const NodeImpl* const node = (*j);
- send_node(client, node, true, false);
- }
-
- // 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, false);
- }
-
- // Send edges
- for (PatchImpl::Edges::const_iterator j = patch->edges().begin();
- j != patch->edges().end(); ++j)
- client->connect(j->second->tail_path(), j->second->head_path());
- }
-
- if (bundle)
- client->bundle_end();
-}
-
-/** Sends a node or a patch */
-void
-ObjectSender::send_node(Interface* client, const NodeImpl* node, bool recursive, bool bundle)
-{
- PluginImpl* const plugin = node->plugin_impl();
-
- if (plugin->type() == Plugin::Patch) {
- send_patch(client, (PatchImpl*)node, recursive);
- return;
- }
-
- if (plugin->uri().length() == 0) {
- Raul::error << "Node " << node->path() << "'s plugin has no URI! Not sending." << endl;
- return;
- }
-
- if (bundle)
- client->bundle_begin();
-
- client->put(node->path(), node->properties());
-
- if (recursive) {
- // Send ports
- for (size_t j=0; j < node->num_ports(); ++j)
- send_port(client, node->port_impl(j), false);
- }
-
- if (bundle)
- client->bundle_end();
-}
-
-void
-ObjectSender::send_port(Interface* client, const PortImpl* port, bool bundle)
-{
- assert(port);
-
- if (bundle)
- client->bundle_begin();
-
- if (port->is_a(PortType::CONTROL) || port->is_a(PortType::CV)) {
- Resource::Properties props = port->properties();
- props.erase(port->bufs().uris().ingen_value);
- props.insert(make_pair(port->bufs().uris().ingen_value,
- port->value()));
- client->put(port->path(), props);
- } else {
- client->put(port->path(), port->properties());
- }
-
- if (bundle)
- client->bundle_end();
-}
-
-} // namespace Server
-} // namespace Ingen
-
diff --git a/src/server/ObjectSender.hpp b/src/server/ObjectSender.hpp
deleted file mode 100644
index 68e26ce6..00000000
--- a/src/server/ObjectSender.hpp
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- This file is part of Ingen.
- Copyright 2007-2012 David Robillard <http://drobilla.net/>
-
- Ingen is free software: you can redistribute it and/or modify it under the
- terms of the GNU Affero General Public License as published by the Free
- Software Foundation, either version 3 of the License, or any later version.
-
- Ingen is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU Affero General Public License for details.
-
- You should have received a copy of the GNU Affero General Public License
- along with Ingen. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef INGEN_ENGINE_OBJECTSENDER_HPP
-#define INGEN_ENGINE_OBJECTSENDER_HPP
-
-namespace Ingen {
-
-class Interface;
-
-namespace Server {
-
-class GraphObjectImpl;
-class PatchImpl;
-class NodeImpl;
-class PortImpl;
-class PluginImpl;
-
-/** Utility class for sending GraphObjects to clients via Interface.
- *
- * While Interface is the direct low level message-based interface
- * (protocol), this is used from the engine to easily send proper Objects
- * with these messages (which is done in a few different parts of the code).
- *
- * Basically a serialiser, except to calls on Interface rather than
- * eg a byte stream.
- */
-class ObjectSender {
-public:
- static void send_object(Interface* client,
- const GraphObjectImpl* object,
- bool recursive);
-
-private:
- static void send_patch(Interface* client,
- const PatchImpl* patch,
- bool recursive,
- bool bundle = true);
- static void send_node(Interface* client,
- const NodeImpl* node,
- bool recursive,
- bool bundle = true);
- static void send_port(Interface* client,
- const PortImpl* port,
- bool bundle = true);
-};
-
-} // namespace Server
-} // namespace Ingen
-
-#endif // INGEN_ENGINE_OBJECTSENDER_HPP
-
diff --git a/src/server/events/Get.cpp b/src/server/events/Get.cpp
index 9558c6aa..80fc34e8 100644
--- a/src/server/events/Get.cpp
+++ b/src/server/events/Get.cpp
@@ -14,6 +14,8 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <utility>
+
#include "ingen/Interface.hpp"
#include "Broadcaster.hpp"
@@ -21,13 +23,18 @@
#include "Engine.hpp"
#include "EngineStore.hpp"
#include "Get.hpp"
-#include "ObjectSender.hpp"
+#include "NodeImpl.hpp"
+#include "PatchImpl.hpp"
#include "PluginImpl.hpp"
+#include "PortImpl.hpp"
namespace Ingen {
namespace Server {
namespace Events {
+static void
+send_patch(Interface* client, const PatchImpl* patch);
+
Get::Get(Engine& engine,
Interface* client,
int32_t id,
@@ -57,6 +64,68 @@ Get::pre_process()
Event::pre_process();
}
+static void
+send_port(Interface* client, const PortImpl* port)
+{
+ if (port->is_a(PortType::CONTROL) || port->is_a(PortType::CV)) {
+ Resource::Properties props = port->properties();
+ props.erase(port->bufs().uris().ingen_value);
+ props.insert(std::make_pair(port->bufs().uris().ingen_value,
+ port->value()));
+ client->put(port->path(), props);
+ } else {
+ client->put(port->path(), port->properties());
+ }
+}
+
+static void
+send_node(Interface* client, const NodeImpl* node)
+{
+ PluginImpl* const plugin = node->plugin_impl();
+ if (plugin->type() == Plugin::Patch) {
+ send_patch(client, (PatchImpl*)node);
+ } else if (plugin->uri().length() == 0) {
+ Raul::error((Raul::fmt("Node %1%'s plugin has no URI\n")
+ % node->path()));
+ } else {
+ client->put(node->path(), node->properties());
+ for (size_t j=0; j < node->num_ports(); ++j) {
+ send_port(client, node->port_impl(j));
+ }
+ }
+}
+
+static void
+send_patch(Interface* client, const PatchImpl* patch)
+{
+ client->put(patch->path(),
+ patch->properties(Resource::INTERNAL),
+ Resource::INTERNAL);
+
+ client->put(patch->path(),
+ patch->properties(Resource::EXTERNAL),
+ Resource::EXTERNAL);
+
+ // Send nodes
+ for (Raul::List<NodeImpl*>::const_iterator j = patch->nodes().begin();
+ j != patch->nodes().end(); ++j) {
+ const NodeImpl* const node = (*j);
+ send_node(client, node);
+ }
+
+ // 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 edges
+ for (PatchImpl::Edges::const_iterator j = patch->edges().begin();
+ j != patch->edges().end(); ++j) {
+ client->connect(j->second->tail_path(), j->second->head_path());
+ }
+}
+
void
Get::post_process()
{
@@ -82,7 +151,18 @@ Get::post_process()
} else {
respond(SUCCESS);
if (_object) {
- ObjectSender::send_object(_request_client, _object, true);
+ _request_client->bundle_begin();
+ const NodeImpl* node = NULL;
+ const PatchImpl* patch = NULL;
+ const PortImpl* port = NULL;
+ if ((patch = dynamic_cast<const PatchImpl*>(_object))) {
+ send_patch(_request_client, patch);
+ } else if ((node = dynamic_cast<const NodeImpl*>(_object))) {
+ send_node(_request_client, node);
+ } else if ((port = dynamic_cast<const PortImpl*>(_object))) {
+ send_port(_request_client, port);
+ }
+ _request_client->bundle_end();
} else if (_plugin) {
_request_client->put(_uri, _plugin->properties());
}
diff --git a/src/server/wscript b/src/server/wscript
index e63b5fa7..986cc76a 100644
--- a/src/server/wscript
+++ b/src/server/wscript
@@ -24,7 +24,6 @@ def build(bld):
NodeFactory.cpp
NodeImpl.cpp
Notification.cpp
- ObjectSender.cpp
OutputPort.cpp
PatchImpl.cpp
PluginImpl.cpp