diff options
author | David Robillard <d@drobilla.net> | 2020-08-02 14:09:03 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2020-08-02 14:09:03 +0200 |
commit | 62f5c3124b991abe9b9423a4908ca076079d5327 (patch) | |
tree | 661304a2e5920c1c77f4ce61e4852cabdb250e5f /src/client | |
parent | 019eeff6a7d051427ad62a288f350e66471a0462 (diff) | |
download | ingen-62f5c3124b991abe9b9423a4908ca076079d5327.tar.gz ingen-62f5c3124b991abe9b9423a4908ca076079d5327.tar.bz2 ingen-62f5c3124b991abe9b9423a4908ca076079d5327.zip |
Use auto with pointer casts to remove redundancy
Diffstat (limited to 'src/client')
-rw-r--r-- | src/client/BlockModel.cpp | 6 | ||||
-rw-r--r-- | src/client/ClientStore.cpp | 24 | ||||
-rw-r--r-- | src/client/GraphModel.cpp | 12 | ||||
-rw-r--r-- | src/client/PortModel.cpp | 2 |
4 files changed, 22 insertions, 22 deletions
diff --git a/src/client/BlockModel.cpp b/src/client/BlockModel.cpp index a4318f4e..636b3a85 100644 --- a/src/client/BlockModel.cpp +++ b/src/client/BlockModel.cpp @@ -108,7 +108,7 @@ BlockModel::add_child(const SPtr<ObjectModel>& c) //ObjectModel::add_child(c); - SPtr<PortModel> pm = std::dynamic_pointer_cast<PortModel>(c); + auto pm = std::dynamic_pointer_cast<PortModel>(c); assert(pm); add_port(pm); } @@ -121,7 +121,7 @@ BlockModel::remove_child(const SPtr<ObjectModel>& c) //bool ret = ObjectModel::remove_child(c); - SPtr<PortModel> pm = std::dynamic_pointer_cast<PortModel>(c); + auto pm = std::dynamic_pointer_cast<PortModel>(c); assert(pm); remove_port(pm); @@ -275,7 +275,7 @@ BlockModel::port_label(const SPtr<const PortModel>& port) const void BlockModel::set(const SPtr<ObjectModel>& model) { - SPtr<BlockModel> block = std::dynamic_pointer_cast<BlockModel>(model); + auto block = std::dynamic_pointer_cast<BlockModel>(model); if (block) { _plugin_uri = block->_plugin_uri; _plugin = block->_plugin; diff --git a/src/client/ClientStore.cpp b/src/client/ClientStore.cpp index 1320de27..a02a3227 100644 --- a/src/client/ClientStore.cpp +++ b/src/client/ClientStore.cpp @@ -99,11 +99,11 @@ ClientStore::remove_object(const Raul::Path& path) return SPtr<ObjectModel>(); } - SPtr<ObjectModel> object = std::dynamic_pointer_cast<ObjectModel>(top->second); + auto object = std::dynamic_pointer_cast<ObjectModel>(top->second); // Remove object and any adjacent arcs from parent if applicable if (object && object->parent()) { - SPtr<PortModel> port = std::dynamic_pointer_cast<PortModel>(object); + auto port = std::dynamic_pointer_cast<PortModel>(object); if (port && std::dynamic_pointer_cast<GraphModel>(port->parent())) { disconnect_all(port->parent()->path(), path); if (port->parent()->parent()) { @@ -160,7 +160,7 @@ ClientStore::_object(const Raul::Path& path) if (i == end()) { return SPtr<ObjectModel>(); } else { - SPtr<ObjectModel> model = std::dynamic_pointer_cast<ObjectModel>(i->second); + auto model = std::dynamic_pointer_cast<ObjectModel>(i->second); assert(model); assert(model->path().is_root() || model->parent()); return model; @@ -290,7 +290,7 @@ ClientStore::operator()(const Put& msg) const Raul::Path path(uri_to_path(uri)); - SPtr<ObjectModel> obj = std::dynamic_pointer_cast<ObjectModel>(_object(path)); + auto obj = std::dynamic_pointer_cast<ObjectModel>(_object(path)); if (obj) { obj->set_properties(properties); return; @@ -437,8 +437,8 @@ bool ClientStore::attempt_connection(const Raul::Path& tail_path, const Raul::Path& head_path) { - SPtr<PortModel> tail = std::dynamic_pointer_cast<PortModel>(_object(tail_path)); - SPtr<PortModel> head = std::dynamic_pointer_cast<PortModel>(_object(head_path)); + auto tail = std::dynamic_pointer_cast<PortModel>(_object(tail_path)); + auto head = std::dynamic_pointer_cast<PortModel>(_object(head_path)); if (tail && head) { SPtr<GraphModel> graph = connection_graph(tail_path, head_path); @@ -460,9 +460,9 @@ ClientStore::operator()(const Connect& msg) void ClientStore::operator()(const Disconnect& msg) { - SPtr<PortModel> tail = std::dynamic_pointer_cast<PortModel>(_object(msg.tail)); - SPtr<PortModel> head = std::dynamic_pointer_cast<PortModel>(_object(msg.head)); - SPtr<GraphModel> graph = connection_graph(msg.tail, msg.head); + auto tail = std::dynamic_pointer_cast<PortModel>(_object(msg.tail)); + auto head = std::dynamic_pointer_cast<PortModel>(_object(msg.head)); + auto graph = connection_graph(msg.tail, msg.head); if (graph) { graph->remove_arc(tail.get(), head.get()); } @@ -471,8 +471,8 @@ ClientStore::operator()(const Disconnect& msg) void ClientStore::operator()(const DisconnectAll& msg) { - SPtr<GraphModel> graph = std::dynamic_pointer_cast<GraphModel>(_object(msg.graph)); - SPtr<ObjectModel> object = _object(msg.path); + auto graph = std::dynamic_pointer_cast<GraphModel>(_object(msg.graph)); + auto object = _object(msg.path); if (!graph || !object) { _log.error("Bad disconnect all notification %1% in %2%\n", @@ -482,7 +482,7 @@ ClientStore::operator()(const DisconnectAll& msg) const GraphModel::Arcs arcs = graph->arcs(); for (const auto& a : arcs) { - SPtr<ArcModel> arc = std::dynamic_pointer_cast<ArcModel>(a.second); + auto arc = std::dynamic_pointer_cast<ArcModel>(a.second); if (arc->tail()->parent() == object || arc->head()->parent() == object || arc->tail()->path() == msg.path diff --git a/src/client/GraphModel.cpp b/src/client/GraphModel.cpp index a2d50a20..4de2cb53 100644 --- a/src/client/GraphModel.cpp +++ b/src/client/GraphModel.cpp @@ -34,13 +34,13 @@ GraphModel::add_child(const SPtr<ObjectModel>& c) { assert(c->parent().get() == this); - SPtr<PortModel> pm = std::dynamic_pointer_cast<PortModel>(c); + auto pm = std::dynamic_pointer_cast<PortModel>(c); if (pm) { add_port(pm); return; } - SPtr<BlockModel> bm = std::dynamic_pointer_cast<BlockModel>(c); + auto bm = std::dynamic_pointer_cast<BlockModel>(c); if (bm) { _signal_new_block.emit(bm); } @@ -52,13 +52,13 @@ GraphModel::remove_child(const SPtr<ObjectModel>& o) assert(o->path().is_child_of(path())); assert(o->parent().get() == this); - SPtr<PortModel> pm = std::dynamic_pointer_cast<PortModel>(o); + auto pm = std::dynamic_pointer_cast<PortModel>(o); if (pm) { remove_arcs_on(pm); remove_port(pm); } - SPtr<BlockModel> bm = std::dynamic_pointer_cast<BlockModel>(o); + auto bm = std::dynamic_pointer_cast<BlockModel>(o); if (bm) { _signal_removed_block.emit(bm); } @@ -75,7 +75,7 @@ GraphModel::remove_arcs_on(const SPtr<PortModel>& p) auto next = j; ++next; - SPtr<ArcModel> arc = std::dynamic_pointer_cast<ArcModel>(j->second); + auto arc = std::dynamic_pointer_cast<ArcModel>(j->second); if (arc->tail_path().parent() == p->path() || arc->tail_path() == p->path() || arc->head_path().parent() == p->path() @@ -149,7 +149,7 @@ GraphModel::remove_arc(const Node* tail, const Node* head) { auto i = _arcs.find(std::make_pair(tail, head)); if (i != _arcs.end()) { - SPtr<ArcModel> arc = std::dynamic_pointer_cast<ArcModel>(i->second); + auto arc = std::dynamic_pointer_cast<ArcModel>(i->second); _signal_removed_arc.emit(arc); _arcs.erase(i); } diff --git a/src/client/PortModel.cpp b/src/client/PortModel.cpp index b3562f77..fe9bef2c 100644 --- a/src/client/PortModel.cpp +++ b/src/client/PortModel.cpp @@ -70,7 +70,7 @@ PortModel::set(const SPtr<ObjectModel>& model) { ObjectModel::set(model); - SPtr<PortModel> port = std::dynamic_pointer_cast<PortModel>(model); + auto port = std::dynamic_pointer_cast<PortModel>(model); if (port) { _index = port->_index; _direction = port->_direction; |