From 9da45f53bdedff9ac9320a7a3c2ac1d5b9184ce2 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Sun, 10 Jun 2018 23:49:20 +0200 Subject: [PATCH] naming consistency (+snake_casing) Christian recently added get_filtered_actors(), which is a nice name. --- .../s4u-routing-get-clusters.cpp | 6 +++--- include/simgrid/s4u/Engine.hpp | 12 ++++++------ include/simgrid/s4u/NetZone.hpp | 11 ++++++++--- src/bindings/java/jmsg_as.cpp | 4 ++-- src/instr/instr_platform.cpp | 8 ++++---- src/s4u/s4u_Engine.cpp | 2 +- src/s4u/s4u_Netzone.cpp | 6 +++--- src/surf/sg_platf.cpp | 2 +- 8 files changed, 28 insertions(+), 23 deletions(-) diff --git a/examples/s4u/routing-get-clusters/s4u-routing-get-clusters.cpp b/examples/s4u/routing-get-clusters/s4u-routing-get-clusters.cpp index 21b583774f..1ae6c53577 100644 --- a/examples/s4u/routing-get-clusters/s4u-routing-get-clusters.cpp +++ b/examples/s4u/routing-get-clusters/s4u-routing-get-clusters.cpp @@ -15,7 +15,7 @@ int main(int argc, char* argv[]) e.load_platform(argv[1]); std::vector clusters = - e.filter_netzones_by_type(); + e.get_filtered_netzones(); for (auto c : clusters) { XBT_INFO("%s", c->get_cname()); @@ -25,12 +25,12 @@ int main(int argc, char* argv[]) } std::vector dragonfly_clusters = - e.filter_netzones_by_type(); + e.get_filtered_netzones(); if (not dragonfly_clusters.empty()) { for (auto d : dragonfly_clusters) { XBT_INFO("%s' dragonfly topology:", d->get_cname()); - for (int i = 0; i < d->getHostCount(); i++) { + for (int i = 0; i < d->get_host_count(); i++) { unsigned int coords[4]; d->rankId_to_coords(i, coords); XBT_INFO(" %d: (%u, %u, %u, %u)", i, coords[0], coords[1], coords[2], coords[3]); diff --git a/include/simgrid/s4u/Engine.hpp b/include/simgrid/s4u/Engine.hpp index 93b6531651..a0f10cf947 100644 --- a/include/simgrid/s4u/Engine.hpp +++ b/include/simgrid/s4u/Engine.hpp @@ -130,10 +130,10 @@ public: simgrid::s4u::NetZone* netzone_by_name_or_null(const char* name); /** @brief Retrieves all netzones of the type indicated by the template argument */ - template std::vector filter_netzones_by_type() + template std::vector get_filtered_netzones() { std::vector res; - filter_netzones_by_type_recursive(get_netzone_root(), &res); + get_filtered_netzones_recursive(get_netzone_root(), &res); return res; } @@ -242,7 +242,7 @@ public: XBT_ATTRIB_DEPRECATED_v323("Please use Engine::filter_netzones_by_type()") void getNetzoneByType( std::vector* whereto) { - filter_netzones_by_type_recursive(get_netzone_root(), whereto); + get_filtered_netzones_recursive(get_netzone_root(), whereto); } XBT_ATTRIB_DEPRECATED_v323("Please use Engine::get_instance()") static s4u::Engine* getInstance() @@ -273,10 +273,10 @@ extern XBT_PUBLIC xbt::signal on_time_advance; /** Callback fired when the time cannot jump because of inter-actors deadlock */ extern XBT_PUBLIC xbt::signal on_deadlock; -template XBT_PRIVATE void filter_netzones_by_type_recursive(s4u::NetZone* current, std::vector* whereto) +template XBT_PRIVATE void get_filtered_netzones_recursive(s4u::NetZone* current, std::vector* whereto) { - for (auto const& elem : *(current->getChildren())) { - filter_netzones_by_type_recursive(elem, whereto); + for (auto const& elem : *(current->get_children())) { + get_filtered_netzones_recursive(elem, whereto); if (elem == dynamic_cast(elem)) whereto->push_back(dynamic_cast(elem)); } diff --git a/include/simgrid/s4u/NetZone.hpp b/include/simgrid/s4u/NetZone.hpp index 4b485bb049..8eb0e8cb6e 100644 --- a/include/simgrid/s4u/NetZone.hpp +++ b/include/simgrid/s4u/NetZone.hpp @@ -37,12 +37,12 @@ public: const std::string& get_name() const { return name_; } /** @brief Retrieves the name of that netzone as a C string */ const char* get_cname() const; + NetZone* get_father(); + std::vector* get_children(); // Sub netzones std::vector get_all_hosts(); - - std::vector* getChildren(); // Sub netzones - int getHostCount(); + int get_host_count(); private: std::unordered_map properties_; @@ -126,8 +126,13 @@ public: // Deprecation wrappers { return get_vertices(); } + XBT_ATTRIB_DEPRECATED_v323("Please use NetZone::get_host_count()") int getHostCount() { return get_host_count(); } XBT_ATTRIB_DEPRECATED_v323("Please use NetZone::get_all_hosts()") void getHosts( std::vector* whereto); // retrieve my content as a vector of hosts + XBT_ATTRIB_DEPRECATED_v323("Please use NetZone::get_children()") std::vector* getChildren() + { + return get_children(); + } }; } }; // Namespace simgrid::s4u diff --git a/src/bindings/java/jmsg_as.cpp b/src/bindings/java/jmsg_as.cpp index 2bf2499b39..607f4a9363 100644 --- a/src/bindings/java/jmsg_as.cpp +++ b/src/bindings/java/jmsg_as.cpp @@ -69,14 +69,14 @@ JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_As_getSons(JNIEnv * env, job if (not cls) return nullptr; - jtable = env->NewObjectArray(static_cast(self_as->getChildren()->size()), cls, nullptr); + jtable = env->NewObjectArray(static_cast(self_as->get_children()->size()), cls, nullptr); if (not jtable) { jxbt_throw_jni(env, "Hosts table allocation failed"); return nullptr; } - for (auto const& tmp_as : *self_as->getChildren()) { + for (auto const& tmp_as : *self_as->get_children()) { jobject tmp_jas = jnetzone_new_instance(env); if (not tmp_jas) { jxbt_throw_jni(env, "java As instantiation failed"); diff --git a/src/instr/instr_platform.cpp b/src/instr/instr_platform.cpp index 6bf58f3e87..0184c25331 100644 --- a/src/instr/instr_platform.cpp +++ b/src/instr/instr_platform.cpp @@ -127,9 +127,9 @@ static void recursiveGraphExtraction(simgrid::s4u::NetZone* netzone, container_t return; } XBT_DEBUG("Graph extraction for NetZone = %s", netzone->get_cname()); - if (not netzone->getChildren()->empty()) { + if (not netzone->get_children()->empty()) { // bottom-up recursion - for (auto const& nz_son : *netzone->getChildren()) { + for (auto const& nz_son : *netzone->get_children()) { container_t child_container = container->children_.at(nz_son->get_cname()); recursiveGraphExtraction(nz_son, child_container, filter); } @@ -466,9 +466,9 @@ static void recursiveXBTGraphExtraction(xbt_graph_t graph, std::map* edges, sg_netzone_t netzone, container_t container) { - if (not netzone->getChildren()->empty()) { + if (not netzone->get_children()->empty()) { // bottom-up recursion - for (auto const& netzone_child : *netzone->getChildren()) { + for (auto const& netzone_child : *netzone->get_children()) { container_t child_container = container->children_.at(netzone_child->get_cname()); recursiveXBTGraphExtraction(graph, nodes, edges, netzone_child, child_container); } diff --git a/src/s4u/s4u_Engine.cpp b/src/s4u/s4u_Engine.cpp index eefc262007..ac01c07206 100644 --- a/src/s4u/s4u_Engine.cpp +++ b/src/s4u/s4u_Engine.cpp @@ -273,7 +273,7 @@ static s4u::NetZone* netzone_by_name_recursive(s4u::NetZone* current, const char if (not strcmp(current->get_cname(), name)) return current; - for (auto const& elem : *(current->getChildren())) { + for (auto const& elem : *(current->get_children())) { simgrid::s4u::NetZone* tmp = netzone_by_name_recursive(elem, name); if (tmp != nullptr) { return tmp; diff --git a/src/s4u/s4u_Netzone.cpp b/src/s4u/s4u_Netzone.cpp index a01bd946c5..d361ce0b65 100644 --- a/src/s4u/s4u_Netzone.cpp +++ b/src/s4u/s4u_Netzone.cpp @@ -57,7 +57,7 @@ void NetZone::set_property(const char* key, const char* value) * * This function returns the internal copy of the children, not a copy. Don't mess with it! */ -std::vector* NetZone::getChildren() +std::vector* NetZone::get_children() { return children_; } @@ -96,7 +96,7 @@ void NetZone::getHosts(std::vector* whereto) } } -int NetZone::getHostCount() +int NetZone::get_host_count() { int count = 0; for (auto const& card : vertices_) { @@ -142,7 +142,7 @@ sg_netzone_t sg_zone_get_by_name(const char* name) void sg_zone_get_sons(sg_netzone_t netzone, xbt_dict_t whereto) { - for (auto const& elem : *netzone->getChildren()) { + for (auto const& elem : *netzone->get_children()) { xbt_dict_set(whereto, elem->get_cname(), static_cast(elem), nullptr); } } diff --git a/src/surf/sg_platf.cpp b/src/surf/sg_platf.cpp index bf7afcc4c5..24def5ed79 100644 --- a/src/surf/sg_platf.cpp +++ b/src/surf/sg_platf.cpp @@ -606,7 +606,7 @@ simgrid::s4u::NetZone* sg_platf_new_Zone_begin(simgrid::kernel::routing::ZoneCre if (current_routing->hierarchy_ == simgrid::kernel::routing::NetZoneImpl::RoutingMode::unset) current_routing->hierarchy_ = simgrid::kernel::routing::NetZoneImpl::RoutingMode::recursive; /* add to the sons dictionary */ - current_routing->getChildren()->push_back(static_cast(new_zone)); + current_routing->get_children()->push_back(static_cast(new_zone)); } /* set the new current component of the tree */ -- 2.20.1