From bdbdf42f3fe990c713c5437724db39274c387eee Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 2 Aug 2020 15:23:19 +0200 Subject: Remove std::shared_ptr alias --- src/client/BlockModel.cpp | 53 +++++++++++++++++++------------------- src/client/ClientStore.cpp | 64 +++++++++++++++++++++++----------------------- src/client/GraphModel.cpp | 12 ++++----- src/client/ObjectModel.cpp | 4 +-- src/client/PluginModel.cpp | 8 +++--- src/client/PluginUI.cpp | 49 ++++++++++++++++++----------------- src/client/PortModel.cpp | 2 +- 7 files changed, 98 insertions(+), 94 deletions(-) (limited to 'src/client') diff --git a/src/client/BlockModel.cpp b/src/client/BlockModel.cpp index 636b3a85..898a1799 100644 --- a/src/client/BlockModel.cpp +++ b/src/client/BlockModel.cpp @@ -30,15 +30,15 @@ namespace ingen { namespace client { -BlockModel::BlockModel(URIs& uris, - const SPtr& plugin, - const Raul::Path& path) - : ObjectModel(uris, path) - , _plugin_uri(plugin->uri()) - , _plugin(plugin) - , _num_values(0) - , _min_values(nullptr) - , _max_values(nullptr) +BlockModel::BlockModel(URIs& uris, + const std::shared_ptr& plugin, + const Raul::Path& path) + : ObjectModel(uris, path) + , _plugin_uri(plugin->uri()) + , _plugin(plugin) + , _num_values(0) + , _min_values(nullptr) + , _max_values(nullptr) { } @@ -68,7 +68,7 @@ BlockModel::~BlockModel() } void -BlockModel::remove_port(const SPtr& port) +BlockModel::remove_port(const std::shared_ptr& port) { for (auto i = _ports.begin(); i != _ports.end(); ++i) { if ((*i) == port) { @@ -102,7 +102,7 @@ BlockModel::clear() } void -BlockModel::add_child(const SPtr& c) +BlockModel::add_child(const std::shared_ptr& c) { assert(c->parent().get() == this); @@ -114,7 +114,7 @@ BlockModel::add_child(const SPtr& c) } bool -BlockModel::remove_child(const SPtr& c) +BlockModel::remove_child(const std::shared_ptr& c) { assert(c->path().is_child_of(path())); assert(c->parent().get() == this); @@ -130,7 +130,7 @@ BlockModel::remove_child(const SPtr& c) } void -BlockModel::add_port(const SPtr& pm) +BlockModel::add_port(const std::shared_ptr& pm) { assert(pm); assert(pm->path().is_child_of(path())); @@ -143,7 +143,7 @@ BlockModel::add_port(const SPtr& pm) _signal_new_port.emit(pm); } -SPtr +std::shared_ptr BlockModel::get_port(const Raul::Symbol& symbol) const { for (auto p : _ports) { @@ -151,10 +151,10 @@ BlockModel::get_port(const Raul::Symbol& symbol) const return p; } } - return SPtr(); + return std::shared_ptr(); } -SPtr +std::shared_ptr BlockModel::get_port(uint32_t index) const { return _ports[index]; @@ -169,10 +169,11 @@ BlockModel::port(uint32_t index) const } void -BlockModel::default_port_value_range(const SPtr& port, - float& min, - float& max, - uint32_t srate) const +BlockModel::default_port_value_range( + const std::shared_ptr& port, + float& min, + float& max, + uint32_t srate) const { // Default control values min = 0.0; @@ -203,10 +204,10 @@ BlockModel::default_port_value_range(const SPtr& port, } void -BlockModel::port_value_range(const SPtr& port, - float& min, - float& max, - uint32_t srate) const +BlockModel::port_value_range(const std::shared_ptr& port, + float& min, + float& max, + uint32_t srate) const { assert(port->parent().get() == this); @@ -246,7 +247,7 @@ BlockModel::label() const } std::string -BlockModel::port_label(const SPtr& port) const +BlockModel::port_label(const std::shared_ptr& port) const { const Atom& name = port->get_property(URI(LV2_CORE__name)); if (name.is_valid() && name.type() == _uris.forge.String) { @@ -273,7 +274,7 @@ BlockModel::port_label(const SPtr& port) const } void -BlockModel::set(const SPtr& model) +BlockModel::set(const std::shared_ptr& model) { auto block = std::dynamic_pointer_cast(model); if (block) { diff --git a/src/client/ClientStore.cpp b/src/client/ClientStore.cpp index a9d8f44b..1a7963f3 100644 --- a/src/client/ClientStore.cpp +++ b/src/client/ClientStore.cpp @@ -36,9 +36,9 @@ namespace ingen { namespace client { -ClientStore::ClientStore(URIs& uris, - Log& log, - const SPtr& emitter) +ClientStore::ClientStore(URIs& uris, + Log& log, + const std::shared_ptr& emitter) : _uris(uris) , _log(log) , _emitter(emitter) @@ -58,7 +58,7 @@ ClientStore::clear() } void -ClientStore::add_object(const SPtr& object) +ClientStore::add_object(const std::shared_ptr& object) { // If we already have "this" object, merge the existing one into the new // one (with precedence to the new values). @@ -67,7 +67,7 @@ ClientStore::add_object(const SPtr& object) std::dynamic_pointer_cast(existing->second)->set(object); } else { if (!object->path().is_root()) { - SPtr parent = _object(object->path().parent()); + std::shared_ptr parent = _object(object->path().parent()); if (parent) { assert(object->path().is_child_of(parent->path())); object->set_parent(parent); @@ -90,7 +90,7 @@ ClientStore::add_object(const SPtr& object) } } -SPtr +std::shared_ptr ClientStore::remove_object(const Raul::Path& path) { // Find the object, the "top" of the tree to remove @@ -130,30 +130,30 @@ ClientStore::remove_object(const Raul::Path& path) return object; } -SPtr +std::shared_ptr ClientStore::_plugin(const URI& uri) { const Plugins::iterator i = _plugins->find(uri); - return (i == _plugins->end()) ? SPtr() : (*i).second; + return (i == _plugins->end()) ? std::shared_ptr() : (*i).second; } -SPtr +std::shared_ptr ClientStore::_plugin(const Atom& uri) { /* FIXME: Should probably be stored with URIs rather than strings, to make this a fast case. */ const Plugins::iterator i = _plugins->find(URI(_uris.forge.str(uri, false))); - return (i == _plugins->end()) ? SPtr() : (*i).second; + return (i == _plugins->end()) ? std::shared_ptr() : (*i).second; } -SPtr +std::shared_ptr ClientStore::plugin(const URI& uri) const { return const_cast(this)->_plugin(uri); } -SPtr +std::shared_ptr ClientStore::_object(const Raul::Path& path) { const iterator i = find(path); @@ -167,13 +167,13 @@ ClientStore::_object(const Raul::Path& path) } } -SPtr +std::shared_ptr ClientStore::object(const Raul::Path& path) const { return const_cast(this)->_object(path); } -SPtr +std::shared_ptr ClientStore::_resource(const URI& uri) { if (uri_is_path(uri)) { @@ -183,16 +183,16 @@ ClientStore::_resource(const URI& uri) } } -SPtr +std::shared_ptr ClientStore::resource(const URI& uri) const { return const_cast(this)->_resource(uri); } void -ClientStore::add_plugin(const SPtr& pm) +ClientStore::add_plugin(const std::shared_ptr& pm) { - SPtr existing = _plugin(pm->uri()); + std::shared_ptr existing = _plugin(pm->uri()); if (existing) { existing->set(pm); } else { @@ -258,9 +258,9 @@ ClientStore::operator()(const Put& msg) if (t != properties.end()) { const Atom& type(t->second); if (_uris.pset_Preset == type) { - const Iterator p = properties.find(_uris.lv2_appliesTo); - const Iterator l = properties.find(_uris.rdfs_label); - SPtr plug; + const Iterator p = properties.find(_uris.lv2_appliesTo); + const Iterator l = properties.find(_uris.rdfs_label); + std::shared_ptr plug; if (p == properties.end()) { _log.error("Preset <%1%> with no plugin\n", uri.c_str()); } else if (l == properties.end()) { @@ -277,7 +277,7 @@ ClientStore::operator()(const Put& msg) } else if (_uris.ingen_Graph == type) { is_graph = true; } else if (_uris.ingen_Internal == type || _uris.lv2_Plugin == type) { - SPtr p(new PluginModel(uris(), uri, type, properties)); + std::shared_ptr p(new PluginModel(uris(), uri, type, properties)); add_plugin(p); return; } @@ -301,7 +301,7 @@ ClientStore::operator()(const Put& msg) } if (is_graph) { - SPtr model(new GraphModel(uris(), path)); + std::shared_ptr model(new GraphModel(uris(), path)); model->set_properties(properties); add_object(model); } else if (is_block) { @@ -310,7 +310,7 @@ ClientStore::operator()(const Put& msg) p = properties.find(_uris.ingen_prototype); } - SPtr plug; + std::shared_ptr plug; if (p->second.is_valid() && (p->second.type() == _uris.forge.URI || p->second.type() == _uris.forge.URID)) { const URI plugin_uri(_uris.forge.str(p->second, false)); @@ -322,7 +322,7 @@ ClientStore::operator()(const Put& msg) add_plugin(plug); } - SPtr bm(new BlockModel(uris(), plug, path)); + std::shared_ptr bm(new BlockModel(uris(), plug, path)); bm->set_properties(properties); add_object(bm); } else { @@ -338,7 +338,7 @@ ClientStore::operator()(const Put& msg) index = i->second.get(); } - SPtr p(new PortModel(uris(), path, index, pdir)); + std::shared_ptr p(new PortModel(uris(), path, index, pdir)); p->set_properties(properties); add_object(p); } else { @@ -362,7 +362,7 @@ ClientStore::operator()(const Delta& msg) const Raul::Path path(uri_to_path(uri)); - SPtr obj = _object(path); + std::shared_ptr obj = _object(path); if (obj) { obj->remove_properties(msg.remove); obj->add_properties(msg.add); @@ -383,7 +383,7 @@ ClientStore::operator()(const SetProperty& msg) predicate.c_str(), _uris.forge.str(value, false)); return; } - SPtr subject = _resource(subject_uri); + std::shared_ptr subject = _resource(subject_uri); if (subject) { if (predicate == _uris.ingen_activity) { /* Activity is transient, trigger any live actions (like GUI @@ -393,7 +393,7 @@ ClientStore::operator()(const SetProperty& msg) subject->set_property(predicate, value, msg.ctx); } } else { - SPtr plugin = _plugin(subject_uri); + std::shared_ptr plugin = _plugin(subject_uri); if (plugin) { plugin->set_property(predicate, value); } else if (predicate != _uris.ingen_activity) { @@ -403,11 +403,11 @@ ClientStore::operator()(const SetProperty& msg) } } -SPtr +std::shared_ptr ClientStore::connection_graph(const Raul::Path& tail_path, const Raul::Path& head_path) { - SPtr graph; + std::shared_ptr graph; if (tail_path.parent() == head_path.parent()) { graph = std::dynamic_pointer_cast(_object(tail_path.parent())); @@ -441,8 +441,8 @@ ClientStore::attempt_connection(const Raul::Path& tail_path, auto head = std::dynamic_pointer_cast(_object(head_path)); if (tail && head) { - SPtr graph = connection_graph(tail_path, head_path); - SPtr arc(new ArcModel(tail, head)); + std::shared_ptr graph = connection_graph(tail_path, head_path); + std::shared_ptr arc(new ArcModel(tail, head)); graph->add_arc(arc); return true; } else { diff --git a/src/client/GraphModel.cpp b/src/client/GraphModel.cpp index b965258e..3bc08dfd 100644 --- a/src/client/GraphModel.cpp +++ b/src/client/GraphModel.cpp @@ -30,7 +30,7 @@ namespace ingen { namespace client { void -GraphModel::add_child(const SPtr& c) +GraphModel::add_child(const std::shared_ptr& c) { assert(c->parent().get() == this); @@ -47,7 +47,7 @@ GraphModel::add_child(const SPtr& c) } bool -GraphModel::remove_child(const SPtr& o) +GraphModel::remove_child(const std::shared_ptr& o) { assert(o->path().is_child_of(path())); assert(o->parent().get() == this); @@ -67,7 +67,7 @@ GraphModel::remove_child(const SPtr& o) } void -GraphModel::remove_arcs_on(const SPtr& p) +GraphModel::remove_arcs_on(const std::shared_ptr& p) { // Remove any connections which referred to this object, // since they can't possibly exist anymore @@ -98,7 +98,7 @@ GraphModel::clear() assert(_ports.empty()); } -SPtr +std::shared_ptr GraphModel::get_arc(const Node* tail, const Node* head) { auto i = _arcs.find(std::make_pair(tail, head)); @@ -117,7 +117,7 @@ GraphModel::get_arc(const Node* tail, const Node* head) * this graph is a fatal error. */ void -GraphModel::add_arc(const SPtr& arc) +GraphModel::add_arc(const std::shared_ptr& arc) { // Store should have 'resolved' the connection already assert(arc); @@ -131,7 +131,7 @@ GraphModel::add_arc(const SPtr& arc) assert(arc->head()->parent().get() == this || arc->head()->parent()->parent().get() == this); - SPtr existing = get_arc( + std::shared_ptr existing = get_arc( arc->tail().get(), arc->head().get()); if (existing) { diff --git a/src/client/ObjectModel.cpp b/src/client/ObjectModel.cpp index 78337270..00da2c62 100644 --- a/src/client/ObjectModel.cpp +++ b/src/client/ObjectModel.cpp @@ -81,7 +81,7 @@ ObjectModel::polyphonic() const * `o` as correct. The paths of the two models MUST be equal. */ void -ObjectModel::set(const SPtr& o) +ObjectModel::set(const std::shared_ptr& o) { assert(_path == o->path()); if (o->_parent) { @@ -104,7 +104,7 @@ ObjectModel::set_path(const Raul::Path& p) } void -ObjectModel::set_parent(const SPtr& p) +ObjectModel::set_parent(const std::shared_ptr& p) { assert(_path.is_child_of(p->path())); _parent = p; diff --git a/src/client/PluginModel.cpp b/src/client/PluginModel.cpp index b3a9aecd..d2347027 100644 --- a/src/client/PluginModel.cpp +++ b/src/client/PluginModel.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -153,7 +154,7 @@ PluginModel::get_property(const URI& key) const } void -PluginModel::set(const SPtr& p) +PluginModel::set(const std::shared_ptr& p) { _type = p->_type; @@ -241,8 +242,9 @@ PluginModel::has_ui() const return false; } -SPtr -PluginModel::ui(ingen::World& world, const SPtr& block) const +std::shared_ptr +PluginModel::ui(ingen::World& world, + const std::shared_ptr& block) const { if (!_lilv_plugin) { return nullptr; diff --git a/src/client/PluginUI.cpp b/src/client/PluginUI.cpp index b0f92e41..122c2af6 100644 --- a/src/client/PluginUI.cpp +++ b/src/client/PluginUI.cpp @@ -25,6 +25,7 @@ #include "lv2/ui/ui.h" #include +#include #include #include @@ -33,7 +34,7 @@ namespace client { SuilHost* PluginUI::ui_host = nullptr; -static SPtr +static std::shared_ptr get_port(PluginUI* ui, uint32_t port_index) { if (port_index >= ui->block()->ports().size()) { @@ -52,9 +53,9 @@ lv2_ui_write(SuilController controller, uint32_t format, const void* buffer) { - auto* const ui = static_cast(controller); - const URIs& uris = ui->world().uris(); - SPtr port = get_port(ui, port_index); + auto* const ui = static_cast(controller); + const URIs& uris = ui->world().uris(); + auto port = get_port(ui, port_index); if (!port) { return; } @@ -116,7 +117,7 @@ lv2_ui_subscribe(SuilController controller, const LV2_Feature* const* features) { auto* const ui = static_cast(controller); - SPtr port = get_port(ui, port_index); + std::shared_ptr port = get_port(ui, port_index); if (!port) { return 1; } @@ -136,8 +137,8 @@ lv2_ui_unsubscribe(SuilController controller, uint32_t protocol, const LV2_Feature* const* features) { - auto* const ui = static_cast(controller); - SPtr port = get_port(ui, port_index); + auto* const ui = static_cast(controller); + auto port = get_port(ui, port_index); if (!port) { return 1; } @@ -151,18 +152,18 @@ lv2_ui_unsubscribe(SuilController controller, return 0; } -PluginUI::PluginUI(ingen::World& world, - SPtr block, - LilvUIs* uis, - const LilvUI* ui, - const LilvNode* ui_type) - : _world(world) - , _block(std::move(block)) - , _instance(nullptr) - , _uis(uis) - , _ui(ui) - , _ui_node(lilv_node_duplicate(lilv_ui_get_uri(ui))) - , _ui_type(lilv_node_duplicate(ui_type)) +PluginUI::PluginUI(ingen::World& world, + std::shared_ptr block, + LilvUIs* uis, + const LilvUI* ui, + const LilvNode* ui_type) + : _world(world) + , _block(std::move(block)) + , _instance(nullptr) + , _uis(uis) + , _ui(ui) + , _ui_node(lilv_node_duplicate(lilv_ui_get_uri(ui))) + , _ui_type(lilv_node_duplicate(ui_type)) { } @@ -178,10 +179,10 @@ PluginUI::~PluginUI() lilv_world_unload_resource(_world.lilv_world(), lilv_ui_get_uri(_ui)); } -SPtr -PluginUI::create(ingen::World& world, - const SPtr& block, - const LilvPlugin* plugin) +std::shared_ptr +PluginUI::create(ingen::World& world, + const std::shared_ptr& block, + const LilvPlugin* plugin) { if (!PluginUI::ui_host) { PluginUI::ui_host = suil_host_new(lv2_ui_write, @@ -215,7 +216,7 @@ PluginUI::create(ingen::World& world, } // Create the PluginUI, but don't instantiate yet - SPtr ret(new PluginUI(world, block, uis, ui, ui_type)); + std::shared_ptr ret(new PluginUI(world, block, uis, ui, ui_type)); ret->_features = world.lv2_features().lv2_features( world, const_cast(block.get())); diff --git a/src/client/PortModel.cpp b/src/client/PortModel.cpp index fe9bef2c..d58a2b49 100644 --- a/src/client/PortModel.cpp +++ b/src/client/PortModel.cpp @@ -66,7 +66,7 @@ PortModel::is_uri() const } void -PortModel::set(const SPtr& model) +PortModel::set(const std::shared_ptr& model) { ObjectModel::set(model); -- cgit v1.2.1