summaryrefslogtreecommitdiffstats
path: root/src/engine/events
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2009-05-12 21:58:35 +0000
committerDavid Robillard <d@drobilla.net>2009-05-12 21:58:35 +0000
commited1032ca54a55c48d2f7c9709b77a4f4da935e99 (patch)
treeebc821e22bcdd9424383174fe9ec2a6a32dbb362 /src/engine/events
parentc32745b044d88e74526599c5994255a2ea6d2c21 (diff)
downloadingen-ed1032ca54a55c48d2f7c9709b77a4f4da935e99.tar.gz
ingen-ed1032ca54a55c48d2f7c9709b77a4f4da935e99.tar.bz2
ingen-ed1032ca54a55c48d2f7c9709b77a4f4da935e99.zip
Bring EngineInterface and ClientInterface closer together.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@1990 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/engine/events')
-rw-r--r--src/engine/events/ClearPatchEvent.cpp2
-rw-r--r--src/engine/events/RenameEvent.cpp38
-rw-r--r--src/engine/events/RenameEvent.hpp13
3 files changed, 23 insertions, 30 deletions
diff --git a/src/engine/events/ClearPatchEvent.cpp b/src/engine/events/ClearPatchEvent.cpp
index 9122281b..2be2e4a8 100644
--- a/src/engine/events/ClearPatchEvent.cpp
+++ b/src/engine/events/ClearPatchEvent.cpp
@@ -136,7 +136,7 @@ ClearPatchEvent::post_process()
// Reply
_responder->respond_ok();
- _engine.broadcaster()->send_patch_cleared(_patch_path);
+ _engine.broadcaster()->send_clear_patch(_patch_path);
// Unregister and destroy driver ports
if (_driver_ports) {
diff --git a/src/engine/events/RenameEvent.cpp b/src/engine/events/RenameEvent.cpp
index 4112527b..8ce1bf9c 100644
--- a/src/engine/events/RenameEvent.cpp
+++ b/src/engine/events/RenameEvent.cpp
@@ -31,20 +31,14 @@ using namespace std;
namespace Ingen {
-RenameEvent::RenameEvent(Engine& engine, SharedPtr<Responder> responder, SampleCount timestamp, const string& path, const string& name)
-: QueuedEvent(engine, responder, timestamp),
- _old_path(path),
- _name(name),
- _new_path("/"),
- _parent_patch(NULL),
- _store_iterator(engine.engine_store()->end()),
- _error(NO_ERROR)
+RenameEvent::RenameEvent(Engine& engine, SharedPtr<Responder> responder, SampleCount timestamp, const string& path, const string& new_path)
+ : QueuedEvent(engine, responder, timestamp)
+ , _old_path(path)
+ , _new_path(new_path)
+ , _parent_patch(NULL)
+ , _store_iterator(engine.engine_store()->end())
+ , _error(NO_ERROR)
{
- /*
- if (_old_path.parent() == "/")
- _new_path = string("/") + _name;
- else
- _new_path = _old_path.parent() +"/"+ _name;*/
}
@@ -56,14 +50,12 @@ RenameEvent::~RenameEvent()
void
RenameEvent::pre_process()
{
- if ((!Raul::Path::is_valid_name(_name)) || _name.find("/") != string::npos) {
- _error = INVALID_NAME;
+ if ((!Raul::Path::is_valid(_new_path) || !_old_path.parent().is_parent_of(_new_path))) {
+ _error = BAD_PATH;
QueuedEvent::pre_process();
return;
}
- _new_path = _old_path.parent().base() + _name;
-
_store_iterator = _engine.engine_store()->find(_old_path);
if (_store_iterator == _engine.engine_store()->end()) {
_error = OBJECT_NOT_FOUND;
@@ -90,7 +82,7 @@ RenameEvent::pre_process()
if (child_old_path == _old_path)
child_new_path = _new_path;
else
- child_new_path = _new_path.base() + child_old_path.substr(_old_path.length()+1);
+ child_new_path = Path(_new_path).base() + child_old_path.substr(_old_path.length()+1);
PtrCast<GraphObjectImpl>(i->second)->set_path(child_new_path);
i->first = child_new_path;
@@ -116,12 +108,8 @@ RenameEvent::execute(ProcessContext& context)
else if (port->type() == DataType::EVENT)
driver_port = _engine.midi_driver()->driver_port(_new_path);
- if (driver_port) {
- cerr << "DRIVER PORT :)!" << endl;
+ if (driver_port)
driver_port->set_name(_new_path);
- } else {
- cerr << "NO DRIVER PORT :(" << endl;
- }
}
}
@@ -141,8 +129,8 @@ RenameEvent::post_process()
msg.append("Could not find object ").append(_old_path);
else if (_error == OBJECT_NOT_RENAMABLE)
msg.append(_old_path).append(" is not renamable");
- else if (_error == INVALID_NAME)
- msg.append(_name).append(" is not a valid name");
+ else if (_error == BAD_PATH)
+ msg.append(_new_path).append(" is not a valid target path");
_responder->respond_error(msg);
}
diff --git a/src/engine/events/RenameEvent.hpp b/src/engine/events/RenameEvent.hpp
index db6d01b9..2cbf6902 100644
--- a/src/engine/events/RenameEvent.hpp
+++ b/src/engine/events/RenameEvent.hpp
@@ -40,7 +40,7 @@ class PatchImpl;
class RenameEvent : public QueuedEvent
{
public:
- RenameEvent(Engine& engine, SharedPtr<Responder> responder, SampleCount timestamp, const string& path, const string& name);
+ RenameEvent(Engine& engine, SharedPtr<Responder> responder, SampleCount timestamp, const string& old_path, const string& new_path);
~RenameEvent();
void pre_process();
@@ -48,11 +48,16 @@ public:
void post_process();
private:
- enum ErrorType { NO_ERROR, OBJECT_NOT_FOUND, OBJECT_EXISTS, OBJECT_NOT_RENAMABLE, INVALID_NAME };
+ enum ErrorType {
+ NO_ERROR,
+ OBJECT_NOT_FOUND,
+ OBJECT_EXISTS,
+ OBJECT_NOT_RENAMABLE,
+ BAD_PATH
+ };
Path _old_path;
- string _name;
- Path _new_path;
+ string _new_path;
PatchImpl* _parent_patch;
EngineStore::iterator _store_iterator;
ErrorType _error;