diff options
author | David Robillard <d@drobilla.net> | 2009-05-12 21:58:35 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2009-05-12 21:58:35 +0000 |
commit | ed1032ca54a55c48d2f7c9709b77a4f4da935e99 (patch) | |
tree | ebc821e22bcdd9424383174fe9ec2a6a32dbb362 /src/engine | |
parent | c32745b044d88e74526599c5994255a2ea6d2c21 (diff) | |
download | ingen-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')
-rw-r--r-- | src/engine/ClientBroadcaster.cpp | 6 | ||||
-rw-r--r-- | src/engine/ClientBroadcaster.hpp | 2 | ||||
-rw-r--r-- | src/engine/HTTPClientSender.cpp | 4 | ||||
-rw-r--r-- | src/engine/HTTPClientSender.hpp | 6 | ||||
-rw-r--r-- | src/engine/OSCClientSender.cpp | 12 | ||||
-rw-r--r-- | src/engine/OSCClientSender.hpp | 6 | ||||
-rw-r--r-- | src/engine/OSCEngineReceiver.cpp | 14 | ||||
-rw-r--r-- | src/engine/QueuedEngineInterface.cpp | 8 | ||||
-rw-r--r-- | src/engine/QueuedEngineInterface.hpp | 2 | ||||
-rw-r--r-- | src/engine/events/ClearPatchEvent.cpp | 2 | ||||
-rw-r--r-- | src/engine/events/RenameEvent.cpp | 38 | ||||
-rw-r--r-- | src/engine/events/RenameEvent.hpp | 13 |
12 files changed, 53 insertions, 60 deletions
diff --git a/src/engine/ClientBroadcaster.cpp b/src/engine/ClientBroadcaster.cpp index ee76eb53..c9f881aa 100644 --- a/src/engine/ClientBroadcaster.cpp +++ b/src/engine/ClientBroadcaster.cpp @@ -140,10 +140,10 @@ ClientBroadcaster::send_destroyed(const string& path) void -ClientBroadcaster::send_patch_cleared(const string& patch_path) +ClientBroadcaster::send_clear_patch(const string& patch_path) { for (Clients::const_iterator i = _clients.begin(); i != _clients.end(); ++i) - (*i).second->patch_cleared(patch_path); + (*i).second->clear_patch(patch_path); } void @@ -242,7 +242,7 @@ void ClientBroadcaster::send_rename(const string& old_path, const string& new_path) { for (Clients::const_iterator i = _clients.begin(); i != _clients.end(); ++i) - (*i).second->object_renamed(old_path, new_path); + (*i).second->rename(old_path, new_path); } diff --git a/src/engine/ClientBroadcaster.hpp b/src/engine/ClientBroadcaster.hpp index a4ef004c..80405d24 100644 --- a/src/engine/ClientBroadcaster.hpp +++ b/src/engine/ClientBroadcaster.hpp @@ -68,7 +68,7 @@ public: void send_plugins(const NodeFactory::Plugins& plugin_list); void send_object(const GraphObjectImpl* p, bool recursive); void send_destroyed(const string& path); - void send_patch_cleared(const string& patch_path); + void send_clear_patch(const string& patch_path); void send_connection(const SharedPtr<const ConnectionImpl> connection); void send_disconnection(const string& src_port_path, const string& dst_port_path); void send_rename(const string& old_path, const string& new_path); diff --git a/src/engine/HTTPClientSender.cpp b/src/engine/HTTPClientSender.cpp index f9329ebd..4b7a2045 100644 --- a/src/engine/HTTPClientSender.cpp +++ b/src/engine/HTTPClientSender.cpp @@ -75,7 +75,7 @@ HTTPClientSender::destroy(const std::string& path) void -HTTPClientSender::patch_cleared(const std::string& patch_path) +HTTPClientSender::clear_patch(const std::string& patch_path) { send_chunk(string("<").append(patch_path).append("> ingen:empty true .")); } @@ -202,7 +202,7 @@ HTTPClientSender::new_patch(const std::string& path, uint32_t poly) void -HTTPClientSender::object_renamed(const std::string& old_path, const std::string& new_path) +HTTPClientSender::rename(const std::string& old_path, const std::string& new_path) { string msg = string( "@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .\n" diff --git a/src/engine/HTTPClientSender.hpp b/src/engine/HTTPClientSender.hpp index 9a1ce10c..364549ee 100644 --- a/src/engine/HTTPClientSender.hpp +++ b/src/engine/HTTPClientSender.hpp @@ -88,12 +88,12 @@ public: uint32_t index, bool is_output); - virtual void patch_cleared(const std::string& path); + virtual void clear_patch(const std::string& path); virtual void destroy(const std::string& path); - virtual void object_renamed(const std::string& old_path, - const std::string& new_path); + virtual void rename(const std::string& old_path, + const std::string& new_path); virtual void connect(const std::string& src_port_path, const std::string& dst_port_path); diff --git a/src/engine/OSCClientSender.cpp b/src/engine/OSCClientSender.cpp index 2e058ed5..1357258e 100644 --- a/src/engine/OSCClientSender.cpp +++ b/src/engine/OSCClientSender.cpp @@ -175,13 +175,13 @@ OSCClientSender::destroy(const std::string& path) /** \page client_osc_namespace - * <p> \b /ingen/patch_cleared - Notification a patch has been cleared (all children destroyed) + * <p> \b /ingen/clear_patch - Notification a patch has been cleared (all children destroyed) * \arg \b path (string) - Path of patch (which is now empty)</p> \n \n */ void -OSCClientSender::patch_cleared(const std::string& patch_path) +OSCClientSender::clear_patch(const std::string& patch_path) { - send("/ingen/patch_cleared", "s", patch_path.c_str(), LO_ARGS_END); + send("/ingen/clear_patch", "s", patch_path.c_str(), LO_ARGS_END); } @@ -350,14 +350,14 @@ OSCClientSender::new_patch(const std::string& path, uint32_t poly) /** \page client_osc_namespace - * <p> \b /ingen/object_renamed - Notification of an object's renaming + * <p> \b /ingen/rename - Notification of an object's renaming * \arg \b old-path (string) - Old path of object * \arg \b new-path (string) - New path of object </p> \n \n */ void -OSCClientSender::object_renamed(const std::string& old_path, const std::string& new_path) +OSCClientSender::rename(const std::string& old_path, const std::string& new_path) { - send("/ingen/object_renamed", "ss", old_path.c_str(), new_path.c_str(), LO_ARGS_END); + send("/ingen/rename", "ss", old_path.c_str(), new_path.c_str(), LO_ARGS_END); } diff --git a/src/engine/OSCClientSender.hpp b/src/engine/OSCClientSender.hpp index 6b8cc1bf..6d93b381 100644 --- a/src/engine/OSCClientSender.hpp +++ b/src/engine/OSCClientSender.hpp @@ -87,12 +87,12 @@ public: uint32_t index, bool is_output); - virtual void patch_cleared(const std::string& path); + virtual void clear_patch(const std::string& path); virtual void destroy(const std::string& path); - virtual void object_renamed(const std::string& old_path, - const std::string& new_path); + virtual void rename(const std::string& old_path, + const std::string& new_path); virtual void connect(const std::string& src_port_path, const std::string& dst_port_path); diff --git a/src/engine/OSCEngineReceiver.cpp b/src/engine/OSCEngineReceiver.cpp index 26b8aeeb..e2377d95 100644 --- a/src/engine/OSCEngineReceiver.cpp +++ b/src/engine/OSCEngineReceiver.cpp @@ -390,16 +390,16 @@ OSCEngineReceiver::_new_patch_cb(const char* path, const char* types, lo_arg** a /** \page engine_osc_namespace * <p> \b /ingen/rename - Rename an Object (only Nodes, for now) * \arg \b response-id (integer) - * \arg \b path - Object's path - * \arg \b name - New name for object </p> \n \n + * \arg \b old-path - Object's path + * \arg \b new-path - Object's new path </p> \n \n */ int OSCEngineReceiver::_rename_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg) { - const char* object_path = &argv[1]->s; - const char* name = &argv[2]->s; + const char* old_path = &argv[1]->s; + const char* new_path = &argv[2]->s; - rename(object_path, name); + rename(old_path, new_path); return 0; } @@ -412,7 +412,7 @@ OSCEngineReceiver::_rename_cb(const char* path, const char* types, lo_arg** argv int OSCEngineReceiver::_clear_patch_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg) { - const char* patch_path = &argv[1]->s; + const char* patch_path = &argv[1]->s; clear_patch(patch_path); return 0; @@ -533,7 +533,7 @@ OSCEngineReceiver::_disconnect_cb(const char* path, const char* types, lo_arg** * <p> \b /ingen/disconnect_all - Disconnect all connections to/from a node/port. * \arg \b response-id (integer) * \arg \b patch-path (string) - The (parent) patch in which to disconnect object. </p> \n \n - * \arg \b node-path (string) - Full path of object. </p> \n \n + * \arg \b object-path (string) - Full path of object. </p> \n \n */ int OSCEngineReceiver::_disconnect_all_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg) diff --git a/src/engine/QueuedEngineInterface.cpp b/src/engine/QueuedEngineInterface.cpp index 9a2cea1b..00d142c9 100644 --- a/src/engine/QueuedEngineInterface.cpp +++ b/src/engine/QueuedEngineInterface.cpp @@ -191,9 +191,9 @@ QueuedEngineInterface::new_node_deprecated(const string& path, void QueuedEngineInterface::rename(const string& old_path, - const string& new_symbol) + const string& new_path) { - push_queued(new RenameEvent(_engine, _responder, now(), old_path, new_symbol)); + push_queued(new RenameEvent(_engine, _responder, now(), old_path, new_path)); } @@ -230,9 +230,9 @@ QueuedEngineInterface::disconnect(const string& src_port_path, void QueuedEngineInterface::disconnect_all(const string& patch_path, - const string& node_path) + const string& path) { - push_queued(new DisconnectAllEvent(_engine, _responder, now(), patch_path, node_path)); + push_queued(new DisconnectAllEvent(_engine, _responder, now(), patch_path, path)); } diff --git a/src/engine/QueuedEngineInterface.hpp b/src/engine/QueuedEngineInterface.hpp index ec5bf602..ed50f7c8 100644 --- a/src/engine/QueuedEngineInterface.hpp +++ b/src/engine/QueuedEngineInterface.hpp @@ -106,7 +106,7 @@ public: const string& dst_port_path); virtual void disconnect_all(const string& patch_path, - const string& node_path); + const string& path); virtual void set_port_value(const string& port_path, const Raul::Atom& value); 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; |