diff options
Diffstat (limited to 'src/client')
-rw-r--r-- | src/client/ClientStore.cpp | 22 | ||||
-rw-r--r-- | src/client/ClientStore.hpp | 5 | ||||
-rw-r--r-- | src/client/NodeModel.cpp | 4 | ||||
-rw-r--r-- | src/client/NodeModel.hpp | 5 | ||||
-rw-r--r-- | src/client/ObjectModel.cpp | 8 | ||||
-rw-r--r-- | src/client/ObjectModel.hpp | 13 | ||||
-rw-r--r-- | src/client/PatchModel.cpp | 10 | ||||
-rw-r--r-- | src/client/PatchModel.hpp | 13 | ||||
-rw-r--r-- | src/client/PluginModel.cpp | 4 | ||||
-rw-r--r-- | src/client/PluginModel.hpp | 7 | ||||
-rw-r--r-- | src/client/PortModel.cpp | 2 | ||||
-rw-r--r-- | src/client/PortModel.hpp | 19 | ||||
-rw-r--r-- | src/client/SigClientInterface.hpp | 47 | ||||
-rw-r--r-- | src/client/ThreadedSigClientInterface.hpp | 33 | ||||
-rw-r--r-- | src/client/signal.hpp | 30 |
15 files changed, 122 insertions, 100 deletions
diff --git a/src/client/ClientStore.cpp b/src/client/ClientStore.cpp index e647c130..52d05622 100644 --- a/src/client/ClientStore.cpp +++ b/src/client/ClientStore.cpp @@ -42,9 +42,9 @@ using namespace Shared; namespace Client { -ClientStore::ClientStore(SharedPtr<Shared::LV2URIMap> uris, - SharedPtr<ServerInterface> engine, - SharedPtr<SigClientInterface> emitter) +ClientStore::ClientStore(SharedPtr<Shared::LV2URIMap> uris, + SharedPtr<ServerInterface> engine, + SharedPtr<SigClientInterface> emitter) : _uris(uris) , _engine(engine) , _emitter(emitter) @@ -54,8 +54,8 @@ ClientStore::ClientStore(SharedPtr<Shared::LV2URIMap> uris, return; #define CONNECT(signal, method) \ - emitter->signal_ ## signal .connect( \ - sigc::mem_fun(this, &ClientStore:: method)); + emitter->signal_##signal().connect( \ + sigc::mem_fun(this, &ClientStore::method)); CONNECT(object_deleted, del); CONNECT(object_moved, move); @@ -93,11 +93,11 @@ ClientStore::add_object(SharedPtr<ObjectModel> object) assert(parent && (object->parent() == parent)); (*this)[object->path()] = object; - signal_new_object.emit(object); + _signal_new_object.emit(object); } } else { (*this)[object->path()] = object; - signal_new_object.emit(object); + _signal_new_object.emit(object); } } @@ -105,7 +105,7 @@ ClientStore::add_object(SharedPtr<ObjectModel> object) typedef Resource::Properties::const_iterator Iterator; for (Iterator i = object->properties().begin(); i != object->properties().end(); ++i) - object->signal_property(i->first, i->second); + object->signal_property().emit(i->first, i->second); LOG(debug) << "Added " << object->path() << " {" << endl; for (iterator i = begin(); i != end(); ++i) { @@ -132,7 +132,7 @@ ClientStore::remove_object(const Path& path) LOG(debug) << "}" << endl; if (result) - result->signal_destroyed.emit(); + result->signal_destroyed().emit(); if (!result->path().is_root()) { assert(result->parent()); @@ -195,7 +195,7 @@ ClientStore::add_plugin(SharedPtr<PluginModel> pm) existing->set(pm); } else { _plugins->insert(make_pair(pm->uri(), pm)); - signal_new_plugin(pm); + _signal_new_plugin.emit(pm); } } @@ -401,7 +401,7 @@ ClientStore::activity(const Path& path) { SharedPtr<PortModel> port = PtrCast<PortModel>(object(path)); if (port) - port->signal_activity.emit(); + port->signal_activity().emit(); else LOG(error) << "Activity for non-existent port " << path << endl; } diff --git a/src/client/ClientStore.hpp b/src/client/ClientStore.hpp index a5a3cbc1..59b112ed 100644 --- a/src/client/ClientStore.hpp +++ b/src/client/ClientStore.hpp @@ -31,6 +31,7 @@ #include "raul/PathTable.hpp" #include "raul/TableImpl.hpp" #include "shared/Store.hpp" +#include "client/signal.hpp" namespace Raul { class Atom; } @@ -102,8 +103,8 @@ public: void del(const Raul::URI& uri); - sigc::signal< void, SharedPtr<ObjectModel> > signal_new_object; - sigc::signal< void, SharedPtr<PluginModel> > signal_new_plugin; + INGEN_SIGNAL(new_object, void, SharedPtr<ObjectModel>); + INGEN_SIGNAL(new_plugin, void, SharedPtr<PluginModel>); private: void add(GraphObject* o) { throw; } diff --git a/src/client/NodeModel.cpp b/src/client/NodeModel.cpp index ce96e775..7847afb40 100644 --- a/src/client/NodeModel.cpp +++ b/src/client/NodeModel.cpp @@ -76,7 +76,7 @@ NodeModel::remove_port(SharedPtr<PortModel> port) break; } } - signal_removed_port.emit(port); + _signal_removed_port.emit(port); } void @@ -142,7 +142,7 @@ NodeModel::add_port(SharedPtr<PortModel> pm) assert(existing == _ports.end()); _ports.push_back(pm); - signal_new_port.emit(pm); + _signal_new_port.emit(pm); } SharedPtr<PortModel> diff --git a/src/client/NodeModel.hpp b/src/client/NodeModel.hpp index 2a47bc04..314ed1b4 100644 --- a/src/client/NodeModel.hpp +++ b/src/client/NodeModel.hpp @@ -21,7 +21,6 @@ #include <cstdlib> #include <string> #include <vector> -#include <sigc++/sigc++.h> #include "raul/SharedPtr.hpp" #include "ingen/Node.hpp" #include "ingen/Port.hpp" @@ -70,8 +69,8 @@ public: std::string port_label(SharedPtr<PortModel> port) const; // Signals - sigc::signal<void, SharedPtr<PortModel> > signal_new_port; - sigc::signal<void, SharedPtr<PortModel> > signal_removed_port; + INGEN_SIGNAL(new_port, void, SharedPtr<PortModel>); + INGEN_SIGNAL(removed_port, void, SharedPtr<PortModel>); protected: friend class ClientStore; diff --git a/src/client/ObjectModel.cpp b/src/client/ObjectModel.cpp index e85742a9..2478e786 100644 --- a/src/client/ObjectModel.cpp +++ b/src/client/ObjectModel.cpp @@ -50,7 +50,7 @@ ObjectModel::~ObjectModel() Raul::Atom& ObjectModel::set_property(const Raul::URI& key, const Raul::Atom& value) { - signal_property.emit(key, value); + _signal_property.emit(key, value); return ResourceImpl::set_property(key, value); } @@ -58,7 +58,7 @@ void ObjectModel::add_property(const Raul::URI& key, const Raul::Atom& value) { ResourceImpl::add_property(key, value); - signal_property.emit(key, value); + _signal_property.emit(key, value); } const Atom& @@ -91,7 +91,7 @@ ObjectModel::set(SharedPtr<ObjectModel> o) for (Properties::const_iterator v = o->properties().begin(); v != o->properties().end(); ++v) { ResourceImpl::set_property(v->first, v->second); - signal_property.emit(v->first, v->second); + _signal_property.emit(v->first, v->second); } } @@ -100,7 +100,7 @@ ObjectModel::set_path(const Raul::Path& p) { _path = p; _symbol = p.symbol(); - signal_moved.emit(); + _signal_moved.emit(); } void diff --git a/src/client/ObjectModel.hpp b/src/client/ObjectModel.hpp index 21cf4b2b..bcba2242 100644 --- a/src/client/ObjectModel.hpp +++ b/src/client/ObjectModel.hpp @@ -1,4 +1,3 @@ - /* This file is part of Ingen. * Copyright 2007-2011 David Robillard <http://drobilla.net> * @@ -23,12 +22,12 @@ #include <algorithm> #include <cassert> #include <boost/utility.hpp> -#include <sigc++/sigc++.h> #include "raul/Path.hpp" #include "raul/URI.hpp" #include "raul/SharedPtr.hpp" #include "ingen/GraphObject.hpp" #include "shared/ResourceImpl.hpp" +#include "client/signal.hpp" namespace Ingen { @@ -68,11 +67,11 @@ public: GraphObject* graph_parent() const { return _parent.get(); } // Signals - sigc::signal<void, SharedPtr<ObjectModel> > signal_new_child; - sigc::signal<void, SharedPtr<ObjectModel> > signal_removed_child; - sigc::signal<void, const Raul::URI&, const Raul::Atom&> signal_property; - sigc::signal<void> signal_destroyed; - sigc::signal<void> signal_moved; + INGEN_SIGNAL(new_child, void, SharedPtr<ObjectModel>); + INGEN_SIGNAL(removed_child, void, SharedPtr<ObjectModel>); + INGEN_SIGNAL(property, void, const Raul::URI&, const Raul::Atom&); + INGEN_SIGNAL(destroyed, void); + INGEN_SIGNAL(moved, void); protected: friend class ClientStore; diff --git a/src/client/PatchModel.cpp b/src/client/PatchModel.cpp index 190bc3ba..5dcf4ab0 100644 --- a/src/client/PatchModel.cpp +++ b/src/client/PatchModel.cpp @@ -42,7 +42,7 @@ PatchModel::add_child(SharedPtr<ObjectModel> c) SharedPtr<NodeModel> nm = PtrCast<NodeModel>(c); if (nm) - signal_new_node.emit(nm); + _signal_new_node.emit(nm); } bool @@ -64,7 +64,7 @@ PatchModel::remove_child(SharedPtr<ObjectModel> o) || cm->src_port_path() == o->path() || cm->dst_port_path().parent() == o->path() || cm->dst_port_path() == o->path()) { - signal_removed_connection.emit(cm); + _signal_removed_connection.emit(cm); _connections->erase(j); // cuts our reference } j = next; @@ -76,7 +76,7 @@ PatchModel::remove_child(SharedPtr<ObjectModel> o) SharedPtr<NodeModel> nm = PtrCast<NodeModel>(o); if (nm) - signal_removed_node.emit(nm); + _signal_removed_node.emit(nm); return true; } @@ -132,7 +132,7 @@ PatchModel::add_connection(SharedPtr<ConnectionModel> cm) assert(cm->dst_port() == existing->dst_port()); } else { _connections->insert(make_pair(make_pair(cm->src_port().get(), cm->dst_port().get()), cm)); - signal_new_connection.emit(cm); + _signal_new_connection.emit(cm); } } @@ -142,7 +142,7 @@ PatchModel::remove_connection(const Port* src_port, const Ingen::Port* dst_port) Connections::iterator i = _connections->find(make_pair(src_port, dst_port)); if (i != _connections->end()) { SharedPtr<ConnectionModel> c = PtrCast<ConnectionModel>(i->second); - signal_removed_connection.emit(c); + _signal_removed_connection.emit(c); _connections->erase(i); } else { warn << "[PatchModel::remove_connection] Failed to find connection " << diff --git a/src/client/PatchModel.hpp b/src/client/PatchModel.hpp index 775cfe29..73930189 100644 --- a/src/client/PatchModel.hpp +++ b/src/client/PatchModel.hpp @@ -19,7 +19,6 @@ #define INGEN_CLIENT_PATCHMODEL_HPP #include <cassert> -#include <sigc++/sigc++.h> #include "raul/SharedPtr.hpp" #include "ingen/Patch.hpp" #include "NodeModel.hpp" @@ -61,16 +60,16 @@ public: void set_editable(bool e) { if (_editable != e) { _editable = e; - signal_editable.emit(e); + _signal_editable.emit(e); } } // Signals - sigc::signal<void, SharedPtr<NodeModel> > signal_new_node; - sigc::signal<void, SharedPtr<NodeModel> > signal_removed_node; - sigc::signal<void, SharedPtr<ConnectionModel> > signal_new_connection; - sigc::signal<void, SharedPtr<ConnectionModel> > signal_removed_connection; - sigc::signal<void, bool> signal_editable; + INGEN_SIGNAL(new_node, void, SharedPtr<NodeModel>); + INGEN_SIGNAL(removed_node, void, SharedPtr<NodeModel>); + INGEN_SIGNAL(new_connection, void, SharedPtr<ConnectionModel>); + INGEN_SIGNAL(removed_connection, void, SharedPtr<ConnectionModel>); + INGEN_SIGNAL(editable, void, bool); private: friend class ClientStore; diff --git a/src/client/PluginModel.cpp b/src/client/PluginModel.cpp index 315214ed..8a644edc 100644 --- a/src/client/PluginModel.cpp +++ b/src/client/PluginModel.cpp @@ -142,10 +142,10 @@ PluginModel::set(SharedPtr<PluginModel> p) for (Properties::const_iterator v = p->properties().begin(); v != p->properties().end(); ++v) { ResourceImpl::set_property(v->first, v->second); - signal_property.emit(v->first, v->second); + _signal_property.emit(v->first, v->second); } - signal_changed.emit(); + _signal_changed.emit(); } Symbol diff --git a/src/client/PluginModel.hpp b/src/client/PluginModel.hpp index faba8c8b..e301c615 100644 --- a/src/client/PluginModel.hpp +++ b/src/client/PluginModel.hpp @@ -18,8 +18,6 @@ #ifndef INGEN_CLIENT_PLUGINMODEL_HPP #define INGEN_CLIENT_PLUGINMODEL_HPP -#include <sigc++/sigc++.h> - #include "raul/SharedPtr.hpp" #include "raul/Symbol.hpp" @@ -34,6 +32,7 @@ #include "ingen/Plugin.hpp" #include "shared/World.hpp" #include "shared/ResourceImpl.hpp" +#include "client/signal.hpp" namespace Ingen { @@ -99,8 +98,8 @@ public: static Sord::World* rdf_world() { return _rdf_world; } // Signals - sigc::signal<void> signal_changed; - sigc::signal<void, const Raul::URI&, const Raul::Atom&> signal_property; + INGEN_SIGNAL(changed, void); + INGEN_SIGNAL(property, void, const Raul::URI&, const Raul::Atom&); protected: friend class ClientStore; diff --git a/src/client/PortModel.cpp b/src/client/PortModel.cpp index 94b83ee3..9ca7fe19 100644 --- a/src/client/PortModel.cpp +++ b/src/client/PortModel.cpp @@ -54,7 +54,7 @@ PortModel::set(SharedPtr<ObjectModel> model) _direction = port->_direction; _current_val = port->_current_val; _connections = port->_connections; - signal_value_changed.emit(_current_val); + _signal_value_changed.emit(_current_val); } ObjectModel::set(model); diff --git a/src/client/PortModel.hpp b/src/client/PortModel.hpp index 264f532e..133a2794 100644 --- a/src/client/PortModel.hpp +++ b/src/client/PortModel.hpp @@ -20,7 +20,6 @@ #include <cstdlib> #include <string> -#include <sigc++/sigc++.h> #include "raul/log.hpp" #include "raul/SharedPtr.hpp" #include "ingen/Port.hpp" @@ -66,21 +65,21 @@ public: inline void value(const Raul::Atom& val) { if (val != _current_val) { _current_val = val; - signal_value_changed.emit(val); + _signal_value_changed.emit(val); } } inline void value(uint32_t voice, const Raul::Atom& val) { // FIXME: implement properly - signal_voice_changed.emit(voice, val); + _signal_voice_changed.emit(voice, val); } // Signals - sigc::signal<void, const Raul::Atom&> signal_value_changed; ///< Value ports - sigc::signal<void, uint32_t, const Raul::Atom&> signal_voice_changed; ///< Polyphonic value ports - sigc::signal<void> signal_activity; ///< Message ports - sigc::signal<void, SharedPtr<PortModel> > signal_connection; - sigc::signal<void, SharedPtr<PortModel> > signal_disconnection; + INGEN_SIGNAL(value_changed, void, const Raul::Atom&); + INGEN_SIGNAL(voice_changed, void, uint32_t, const Raul::Atom&); + INGEN_SIGNAL(activity, void); + INGEN_SIGNAL(connection, void, SharedPtr<PortModel>); + INGEN_SIGNAL(disconnection, void, SharedPtr<PortModel>); private: friend class ClientStore; @@ -101,8 +100,8 @@ private: void add_child(SharedPtr<ObjectModel> c) { throw; } bool remove_child(SharedPtr<ObjectModel> c) { throw; } - void connected_to(SharedPtr<PortModel> p) { ++_connections; signal_connection.emit(p); } - void disconnected_from(SharedPtr<PortModel> p) { --_connections; signal_disconnection.emit(p); } + void connected_to(SharedPtr<PortModel> p) { ++_connections; _signal_connection.emit(p); } + void disconnected_from(SharedPtr<PortModel> p) { --_connections; _signal_disconnection.emit(p); } void set(SharedPtr<ObjectModel> model); diff --git a/src/client/SigClientInterface.hpp b/src/client/SigClientInterface.hpp index fc5201e1..7409688a 100644 --- a/src/client/SigClientInterface.hpp +++ b/src/client/SigClientInterface.hpp @@ -19,18 +19,17 @@ #define INGEN_CLIENT_SIGCLIENTINTERFACE_HPP #include <inttypes.h> -#include <sigc++/sigc++.h> #include "raul/Path.hpp" #include "ingen/ClientInterface.hpp" +#include "client/signal.hpp" namespace Ingen { namespace Client { /** A LibSigC++ signal emitting interface for clients to use. * - * This simply emits an sigc signal for every event (eg OSC message) coming from - * the engine. Use Store (which extends this) if you want a nice client-side - * model of the engine. + * This simply emits a signal for every event that comes from the engine. + * For a higher level model based view of the engine, use ClientStore. * * The signals here match the calls to ClientInterface exactly. See the * documentation for ClientInterface for meanings of signal parameters. @@ -43,26 +42,24 @@ public: Raul::URI uri() const { return "http://drobilla.net/ns/ingen#internal"; } - sigc::signal<void, int32_t> signal_response_ok; - sigc::signal<void, int32_t, std::string> signal_response_error; - sigc::signal<void> signal_bundle_begin; - sigc::signal<void> signal_bundle_end; - sigc::signal<void, std::string> signal_error; - sigc::signal<void, Raul::Path, uint32_t> signal_new_patch; - sigc::signal<void, Raul::Path, Raul::URI, uint32_t, bool> signal_new_port; - sigc::signal<void, Raul::URI, Resource::Properties, - Resource::Graph> signal_put; - sigc::signal<void, Raul::URI, Resource::Properties, - Resource::Properties> signal_delta; - sigc::signal<void, Raul::Path, Raul::Path> signal_object_moved; - sigc::signal<void, Raul::URI> signal_object_deleted; - sigc::signal<void, Raul::Path, Raul::Path> signal_connection; - sigc::signal<void, Raul::URI, Raul::URI> signal_disconnection; - sigc::signal<void, Raul::Path, Raul::Path> signal_disconnect_all; - sigc::signal<void, Raul::URI, Raul::URI, Raul::Atom> signal_variable_change; - sigc::signal<void, Raul::URI, Raul::URI, Raul::Atom> signal_property_change; - sigc::signal<void, Raul::Path, Raul::Atom> signal_port_value; - sigc::signal<void, Raul::Path> signal_activity; + INGEN_SIGNAL(response_ok, void, int32_t) + INGEN_SIGNAL(response_error, void, int32_t, std::string) + INGEN_SIGNAL(bundle_begin, void) + INGEN_SIGNAL(bundle_end, void) + INGEN_SIGNAL(error, void, std::string) + INGEN_SIGNAL(new_patch, void, Raul::Path, uint32_t) + INGEN_SIGNAL(new_port, void, Raul::Path, Raul::URI, uint32_t, bool) + INGEN_SIGNAL(put, void, Raul::URI, Resource::Properties, Resource::Graph) + INGEN_SIGNAL(delta, void, Raul::URI, Resource::Properties, Resource::Properties) + INGEN_SIGNAL(object_moved, void, Raul::Path, Raul::Path) + INGEN_SIGNAL(object_deleted, void, Raul::URI) + INGEN_SIGNAL(connection, void, Raul::Path, Raul::Path) + INGEN_SIGNAL(disconnection, void, Raul::URI, Raul::URI) + INGEN_SIGNAL(disconnect_all, void, Raul::Path, Raul::Path) + INGEN_SIGNAL(variable_change, void, Raul::URI, Raul::URI, Raul::Atom) + INGEN_SIGNAL(property_change, void, Raul::URI, Raul::URI, Raul::Atom) + INGEN_SIGNAL(port_value, void, Raul::Path, Raul::Atom) + INGEN_SIGNAL(activity, void, Raul::Path) /** Fire pending signals. Only does anything on derived classes (that may queue) */ virtual bool emit_signals() { return false; } @@ -71,7 +68,7 @@ protected: // ClientInterface hooks that fire the above signals -#define EMIT(name, ...) { signal_ ## name (__VA_ARGS__); } +#define EMIT(name, ...) { _signal_ ## name (__VA_ARGS__); } void bundle_begin() { EMIT(bundle_begin); } diff --git a/src/client/ThreadedSigClientInterface.hpp b/src/client/ThreadedSigClientInterface.hpp index 4fe85209..373fb14d 100644 --- a/src/client/ThreadedSigClientInterface.hpp +++ b/src/client/ThreadedSigClientInterface.hpp @@ -47,23 +47,22 @@ class ThreadedSigClientInterface : public SigClientInterface { public: ThreadedSigClientInterface(uint32_t queue_size) - : _sigs(queue_size) - , response_ok_slot(signal_response_ok.make_slot()) - , response_error_slot(signal_response_error.make_slot()) - , error_slot(signal_error.make_slot()) - , new_port_slot(signal_new_port.make_slot()) - , put_slot(signal_put.make_slot()) - , connection_slot(signal_connection.make_slot()) - , object_deleted_slot(signal_object_deleted.make_slot()) - , object_moved_slot(signal_object_moved.make_slot()) - , disconnection_slot(signal_disconnection.make_slot()) - , disconnect_all_slot(signal_disconnect_all.make_slot()) - , variable_change_slot(signal_variable_change.make_slot()) - , property_change_slot(signal_property_change.make_slot()) - , port_value_slot(signal_port_value.make_slot()) - , activity_slot(signal_activity.make_slot()) - { - } + : _sigs(queue_size) + , response_ok_slot(_signal_response_ok.make_slot()) + , response_error_slot(_signal_response_error.make_slot()) + , error_slot(_signal_error.make_slot()) + , new_port_slot(_signal_new_port.make_slot()) + , put_slot(_signal_put.make_slot()) + , connection_slot(_signal_connection.make_slot()) + , object_deleted_slot(_signal_object_deleted.make_slot()) + , object_moved_slot(_signal_object_moved.make_slot()) + , disconnection_slot(_signal_disconnection.make_slot()) + , disconnect_all_slot(_signal_disconnect_all.make_slot()) + , variable_change_slot(_signal_variable_change.make_slot()) + , property_change_slot(_signal_property_change.make_slot()) + , port_value_slot(_signal_port_value.make_slot()) + , activity_slot(_signal_activity.make_slot()) + {} virtual Raul::URI uri() const { return "http://drobilla.net/ns/ingen#internal"; } diff --git a/src/client/signal.hpp b/src/client/signal.hpp new file mode 100644 index 00000000..46718163 --- /dev/null +++ b/src/client/signal.hpp @@ -0,0 +1,30 @@ +/* This file is part of Ingen. + * Copyright 2007-2011 David Robillard <http://drobilla.net> + * + * Ingen is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) 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 General Public License for details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef INGEN_CLIENT_SIGNAL_HPP +#define INGEN_CLIENT_SIGNAL_HPP + +#include <sigc++/sigc++.h> + +#define INGEN_SIGNAL(name, ...) \ +protected: \ +sigc::signal<__VA_ARGS__> _signal_##name; \ +public: \ +sigc::signal<__VA_ARGS__> signal_##name() const { return _signal_##name; } \ +sigc::signal<__VA_ARGS__>& signal_##name() { return _signal_##name; } + +#endif // INGEN_CLIENT_SIGNAL_HPP |