diff options
Diffstat (limited to 'src/client')
-rw-r--r-- | src/client/ClientStore.cpp | 40 | ||||
-rw-r--r-- | src/client/ClientStore.hpp | 9 | ||||
-rw-r--r-- | src/client/NodeModel.cpp | 19 | ||||
-rw-r--r-- | src/client/NodeModel.hpp | 32 | ||||
-rw-r--r-- | src/client/PatchModel.hpp | 6 | ||||
-rw-r--r-- | src/client/PluginModel.cpp | 7 | ||||
-rw-r--r-- | src/client/PluginModel.hpp | 8 | ||||
-rw-r--r-- | src/client/PluginUI.cpp | 15 | ||||
-rw-r--r-- | src/client/PluginUI.hpp | 20 | ||||
-rw-r--r-- | src/client/PortModel.cpp | 2 | ||||
-rw-r--r-- | src/client/PortModel.hpp | 3 |
11 files changed, 92 insertions, 69 deletions
diff --git a/src/client/ClientStore.cpp b/src/client/ClientStore.cpp index 52d05622..24d7728f 100644 --- a/src/client/ClientStore.cpp +++ b/src/client/ClientStore.cpp @@ -85,7 +85,7 @@ ClientStore::add_object(SharedPtr<ObjectModel> object) PtrCast<ObjectModel>(existing->second)->set(object); } else { if (!object->path().is_root()) { - SharedPtr<ObjectModel> parent = this->object(object->path().parent()); + SharedPtr<ObjectModel> parent = _object(object->path().parent()); if (parent) { assert(object->path().is_child_of(parent->path())); object->set_parent(parent); @@ -137,7 +137,7 @@ ClientStore::remove_object(const Path& path) if (!result->path().is_root()) { assert(result->parent()); - SharedPtr<ObjectModel> parent = this->object(result->path().parent()); + SharedPtr<ObjectModel> parent = _object(result->path().parent()); if (parent) { parent->remove_child(result); } @@ -164,7 +164,7 @@ ClientStore::plugin(const URI& uri) } SharedPtr<ObjectModel> -ClientStore::object(const Path& path) +ClientStore::_object(const Path& path) { assert(path.length() > 0); iterator i = find(path); @@ -178,11 +178,17 @@ ClientStore::object(const Path& path) } } +SharedPtr<const ObjectModel> +ClientStore::object(const Path& path) const +{ + return const_cast<ClientStore*>(this)->_object(path); +} + SharedPtr<Resource> ClientStore::resource(const URI& uri) { if (Path::is_path(uri)) - return object(uri.str()); + return _object(uri.str()); else return plugin(uri); } @@ -291,7 +297,7 @@ ClientStore::put(const URI& uri, const Path path(uri.str()); - SharedPtr<ObjectModel> obj = PtrCast<ObjectModel>(object(path)); + SharedPtr<ObjectModel> obj = PtrCast<ObjectModel>(_object(path)); if (obj) { obj->set_properties(properties); return; @@ -371,7 +377,7 @@ ClientStore::delta(const URI& uri, const Path path(uri.str()); - SharedPtr<ObjectModel> obj = object(path); + SharedPtr<ObjectModel> obj = _object(path); if (obj) { obj->remove_properties(remove); obj->add_properties(add); @@ -399,7 +405,7 @@ ClientStore::set_property(const URI& subject_uri, const URI& predicate, const At void ClientStore::activity(const Path& path) { - SharedPtr<PortModel> port = PtrCast<PortModel>(object(path)); + SharedPtr<PortModel> port = PtrCast<PortModel>(_object(path)); if (port) port->signal_activity().emit(); else @@ -412,16 +418,16 @@ ClientStore::connection_patch(const Path& src_port_path, const Path& dst_port_pa SharedPtr<PatchModel> patch; if (src_port_path.parent() == dst_port_path.parent()) - patch = PtrCast<PatchModel>(this->object(src_port_path.parent())); + patch = PtrCast<PatchModel>(_object(src_port_path.parent())); if (!patch && src_port_path.parent() == dst_port_path.parent().parent()) - patch = PtrCast<PatchModel>(this->object(src_port_path.parent())); + patch = PtrCast<PatchModel>(_object(src_port_path.parent())); if (!patch && src_port_path.parent().parent() == dst_port_path.parent()) - patch = PtrCast<PatchModel>(this->object(dst_port_path.parent())); + patch = PtrCast<PatchModel>(_object(dst_port_path.parent())); if (!patch) - patch = PtrCast<PatchModel>(this->object(src_port_path.parent().parent())); + patch = PtrCast<PatchModel>(_object(src_port_path.parent().parent())); if (!patch) LOG(error) << "Unable to find connection patch " << src_port_path @@ -434,8 +440,8 @@ bool ClientStore::attempt_connection(const Path& src_port_path, const Path& dst_port_path) { - SharedPtr<PortModel> src_port = PtrCast<PortModel>(object(src_port_path)); - SharedPtr<PortModel> dst_port = PtrCast<PortModel>(object(dst_port_path)); + SharedPtr<PortModel> src_port = PtrCast<PortModel>(_object(src_port_path)); + SharedPtr<PortModel> dst_port = PtrCast<PortModel>(_object(dst_port_path)); if (src_port && dst_port) { SharedPtr<PatchModel> patch = connection_patch(src_port_path, dst_port_path); @@ -470,8 +476,8 @@ ClientStore::disconnect(const URI& src, const Path src_path(src.str()); const Path dst_path(dst.str()); - SharedPtr<PortModel> src_port = PtrCast<PortModel>(object(src_path)); - SharedPtr<PortModel> dst_port = PtrCast<PortModel>(object(dst_path)); + SharedPtr<PortModel> src_port = PtrCast<PortModel>(_object(src_path)); + SharedPtr<PortModel> dst_port = PtrCast<PortModel>(_object(dst_path)); if (src_port) src_port->disconnected_from(dst_port); @@ -488,8 +494,8 @@ void ClientStore::disconnect_all(const Raul::Path& parent_patch_path, const Raul::Path& path) { - SharedPtr<PatchModel> patch = PtrCast<PatchModel>(object(parent_patch_path)); - SharedPtr<ObjectModel> object = this->object(path); + SharedPtr<PatchModel> patch = PtrCast<PatchModel>(_object(parent_patch_path)); + SharedPtr<ObjectModel> object = _object(path); if (!patch || !object) return; diff --git a/src/client/ClientStore.hpp b/src/client/ClientStore.hpp index 59b112ed..32b66484 100644 --- a/src/client/ClientStore.hpp +++ b/src/client/ClientStore.hpp @@ -61,9 +61,10 @@ public: SharedPtr<ServerInterface> engine=SharedPtr<ServerInterface>(), SharedPtr<SigClientInterface> emitter=SharedPtr<SigClientInterface>()); - SharedPtr<PluginModel> plugin(const Raul::URI& uri); - SharedPtr<ObjectModel> object(const Raul::Path& path); - SharedPtr<Resource> resource(const Raul::URI& uri); + SharedPtr<PluginModel> plugin(const Raul::URI& uri); + SharedPtr<Resource> resource(const Raul::URI& uri); + + SharedPtr<const ObjectModel> object(const Raul::Path& path) const; void clear(); @@ -109,6 +110,8 @@ public: private: void add(GraphObject* o) { throw; } + SharedPtr<ObjectModel> _object(const Raul::Path& path); + void add_object(SharedPtr<ObjectModel> object); SharedPtr<ObjectModel> remove_object(const Raul::Path& path); diff --git a/src/client/NodeModel.cpp b/src/client/NodeModel.cpp index 7847afb40..39ce7c8d 100644 --- a/src/client/NodeModel.cpp +++ b/src/client/NodeModel.cpp @@ -29,7 +29,9 @@ using namespace Raul; namespace Ingen { namespace Client { -NodeModel::NodeModel(Shared::LV2URIMap& uris, SharedPtr<PluginModel> plugin, const Path& path) +NodeModel::NodeModel(Shared::LV2URIMap& uris, + SharedPtr<PluginModel> plugin, + const Path& path) : Node() , ObjectModel(uris, path) , _plugin_uri(plugin->uri()) @@ -40,7 +42,9 @@ NodeModel::NodeModel(Shared::LV2URIMap& uris, SharedPtr<PluginModel> plugin, con { } -NodeModel::NodeModel(Shared::LV2URIMap& uris, const URI& plugin_uri, const Path& path) +NodeModel::NodeModel(Shared::LV2URIMap& uris, + const URI& plugin_uri, + const Path& path) : Node() , ObjectModel(uris, path) , _plugin_uri(plugin_uri) @@ -145,7 +149,7 @@ NodeModel::add_port(SharedPtr<PortModel> pm) _signal_new_port.emit(pm); } -SharedPtr<PortModel> +SharedPtr<const PortModel> NodeModel::get_port(const Raul::Symbol& symbol) const { for (Ports::const_iterator i = _ports.begin(); i != _ports.end(); ++i) @@ -158,11 +162,12 @@ Ingen::Port* NodeModel::port(uint32_t index) const { assert(index < num_ports()); - return dynamic_cast<Ingen::Port*>(_ports[index].get()); + return const_cast<Ingen::Port*>(dynamic_cast<const Ingen::Port*>(_ports[index].get())); } void -NodeModel::default_port_value_range(SharedPtr<PortModel> port, float& min, float& max) const +NodeModel::default_port_value_range(SharedPtr<const PortModel> port, + float& min, float& max) const { // Default control values min = 0.0; @@ -189,7 +194,7 @@ NodeModel::default_port_value_range(SharedPtr<PortModel> port, float& min, float } void -NodeModel::port_value_range(SharedPtr<PortModel> port, float& min, float& max) const +NodeModel::port_value_range(SharedPtr<const PortModel> port, float& min, float& max) const { assert(port->parent().get() == this); @@ -208,7 +213,7 @@ NodeModel::port_value_range(SharedPtr<PortModel> port, float& min, float& max) c } std::string -NodeModel::port_label(SharedPtr<PortModel> port) const +NodeModel::port_label(SharedPtr<const PortModel> port) const { const Raul::Atom& name = port->get_property("http://lv2plug.in/ns/lv2core#name"); if (name.is_valid()) { diff --git a/src/client/NodeModel.hpp b/src/client/NodeModel.hpp index 314ed1b4..e57d02d6 100644 --- a/src/client/NodeModel.hpp +++ b/src/client/NodeModel.hpp @@ -50,9 +50,9 @@ public: NodeModel(const NodeModel& copy); virtual ~NodeModel(); - typedef std::vector< SharedPtr<PortModel> > Ports; + typedef std::vector< SharedPtr<const PortModel> > Ports; - SharedPtr<PortModel> get_port(const Raul::Symbol& symbol) const; + SharedPtr<const PortModel> get_port(const Raul::Symbol& symbol) const; Port* port(uint32_t index) const; @@ -63,22 +63,28 @@ public: uint32_t num_ports() const { return _ports.size(); } const Ports& ports() const { return _ports; } - void default_port_value_range(SharedPtr<PortModel> port, float& min, float& max) const; - void port_value_range(SharedPtr<PortModel> port, float& min, float& max) const; + void default_port_value_range(SharedPtr<const PortModel> port, + float& min, float& max) const; + void port_value_range(SharedPtr<const PortModel> port, + float& min, float& max) const; - std::string port_label(SharedPtr<PortModel> port) const; + std::string port_label(SharedPtr<const PortModel> port) const; // Signals - INGEN_SIGNAL(new_port, void, SharedPtr<PortModel>); - INGEN_SIGNAL(removed_port, void, SharedPtr<PortModel>); + INGEN_SIGNAL(new_port, void, SharedPtr<const PortModel>); + INGEN_SIGNAL(removed_port, void, SharedPtr<const PortModel>); protected: friend class ClientStore; - NodeModel(Shared::LV2URIMap& uris, const Raul::URI& plugin_uri, const Raul::Path& path); - NodeModel(Shared::LV2URIMap& uris, SharedPtr<PluginModel> plugin, const Raul::Path& path); - + NodeModel(Shared::LV2URIMap& uris, + const Raul::URI& plugin_uri, + const Raul::Path& path); + NodeModel(Shared::LV2URIMap& uris, + SharedPtr<PluginModel> plugin, + const Raul::Path& path); NodeModel(const Raul::Path& path); + void add_child(SharedPtr<ObjectModel> c); bool remove_child(SharedPtr<ObjectModel> c); void add_port(SharedPtr<PortModel> pm); @@ -90,9 +96,9 @@ protected: virtual void clear(); - Ports _ports; ///< Vector of ports (not a Table to preserve order) - Raul::URI _plugin_uri; ///< Plugin URI (if PluginModel is unknown) - SharedPtr<PluginModel> _plugin; ///< The plugin this node is an instance of + Ports _ports; ///< Vector of ports (not a Table to preserve order) + Raul::URI _plugin_uri; ///< Plugin URI (if PluginModel is unknown) + SharedPtr<PluginModel> _plugin; ///< The plugin this node is an instance of private: mutable uint32_t _num_values; ///< Size of _min_values and _max_values diff --git a/src/client/PatchModel.hpp b/src/client/PatchModel.hpp index 73930189..dbd54c03 100644 --- a/src/client/PatchModel.hpp +++ b/src/client/PatchModel.hpp @@ -57,10 +57,10 @@ public: * not editable (control mode) you can just change controllers (performing) */ bool get_editable() const { return _editable; } - void set_editable(bool e) { + void set_editable(bool e) const { if (_editable != e) { _editable = e; - _signal_editable.emit(e); + const_cast<PatchModel*>(this)->signal_editable().emit(e); } } @@ -90,7 +90,7 @@ private: const Ingen::Port* dst_port); SharedPtr<Connections> _connections; - bool _editable; + mutable bool _editable; }; } // namespace Client diff --git a/src/client/PluginModel.cpp b/src/client/PluginModel.cpp index 8a644edc..3f0bf735 100644 --- a/src/client/PluginModel.cpp +++ b/src/client/PluginModel.cpp @@ -149,7 +149,7 @@ PluginModel::set(SharedPtr<PluginModel> p) } Symbol -PluginModel::default_node_symbol() +PluginModel::default_node_symbol() const { const Atom& name_atom = get_property("http://lv2plug.in/ns/lv2core#symbol"); if (name_atom.is_valid() && name_atom.type() == Atom::STRING) @@ -159,7 +159,7 @@ PluginModel::default_node_symbol() } string -PluginModel::human_name() +PluginModel::human_name() const { const Atom& name_atom = get_property("http://usefulinc.com/ns/doap#name"); if (name_atom.type() == Atom::STRING) @@ -194,7 +194,8 @@ PluginModel::has_ui() const } SharedPtr<PluginUI> -PluginModel::ui(Ingen::Shared::World* world, SharedPtr<NodeModel> node) const +PluginModel::ui(Ingen::Shared::World* world, + SharedPtr<const NodeModel> node) const { if (_type != LV2) return SharedPtr<PluginUI>(); diff --git a/src/client/PluginModel.hpp b/src/client/PluginModel.hpp index e301c615..852a554d 100644 --- a/src/client/PluginModel.hpp +++ b/src/client/PluginModel.hpp @@ -62,8 +62,8 @@ public: virtual const Raul::Atom& get_property(const Raul::URI& key) const; - Raul::Symbol default_node_symbol(); - std::string human_name(); + Raul::Symbol default_node_symbol() const; + std::string human_name() const; std::string port_human_name(uint32_t index) const; #ifdef HAVE_LILV @@ -81,8 +81,8 @@ public: bool has_ui() const; - SharedPtr<PluginUI> ui(Ingen::Shared::World* world, - SharedPtr<NodeModel> node) const; + SharedPtr<PluginUI> ui(Ingen::Shared::World* world, + SharedPtr<const NodeModel> node) const; const std::string& icon_path() const; static std::string get_lv2_icon_path(const LilvPlugin* plugin); diff --git a/src/client/PluginUI.cpp b/src/client/PluginUI.cpp index 53f1d5ab..466ee320 100644 --- a/src/client/PluginUI.cpp +++ b/src/client/PluginUI.cpp @@ -52,7 +52,7 @@ lv2_ui_write(SuilController controller, return; } - SharedPtr<PortModel> port = ports[port_index]; + SharedPtr<const PortModel> port = ports[port_index]; const Shared::LV2URIMap& uris = *ui->world()->uris().get(); @@ -101,8 +101,8 @@ lv2_ui_write(SuilController controller, } } -PluginUI::PluginUI(Ingen::Shared::World* world, - SharedPtr<NodeModel> node) +PluginUI::PluginUI(Ingen::Shared::World* world, + SharedPtr<const NodeModel> node) : _world(world) , _node(node) , _instance(NULL) @@ -115,9 +115,9 @@ PluginUI::~PluginUI() } SharedPtr<PluginUI> -PluginUI::create(Ingen::Shared::World* world, - SharedPtr<NodeModel> node, - const LilvPlugin* plugin) +PluginUI::create(Ingen::Shared::World* world, + SharedPtr<const NodeModel> node, + const LilvPlugin* plugin) { if (!PluginUI::ui_host) { PluginUI::ui_host = suil_host_new(lv2_ui_write, NULL, NULL, NULL); @@ -148,7 +148,8 @@ PluginUI::create(Ingen::Shared::World* world, } SharedPtr<PluginUI> ret(new PluginUI(world, node)); - ret->_features = world->lv2_features()->lv2_features(world, node.get()); + ret->_features = world->lv2_features()->lv2_features( + world, const_cast<NodeModel*>(node.get())); SuilInstance* instance = suil_instance_new( PluginUI::ui_host, diff --git a/src/client/PluginUI.hpp b/src/client/PluginUI.hpp index cedc4fe2..9f5b0e52 100644 --- a/src/client/PluginUI.hpp +++ b/src/client/PluginUI.hpp @@ -44,9 +44,9 @@ class PluginUI { public: ~PluginUI(); - static SharedPtr<PluginUI> create(Ingen::Shared::World* world, - SharedPtr<NodeModel> node, - const LilvPlugin* plugin); + static SharedPtr<PluginUI> create(Ingen::Shared::World* world, + SharedPtr<const NodeModel> node, + const LilvPlugin* plugin); SuilWidget get_widget(); @@ -55,16 +55,16 @@ public: uint32_t format, const void* buffer); - Ingen::Shared::World* world() const { return _world; } - SharedPtr<NodeModel> node() const { return _node; } + Ingen::Shared::World* world() const { return _world; } + SharedPtr<const NodeModel> node() const { return _node; } private: - PluginUI(Ingen::Shared::World* world, - SharedPtr<NodeModel> node); + PluginUI(Ingen::Shared::World* world, + SharedPtr<const NodeModel> node); - Ingen::Shared::World* _world; - SharedPtr<NodeModel> _node; - SuilInstance* _instance; + Ingen::Shared::World* _world; + SharedPtr<const NodeModel> _node; + SuilInstance* _instance; static SuilHost* ui_host; diff --git a/src/client/PortModel.cpp b/src/client/PortModel.cpp index 9ca7fe19..f6edba20 100644 --- a/src/client/PortModel.cpp +++ b/src/client/PortModel.cpp @@ -61,7 +61,7 @@ PortModel::set(SharedPtr<ObjectModel> model) } bool -PortModel::has_context(const Raul::URI& uri) +PortModel::has_context(const Raul::URI& uri) const { const Raul::Atom& context = get_property(_uris.ctx_context); if (uri == _uris.ctx_AudioContext && !context.is_valid()) diff --git a/src/client/PortModel.hpp b/src/client/PortModel.hpp index 133a2794..fd4a679e 100644 --- a/src/client/PortModel.hpp +++ b/src/client/PortModel.hpp @@ -56,7 +56,8 @@ public: bool is_integer() const { return port_property("http://lv2plug.in/ns/lv2core#integer"); } bool is_toggle() const { return port_property("http://lv2plug.in/ns/lv2core#toggled"); } - bool has_context(const Raul::URI& context); + bool has_context(const Raul::URI& context) const; + inline bool operator==(const PortModel& pm) const { return (path() == pm.path()); } |