From fa9837f95a2d3be3f5eb94fcbf8222bb208d87db Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 11 Oct 2008 21:50:38 +0000 Subject: Remove duplicated code for getting various hints, add generic hint accessor. Cleanup namespace pollution. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@1650 a436a847-0d15-0410-975c-d299462d15a1 --- src/client/NodeModel.hpp | 16 ++++++---------- src/client/PatchModel.hpp | 2 +- src/client/PortModel.cpp | 22 ++-------------------- src/client/PortModel.hpp | 11 +++++------ 4 files changed, 14 insertions(+), 37 deletions(-) (limited to 'src') diff --git a/src/client/NodeModel.hpp b/src/client/NodeModel.hpp index 9b6efde8..b7bbb5af 100644 --- a/src/client/NodeModel.hpp +++ b/src/client/NodeModel.hpp @@ -22,7 +22,6 @@ #include #include #include -#include #include #include #include "interface/Node.hpp" @@ -31,9 +30,6 @@ #include "PortModel.hpp" #include "PluginModel.hpp" -using std::string; -using Raul::Table; - namespace Ingen { namespace Client { @@ -51,13 +47,13 @@ public: NodeModel(const NodeModel& copy); virtual ~NodeModel(); - typedef vector > Ports; + typedef std::vector< SharedPtr > Ports; - SharedPtr get_port(const string& port_name) const; + SharedPtr get_port(const std::string& port_name) const; Shared::Port* port(uint32_t index) const; - const string& plugin_uri() const { return _plugin_uri; } + const std::string& plugin_uri() const { return _plugin_uri; } const Shared::Plugin* plugin() const { return _plugin.get(); } uint32_t num_ports() const { return _ports.size(); } const Ports& ports() const { return _ports; } @@ -71,7 +67,7 @@ public: protected: friend class ClientStore; - NodeModel(const string& plugin_uri, const Path& path); + NodeModel(const std::string& plugin_uri, const Path& path); NodeModel(SharedPtr plugin, const Path& path); NodeModel(const Path& path); @@ -80,14 +76,14 @@ protected: void add_port(SharedPtr pm); void remove_port(SharedPtr pm); void remove_port(const Path& port_path); - void add_program(int bank, int program, const string& name); + void add_program(int bank, int program, const std::string& name); void remove_program(int bank, int program); void set(SharedPtr model); virtual void clear(); Ports _ports; ///< Vector of ports (not a Table to preserve order) - string _plugin_uri; ///< Plugin URI (if PluginModel is unknown) + std::string _plugin_uri; ///< Plugin URI (if PluginModel is unknown) SharedPtr _plugin; ///< The plugin this node is an instance of private: diff --git a/src/client/PatchModel.hpp b/src/client/PatchModel.hpp index 70c8df0e..ac1e2ac0 100644 --- a/src/client/PatchModel.hpp +++ b/src/client/PatchModel.hpp @@ -96,7 +96,7 @@ private: bool _editable; }; -typedef Table > PatchModelMap; +typedef Raul::Table > PatchModelMap; } // namespace Client diff --git a/src/client/PortModel.cpp b/src/client/PortModel.cpp index c18378db..af257ebf 100644 --- a/src/client/PortModel.cpp +++ b/src/client/PortModel.cpp @@ -21,30 +21,12 @@ namespace Ingen { namespace Client { - -bool -PortModel::is_logarithmic() const -{ - const Atom& hint = get_variable("ingen:logarithmic"); - return (hint.is_valid() && hint.get_bool() > 0); -} - - bool -PortModel::is_integer() const +PortModel::has_hint(const std::string& qname) const { - const Atom& hint = get_variable("ingen:integer"); + const Atom& hint = get_variable(qname); return (hint.is_valid() && hint.get_bool() > 0); } - - -bool -PortModel::is_toggle() const -{ - const Atom& hint = get_variable("ingen:toggled"); - return (hint.is_valid() && hint.get_bool() > 0); -} - void PortModel::set(SharedPtr model) diff --git a/src/client/PortModel.hpp b/src/client/PortModel.hpp index a7f52679..cf0d7ddc 100644 --- a/src/client/PortModel.hpp +++ b/src/client/PortModel.hpp @@ -21,15 +21,12 @@ #include #include #include -#include #include #include #include #include "interface/Port.hpp" #include "ObjectModel.hpp" -using std::string; using std::vector; - namespace Ingen { namespace Client { @@ -50,9 +47,11 @@ public: inline bool is_input() const { return (_direction == INPUT); } inline bool is_output() const { return (_direction == OUTPUT); } - bool is_logarithmic() const; - bool is_integer() const; - bool is_toggle() const; + bool has_hint(const std::string& qname) const; + + bool is_logarithmic() const { return has_hint("ingen:logarithmic"); } + bool is_integer() const { return has_hint("ingen:integer"); } + bool is_toggle() const { return has_hint("ingen:toggled"); } inline bool operator==(const PortModel& pm) const { return (_path == pm._path); } -- cgit v1.2.1