summaryrefslogtreecommitdiffstats
path: root/src/engine/events
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine/events')
-rw-r--r--src/engine/events/RequestMetadataEvent.cpp43
-rw-r--r--src/engine/events/RequestMetadataEvent.hpp17
-rw-r--r--src/engine/events/SetMetadataEvent.cpp30
-rw-r--r--src/engine/events/SetMetadataEvent.hpp19
4 files changed, 63 insertions, 46 deletions
diff --git a/src/engine/events/RequestMetadataEvent.cpp b/src/engine/events/RequestMetadataEvent.cpp
index cf8a127a..14cbcfb3 100644
--- a/src/engine/events/RequestMetadataEvent.cpp
+++ b/src/engine/events/RequestMetadataEvent.cpp
@@ -23,6 +23,7 @@
#include "EngineStore.hpp"
#include "ClientBroadcaster.hpp"
#include "PortImpl.hpp"
+#include "PluginImpl.hpp"
#include "AudioBuffer.hpp"
using namespace std;
@@ -36,15 +37,16 @@ using namespace Shared;
RequestMetadataEvent::RequestMetadataEvent(Engine& engine,
SharedPtr<Responder> responder,
SampleCount timestamp,
- bool property,
- const Path& node_path,
+ bool is_property,
+ const URI& subject,
const URI& key)
: QueuedEvent(engine, responder, timestamp)
+ , _error(NO_ERROR)
, _special_type(NONE)
- , _path(node_path)
- , _property(property)
+ , _uri(subject)
, _key(key)
- , _object(NULL)
+ , _resource(0)
+ , _is_property(is_property)
{
}
@@ -52,9 +54,14 @@ RequestMetadataEvent::RequestMetadataEvent(Engine& engine,
void
RequestMetadataEvent::pre_process()
{
+ const bool is_object = (_uri.scheme() == Path::scheme && Path::is_valid(_uri.str()));
if (_responder->client()) {
- _object = _engine.engine_store()->find_object(_path);
- if (_object == NULL) {
+ if (is_object)
+ _resource = _engine.engine_store()->find_object(Path(_uri.str()));
+ else
+ _resource = _engine.node_factory()->plugin(_uri);
+
+ if (!_resource) {
QueuedEvent::pre_process();
return;
}
@@ -62,10 +69,10 @@ RequestMetadataEvent::pre_process()
if (_key.str() == "ingen:value")
_special_type = PORT_VALUE;
- else if (_property)
- _value = _object->get_property(_key);
+ else if (!is_object || _is_property)
+ _value = _resource->get_property(_key);
else
- _value = _object->get_variable(_key);
+ _value = dynamic_cast<GraphObjectImpl*>(_resource)->get_variable(_key);
QueuedEvent::pre_process();
}
@@ -76,12 +83,12 @@ RequestMetadataEvent::execute(ProcessContext& context)
{
QueuedEvent::execute(context);
if (_special_type == PORT_VALUE) {
- PortImpl* port = dynamic_cast<PortImpl*>(_object);
+ PortImpl* port = dynamic_cast<PortImpl*>(_resource);
if (port) {
if (port->type() == DataType::CONTROL || port->type() == DataType::AUDIO)
_value = ((AudioBuffer*)port->buffer(0))->value_at(0); // TODO: offset
} else {
- _object = 0;
+ _resource = 0;
}
}
}
@@ -92,19 +99,19 @@ RequestMetadataEvent::post_process()
{
if (_responder->client()) {
if (_special_type == PORT_VALUE) {
- if (_object) {
+ if (_resource) {
_responder->respond_ok();
- _responder->client()->set_port_value(_path, _value);
+ _responder->client()->set_port_value(_uri.str(), _value);
} else {
- const string msg = "Get value for non-port " + _path.str();
+ const string msg = "Get value for non-port " + _uri.str();
_responder->respond_error(msg);
}
- } else if (!_object) {
- const string msg = "Unable to find variable subject " + _path.str();
+ } else if (!_resource) {
+ const string msg = "Unable to find subject " + _uri.str();
_responder->respond_error(msg);
} else {
_responder->respond_ok();
- _responder->client()->set_variable(_path, _key, _value);
+ _responder->client()->set_variable(_uri, _key, _value);
}
} else {
_responder->respond_error("Unknown client");
diff --git a/src/engine/events/RequestMetadataEvent.hpp b/src/engine/events/RequestMetadataEvent.hpp
index 5b163500..df1b1acd 100644
--- a/src/engine/events/RequestMetadataEvent.hpp
+++ b/src/engine/events/RequestMetadataEvent.hpp
@@ -23,7 +23,9 @@
#include "raul/URI.hpp"
namespace Ingen {
-
+
+namespace Shared { class ResourceImpl; }
+
class GraphObjectImpl;
@@ -38,7 +40,7 @@ public:
SharedPtr<Responder> responder,
SampleCount timestamp,
bool property,
- const Raul::Path& path,
+ const Raul::URI& path,
const Raul::URI& key);
void pre_process();
@@ -46,16 +48,17 @@ public:
void post_process();
private:
+ enum { NO_ERROR, NOT_FOUND } _error;
enum {
NONE,
PORT_VALUE
} _special_type;
- Raul::Path _path;
- bool _property;
- Raul::URI _key;
- Raul::Atom _value;
- GraphObjectImpl* _object;
+ Raul::URI _uri;
+ Raul::URI _key;
+ Raul::Atom _value;
+ Shared::ResourceImpl* _resource;
+ bool _is_property;
};
diff --git a/src/engine/events/SetMetadataEvent.cpp b/src/engine/events/SetMetadataEvent.cpp
index a41b866e..ea4e9129 100644
--- a/src/engine/events/SetMetadataEvent.cpp
+++ b/src/engine/events/SetMetadataEvent.cpp
@@ -24,6 +24,7 @@
#include "ClientBroadcaster.hpp"
#include "GraphObjectImpl.hpp"
#include "PatchImpl.hpp"
+#include "PluginImpl.hpp"
#include "EngineStore.hpp"
using namespace std;
@@ -37,14 +38,14 @@ SetMetadataEvent::SetMetadataEvent(
SharedPtr<Responder> responder,
SampleCount timestamp,
bool property,
- const Path& path,
+ const URI& subject,
const URI& key,
const Atom& value)
: QueuedEvent(engine, responder, timestamp)
, _error(NO_ERROR)
, _special_type(NONE)
, _property(property)
- , _path(path)
+ , _subject(subject)
, _key(key)
, _value(value)
, _object(NULL)
@@ -57,7 +58,11 @@ SetMetadataEvent::SetMetadataEvent(
void
SetMetadataEvent::pre_process()
{
- _object = _engine.engine_store()->find_object(_path);
+ if (_subject.scheme() == Path::scheme && Path::is_valid(_subject.str()))
+ _object = _engine.engine_store()->find_object(Path(_subject.str()));
+ else
+ _object = _engine.node_factory()->plugin(_subject);
+
if (_object == NULL) {
_error = NOT_FOUND;
QueuedEvent::pre_process();
@@ -67,10 +72,10 @@ SetMetadataEvent::pre_process()
/*cerr << "SET " << _object->path() << (_property ? " PROP " : " VAR ")
<< _key << " :: " << _value.type() << endl;*/
- if (_property)
+ if (_property || !dynamic_cast<GraphObjectImpl*>(_object))
_object->set_property(_key, _value);
else
- _object->set_variable(_key, _value);
+ dynamic_cast<GraphObjectImpl*>(_object)->set_variable(_key, _value);
_patch = dynamic_cast<PatchImpl*>(_object);
@@ -111,7 +116,8 @@ SetMetadataEvent::execute(ProcessContext& context)
if (_error != NO_ERROR)
return;
- PortImpl* port = 0;
+ PortImpl* port = 0;
+ GraphObjectImpl* object = 0;
switch (_special_type) {
case ENABLE_BROADCAST:
if ((port = dynamic_cast<PortImpl*>(_object)))
@@ -127,8 +133,9 @@ SetMetadataEvent::execute(ProcessContext& context)
}
break;
case POLYPHONIC:
- if (!_object->set_polyphonic(*_engine.maid(), _value.get_bool()))
- _error = INTERNAL;
+ if ((object = dynamic_cast<GraphObjectImpl*>(_object)))
+ if (!object->set_polyphonic(*_engine.maid(), _value.get_bool()))
+ _error = INTERNAL;
break;
case POLYPHONY:
if (!_patch->apply_internal_poly(*_engine.maid(), _value.get_int32()))
@@ -149,14 +156,13 @@ SetMetadataEvent::post_process()
case NO_ERROR:
_responder->respond_ok();
if (_property)
- _engine.broadcaster()->send_property_change(_path, _key, _value);
+ _engine.broadcaster()->send_property_change(_subject, _key, _value);
else
- _engine.broadcaster()->send_variable_change(_path, _key, _value);
+ _engine.broadcaster()->send_variable_change(_subject, _key, _value);
break;
case NOT_FOUND:
_responder->respond_error((boost::format(
- "Unable to find object '%1%' to set '%2%'")
- % _path % _key).str());
+ "Unable to find object '%1%' to set '%2%'") % _subject % _key).str());
case INTERNAL:
_responder->respond_error("Internal error");
break;
diff --git a/src/engine/events/SetMetadataEvent.hpp b/src/engine/events/SetMetadataEvent.hpp
index e4f64a11..70292682 100644
--- a/src/engine/events/SetMetadataEvent.hpp
+++ b/src/engine/events/SetMetadataEvent.hpp
@@ -20,6 +20,7 @@
#include "raul/URI.hpp"
#include "raul/Atom.hpp"
+#include "shared/ResourceImpl.hpp"
#include "QueuedEvent.hpp"
namespace Ingen {
@@ -40,7 +41,7 @@ public:
SharedPtr<Responder> responder,
SampleCount timestamp,
bool property,
- const Raul::Path& path,
+ const Raul::URI& subject,
const Raul::URI& key,
const Raul::Atom& value);
@@ -58,14 +59,14 @@ private:
POLYPHONIC
} _special_type;
- bool _property;
- bool _success;
- Raul::Path _path;
- Raul::URI _key;
- Raul::Atom _value;
- GraphObjectImpl* _object;
- PatchImpl* _patch;
- CompiledPatch* _compiled_patch;
+ bool _property;
+ bool _success;
+ Raul::URI _subject;
+ Raul::URI _key;
+ Raul::Atom _value;
+ Shared::ResourceImpl* _object;
+ PatchImpl* _patch;
+ CompiledPatch* _compiled_patch;
};