From df1447c665e6c3631961297a9d3e9aff4e94c47f Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 12 Jan 2013 23:38:03 +0000 Subject: Remove Raul::SharedPtr and switch to std::shared_ptr. Use project local short type aliases for shared_ptr and friends. Move Raul::Disposable and Raul::Manageable into Raul::Maid. Use sets to store machina nodes and edges to avoid O(n) searches. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4939 a436a847-0d15-0410-975c-d299462d15a1 --- ingen/client/ArcModel.hpp | 12 ++++----- ingen/client/BlockModel.hpp | 58 +++++++++++++++++++++++--------------------- ingen/client/ClientStore.hpp | 56 +++++++++++++++++++++--------------------- ingen/client/GraphModel.hpp | 20 +++++++-------- ingen/client/ObjectModel.hpp | 24 +++++++++--------- ingen/client/PluginModel.hpp | 8 +++--- ingen/client/PluginUI.hpp | 28 ++++++++++----------- ingen/client/PortModel.hpp | 16 ++++++------ 8 files changed, 113 insertions(+), 109 deletions(-) (limited to 'ingen/client') diff --git a/ingen/client/ArcModel.hpp b/ingen/client/ArcModel.hpp index 99d5afa0..4306be09 100644 --- a/ingen/client/ArcModel.hpp +++ b/ingen/client/ArcModel.hpp @@ -19,8 +19,8 @@ #include +#include "ingen/types.hpp" #include "raul/Path.hpp" -#include "raul/SharedPtr.hpp" #include "ingen/Arc.hpp" #include "ingen/client/PortModel.hpp" @@ -37,8 +37,8 @@ class ClientStore; class ArcModel : public Arc { public: - SharedPtr tail() const { return _tail; } - SharedPtr head() const { return _head; } + SPtr tail() const { return _tail; } + SPtr head() const { return _head; } const Raul::Path& tail_path() const { return _tail->path(); } const Raul::Path& head_path() const { return _head->path(); } @@ -46,7 +46,7 @@ public: private: friend class ClientStore; - ArcModel(SharedPtr tail, SharedPtr head) + ArcModel(SPtr tail, SPtr head) : _tail(tail) , _head(head) { @@ -57,8 +57,8 @@ private: assert(_tail->path() != _head->path()); } - const SharedPtr _tail; - const SharedPtr _head; + const SPtr _tail; + const SPtr _head; }; } // namespace Client diff --git a/ingen/client/BlockModel.hpp b/ingen/client/BlockModel.hpp index 3262b230..b5db2b0d 100644 --- a/ingen/client/BlockModel.hpp +++ b/ingen/client/BlockModel.hpp @@ -21,11 +21,11 @@ #include #include -#include "raul/SharedPtr.hpp" #include "ingen/Node.hpp" #include "ingen/client/ObjectModel.hpp" #include "ingen/client/PluginModel.hpp" #include "ingen/client/PortModel.hpp" +#include "ingen/types.hpp" namespace Raul { class Path; } @@ -50,31 +50,35 @@ public: GraphType graph_type() const { return Node::GraphType::BLOCK; } - typedef std::vector< SharedPtr > Ports; + typedef std::vector< SPtr > Ports; - SharedPtr get_port(const Raul::Symbol& symbol) const; + SPtr get_port(const Raul::Symbol& symbol) const; Node* port(uint32_t index) const; - const Raul::URI& plugin_uri() const { return _plugin_uri; } - const Plugin* plugin() const { return _plugin.get(); } - Plugin* plugin() { return _plugin.get(); } - SharedPtr plugin_model() const { return _plugin; } - uint32_t num_ports() const { return _ports.size(); } - const Ports& ports() const { return _ports; } + const Raul::URI& plugin_uri() const { return _plugin_uri; } + const Plugin* plugin() const { return _plugin.get(); } + Plugin* plugin() { return _plugin.get(); } + SPtr plugin_model() const { return _plugin; } + uint32_t num_ports() const { return _ports.size(); } + const Ports& ports() const { return _ports; } - void default_port_value_range(SharedPtr port, - float& min, float& max, uint32_t srate=1) const; + void default_port_value_range(SPtr port, + float& min, + float& max, + uint32_t srate = 1) const; - void port_value_range(SharedPtr port, - float& min, float& max, uint32_t srate=1) const; + void port_value_range(SPtr port, + float& min, + float& max, + uint32_t srate = 1) const; std::string label() const; - std::string port_label(SharedPtr port) const; + std::string port_label(SPtr port) const; // Signals - INGEN_SIGNAL(new_port, void, SharedPtr); - INGEN_SIGNAL(removed_port, void, SharedPtr); + INGEN_SIGNAL(new_port, void, SPtr); + INGEN_SIGNAL(removed_port, void, SPtr); protected: friend class ClientStore; @@ -82,23 +86,23 @@ protected: BlockModel(URIs& uris, const Raul::URI& plugin_uri, const Raul::Path& path); - BlockModel(URIs& uris, - SharedPtr plugin, - const Raul::Path& path); + BlockModel(URIs& uris, + SPtr plugin, + const Raul::Path& path); explicit BlockModel(const Raul::Path& path); - void add_child(SharedPtr c); - bool remove_child(SharedPtr c); - void add_port(SharedPtr pm); - void remove_port(SharedPtr pm); + void add_child(SPtr c); + bool remove_child(SPtr c); + void add_port(SPtr pm); + void remove_port(SPtr pm); void remove_port(const Raul::Path& port_path); - void set(SharedPtr model); + void set(SPtr model); virtual void clear(); - Ports _ports; ///< Vector of ports - Raul::URI _plugin_uri; ///< Plugin URI (if PluginModel is unknown) - SharedPtr _plugin; ///< The plugin this block is an instance of + Ports _ports; ///< Vector of ports + Raul::URI _plugin_uri; ///< Plugin URI (if PluginModel is unknown) + SPtr _plugin; ///< The plugin this block is an instance of private: mutable uint32_t _num_values; ///< Size of _min_values and _max_values diff --git a/ingen/client/ClientStore.hpp b/ingen/client/ClientStore.hpp index 3d7d724a..e9c85ba9 100644 --- a/ingen/client/ClientStore.hpp +++ b/ingen/client/ClientStore.hpp @@ -22,10 +22,10 @@ #include #include "ingen/Interface.hpp" -#include "ingen/client/signal.hpp" #include "ingen/Store.hpp" +#include "ingen/client/signal.hpp" +#include "ingen/types.hpp" #include "raul/Path.hpp" -#include "raul/SharedPtr.hpp" namespace Raul { class Atom; } @@ -53,23 +53,23 @@ class ClientStore : public Store , public INGEN_TRACKABLE { public: ClientStore( - URIs& uris, - Log& log, - SharedPtr engine = SharedPtr(), - SharedPtr emitter = SharedPtr()); + URIs& uris, + Log& log, + SPtr engine = SPtr(), + SPtr emitter = SPtr()); Raul::URI uri() const { return Raul::URI("ingen:/clients/store"); } - SharedPtr object(const Raul::Path& path) const; - SharedPtr plugin(const Raul::URI& uri) const; - SharedPtr resource(const Raul::URI& uri) const; + SPtr object(const Raul::Path& path) const; + SPtr plugin(const Raul::URI& uri) const; + SPtr resource(const Raul::URI& uri) const; void clear(); - typedef std::map< const Raul::URI, SharedPtr > Plugins; - SharedPtr plugins() const { return _plugins; } - SharedPtr plugins() { return _plugins; } - void set_plugins(SharedPtr p) { _plugins = p; } + typedef std::map< const Raul::URI, SPtr > Plugins; + SPtr plugins() const { return _plugins; } + SPtr plugins() { return _plugins; } + void set_plugins(SPtr p) { _plugins = p; } URIs& uris() { return _uris; } @@ -104,21 +104,21 @@ public: void response(int32_t id, Status status, const std::string& subject) {} void error(const std::string& msg) {} - INGEN_SIGNAL(new_object, void, SharedPtr); - INGEN_SIGNAL(new_plugin, void, SharedPtr); + INGEN_SIGNAL(new_object, void, SPtr); + INGEN_SIGNAL(new_plugin, void, SPtr); private: - SharedPtr _object(const Raul::Path& path); - SharedPtr _plugin(const Raul::URI& uri); - SharedPtr _resource(const Raul::URI& uri); + SPtr _object(const Raul::Path& path); + SPtr _plugin(const Raul::URI& uri); + SPtr _resource(const Raul::URI& uri); - void add_object(SharedPtr object); - SharedPtr remove_object(const Raul::Path& path); + void add_object(SPtr object); + SPtr remove_object(const Raul::Path& path); - void add_plugin(SharedPtr plugin); + void add_plugin(SPtr plugin); - SharedPtr connection_graph(const Raul::Path& tail_path, - const Raul::Path& head_path); + SPtr connection_graph(const Raul::Path& tail_path, + const Raul::Path& head_path); void bundle_begin() {} void bundle_end() {} @@ -127,12 +127,12 @@ private: bool attempt_connection(const Raul::Path& tail_path, const Raul::Path& head_path); - URIs& _uris; - Log& _log; - SharedPtr _engine; - SharedPtr _emitter; + URIs& _uris; + Log& _log; + SPtr _engine; + SPtr _emitter; - SharedPtr _plugins; ///< Map, keyed by plugin URI + SPtr _plugins; ///< Map, keyed by plugin URI }; } // namespace Client diff --git a/ingen/client/GraphModel.hpp b/ingen/client/GraphModel.hpp index 996e9129..7a899ecb 100644 --- a/ingen/client/GraphModel.hpp +++ b/ingen/client/GraphModel.hpp @@ -18,7 +18,7 @@ #define INGEN_CLIENT_GRAPHMODEL_HPP #include "ingen/client/BlockModel.hpp" -#include "raul/SharedPtr.hpp" +#include "ingen/types.hpp" namespace Ingen { namespace Client { @@ -37,18 +37,18 @@ public: GraphType graph_type() const { return Node::GraphType::GRAPH; } - SharedPtr get_arc(const Ingen::Node* tail, - const Ingen::Node* head); + SPtr get_arc(const Ingen::Node* tail, + const Ingen::Node* head); bool enabled() const; bool polyphonic() const; uint32_t internal_poly() const; // Signals - INGEN_SIGNAL(new_block, void, SharedPtr); - INGEN_SIGNAL(removed_block, void, SharedPtr); - INGEN_SIGNAL(new_arc, void, SharedPtr); - INGEN_SIGNAL(removed_arc, void, SharedPtr); + INGEN_SIGNAL(new_block, void, SPtr); + INGEN_SIGNAL(removed_block, void, SPtr); + INGEN_SIGNAL(new_arc, void, SPtr); + INGEN_SIGNAL(removed_arc, void, SPtr); private: friend class ClientStore; @@ -58,10 +58,10 @@ private: {} void clear(); - void add_child(SharedPtr c); - bool remove_child(SharedPtr c); + void add_child(SPtr c); + bool remove_child(SPtr c); - void add_arc(SharedPtr arc); + void add_arc(SPtr arc); void remove_arc(const Ingen::Node* tail, const Ingen::Node* head); }; diff --git a/ingen/client/ObjectModel.hpp b/ingen/client/ObjectModel.hpp index 60e873e4..52655949 100644 --- a/ingen/client/ObjectModel.hpp +++ b/ingen/client/ObjectModel.hpp @@ -25,8 +25,8 @@ #include #include +#include "ingen/types.hpp" #include "raul/Path.hpp" -#include "raul/SharedPtr.hpp" #include "raul/URI.hpp" #include "ingen/Node.hpp" @@ -63,16 +63,16 @@ public: void on_property(const Raul::URI& uri, const Raul::Atom& value); - const Raul::Path& path() const { return _path; } - const Raul::Symbol& symbol() const { return _symbol; } - SharedPtr parent() const { return _parent; } - bool polyphonic() const; + const Raul::Path& path() const { return _path; } + const Raul::Symbol& symbol() const { return _symbol; } + SPtr parent() const { return _parent; } + bool polyphonic() const; Node* graph_parent() const { return _parent.get(); } // Signals - INGEN_SIGNAL(new_child, void, SharedPtr); - INGEN_SIGNAL(removed_child, void, SharedPtr); + INGEN_SIGNAL(new_child, void, SPtr); + INGEN_SIGNAL(removed_child, void, SPtr); INGEN_SIGNAL(property, void, const Raul::URI&, const Raul::Atom&); INGEN_SIGNAL(destroyed, void); INGEN_SIGNAL(moved, void); @@ -84,13 +84,13 @@ protected: ObjectModel(const ObjectModel& copy); virtual void set_path(const Raul::Path& p); - virtual void set_parent(SharedPtr p); - virtual void add_child(SharedPtr c) {} - virtual bool remove_child(SharedPtr c) { return true; } + virtual void set_parent(SPtr p); + virtual void add_child(SPtr c) {} + virtual bool remove_child(SPtr c) { return true; } - virtual void set(SharedPtr model); + virtual void set(SPtr model); - SharedPtr _parent; + SPtr _parent; private: Raul::Path _path; diff --git a/ingen/client/PluginModel.hpp b/ingen/client/PluginModel.hpp index 4195dfe2..dea85651 100644 --- a/ingen/client/PluginModel.hpp +++ b/ingen/client/PluginModel.hpp @@ -26,8 +26,8 @@ #include "ingen/Resource.hpp" #include "ingen/World.hpp" #include "ingen/client/signal.hpp" +#include "ingen/types.hpp" #include "lilv/lilv.h" -#include "raul/SharedPtr.hpp" #include "raul/Symbol.hpp" #include "sord/sordmm.hpp" @@ -74,8 +74,8 @@ public: bool has_ui() const; - SharedPtr ui(Ingen::World* world, - SharedPtr block) const; + SPtr ui(Ingen::World* world, + SPtr block) const; const std::string& icon_path() const; static std::string get_lv2_icon_path(const LilvPlugin* plugin); @@ -95,7 +95,7 @@ public: protected: friend class ClientStore; - void set(SharedPtr p); + void set(SPtr p); private: Type _type; diff --git a/ingen/client/PluginUI.hpp b/ingen/client/PluginUI.hpp index 60403570..b2a8bd6b 100644 --- a/ingen/client/PluginUI.hpp +++ b/ingen/client/PluginUI.hpp @@ -17,7 +17,7 @@ #ifndef INGEN_CLIENT_PLUGINUI_HPP #define INGEN_CLIENT_PLUGINUI_HPP -#include "raul/SharedPtr.hpp" +#include "ingen/types.hpp" #include "lilv/lilv.h" @@ -42,9 +42,9 @@ class PluginUI { public: ~PluginUI(); - static SharedPtr create(Ingen::World* world, - SharedPtr block, - const LilvPlugin* plugin); + static SPtr create(Ingen::World* world, + SPtr block, + const LilvPlugin* plugin); SuilWidget get_widget(); @@ -55,22 +55,22 @@ public: bool is_resizable() const; - Ingen::World* world() const { return _world; } - SharedPtr block() const { return _block; } + Ingen::World* world() const { return _world; } + SPtr block() const { return _block; } private: - PluginUI(Ingen::World* world, - SharedPtr block, - const LilvNode* ui_node); + PluginUI(Ingen::World* world, + SPtr block, + const LilvNode* ui_node); - Ingen::World* _world; - SharedPtr _block; - SuilInstance* _instance; - LilvNode* _ui_node; + Ingen::World* _world; + SPtr _block; + SuilInstance* _instance; + LilvNode* _ui_node; static SuilHost* ui_host; - SharedPtr _features; + SPtr _features; }; } // namespace Client diff --git a/ingen/client/PortModel.hpp b/ingen/client/PortModel.hpp index 92379e6e..568975fc 100644 --- a/ingen/client/PortModel.hpp +++ b/ingen/client/PortModel.hpp @@ -20,7 +20,7 @@ #include #include -#include "raul/SharedPtr.hpp" +#include "ingen/types.hpp" #include "lv2/lv2plug.in/ns/ext/port-props/port-props.h" #include "lv2/lv2plug.in/ns/lv2core/lv2.h" @@ -71,8 +71,8 @@ public: INGEN_SIGNAL(value_changed, void, const Raul::Atom&); INGEN_SIGNAL(voice_changed, void, uint32_t, const Raul::Atom&); INGEN_SIGNAL(activity, void, const Raul::Atom&); - INGEN_SIGNAL(connection, void, SharedPtr); - INGEN_SIGNAL(disconnection, void, SharedPtr); + INGEN_SIGNAL(connection, void, SPtr); + INGEN_SIGNAL(disconnection, void, SPtr); private: friend class ClientStore; @@ -87,20 +87,20 @@ private: , _connections(0) {} - void add_child(SharedPtr c) { throw; } - bool remove_child(SharedPtr c) { throw; } + void add_child(SPtr c) { throw; } + bool remove_child(SPtr c) { throw; } - void connected_to(SharedPtr p) { + void connected_to(SPtr p) { ++_connections; _signal_connection.emit(p); } - void disconnected_from(SharedPtr p) { + void disconnected_from(SPtr p) { --_connections; _signal_disconnection.emit(p); } - void set(SharedPtr model); + void set(SPtr model); uint32_t _index; Direction _direction; -- cgit v1.2.1