diff options
author | David Robillard <d@drobilla.net> | 2012-05-15 18:40:44 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2012-05-15 18:40:44 +0000 |
commit | 49b9a38100f66c66aee6531bf83e0527ea0386b5 (patch) | |
tree | 63ef643aca90f1b9c36e7a58f87a9140424e0ce7 /src/server/events | |
parent | ee62a6fdb161987fe3bddce7b71a49b3fe393bc5 (diff) | |
download | ingen-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/events')
-rw-r--r-- | src/server/events/Get.cpp | 84 |
1 files changed, 82 insertions, 2 deletions
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()); } |