From: Frederic Suter Date: Thu, 20 Jul 2017 08:24:08 +0000 (+0200) Subject: try to please sonar and avoid protected fields X-Git-Tag: v3_17~358 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/288deb04fbcfc6a916717e31e8009d209d3314cf try to please sonar and avoid protected fields --- diff --git a/include/simgrid/s4u/NetZone.hpp b/include/simgrid/s4u/NetZone.hpp index cb9d1ee3c9..fa5ca046e4 100644 --- a/include/simgrid/s4u/NetZone.hpp +++ b/include/simgrid/s4u/NetZone.hpp @@ -71,10 +71,13 @@ public: static simgrid::xbt::signal onSeal; protected: - std::vector - vertices_; // our content, as known to our graph routing algorithm (maps vertexId -> vertex) + unsigned int getTableSize() { return vertices_.size(); } + std::vector getVertices() { return vertices_; } private: + // our content, as known to our graph routing algorithm (maps vertexId -> vertex) + std::vector vertices_; + std::unordered_map properties_; NetZone* father_ = nullptr; char* name_ = nullptr; diff --git a/src/kernel/routing/ClusterZone.cpp b/src/kernel/routing/ClusterZone.cpp index 73ab218e53..1a191c8b6a 100644 --- a/src/kernel/routing/ClusterZone.cpp +++ b/src/kernel/routing/ClusterZone.cpp @@ -88,7 +88,7 @@ void ClusterZone::getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges new_xbt_graph_edge(graph, routerNode, backboneNode, edges); } - for (auto src : vertices_) { + for (auto src : getVertices()) { if (not src->isRouter()) { xbt_node_t previous = new_xbt_graph_node(graph, src->cname(), nodes); diff --git a/src/kernel/routing/FloydZone.cpp b/src/kernel/routing/FloydZone.cpp index 894aa18b7f..457b0e1ad5 100644 --- a/src/kernel/routing/FloydZone.cpp +++ b/src/kernel/routing/FloydZone.cpp @@ -32,10 +32,10 @@ FloydZone::~FloydZone() { if (linkTable_ == nullptr) // Dealing with a parse error in the file? return; - int table_size = vertices_.size(); + unsigned int table_size = getTableSize(); /* Delete link_table */ - for (int i = 0; i < table_size; i++) - for (int j = 0; j < table_size; j++) + for (unsigned int i = 0; i < table_size; i++) + for (unsigned int j = 0; j < table_size; j++) routing_route_free(TO_FLOYD_LINK(i, j)); xbt_free(linkTable_); @@ -45,7 +45,7 @@ FloydZone::~FloydZone() void FloydZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cbarg_t route, double* lat) { - size_t table_size = vertices_.size(); + unsigned int table_size = getTableSize(); getRouteCheckParams(src, dst); @@ -87,7 +87,7 @@ void FloydZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cbarg void FloydZone::addRoute(sg_platf_route_cbarg_t route) { /* set the size of table routing */ - int table_size = static_cast(vertices_.size()); + unsigned int table_size = getTableSize(); addRouteCheckParams(route); @@ -98,8 +98,8 @@ void FloydZone::addRoute(sg_platf_route_cbarg_t route) linkTable_ = xbt_new0(sg_platf_route_cbarg_t, table_size * table_size); /* actual link between src and dst */ /* Initialize costs and predecessors */ - for (int i = 0; i < table_size; i++) - for (int j = 0; j < table_size; j++) { + for (unsigned int i = 0; i < table_size; i++) + for (unsigned int j = 0; j < table_size; j++) { TO_FLOYD_COST(i, j) = DBL_MAX; TO_FLOYD_PRED(i, j) = -1; TO_FLOYD_LINK(i, j) = nullptr; @@ -156,7 +156,7 @@ void FloydZone::addRoute(sg_platf_route_cbarg_t route) void FloydZone::seal() { /* set the size of table routing */ - size_t table_size = vertices_.size(); + unsigned int table_size = getTableSize(); if (not linkTable_) { /* Create Cost, Predecessor and Link tables */ diff --git a/src/kernel/routing/FullZone.cpp b/src/kernel/routing/FullZone.cpp index 89cdec6a49..7f6a98e169 100644 --- a/src/kernel/routing/FullZone.cpp +++ b/src/kernel/routing/FullZone.cpp @@ -20,7 +20,7 @@ FullZone::FullZone(NetZone* father, const char* name) : RoutedZone(father, name) void FullZone::seal() { - int table_size = static_cast(vertices_.size()); + unsigned int table_size = getTableSize(); /* Create table if needed */ if (not routingTable_) @@ -28,7 +28,7 @@ void FullZone::seal() /* Add the loopback if needed */ if (surf_network_model->loopback_ && hierarchy_ == RoutingMode::base) { - for (int i = 0; i < table_size; i++) { + for (unsigned int i = 0; i < table_size; i++) { sg_platf_route_cbarg_t e_route = TO_ROUTE_FULL(i, i); if (not e_route) { e_route = xbt_new0(s_sg_platf_route_cbarg_t, 1); @@ -45,10 +45,10 @@ void FullZone::seal() FullZone::~FullZone() { if (routingTable_) { - int table_size = static_cast(vertices_.size()); + unsigned int table_size = getTableSize(); /* Delete routing table */ - for (int i = 0; i < table_size; i++) - for (int j = 0; j < table_size; j++) { + for (unsigned int i = 0; i < table_size; i++) + for (unsigned int j = 0; j < table_size; j++) { if (TO_ROUTE_FULL(i, j)) { delete TO_ROUTE_FULL(i, j)->link_list; xbt_free(TO_ROUTE_FULL(i, j)); @@ -62,7 +62,7 @@ void FullZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cbarg_ { XBT_DEBUG("full getLocalRoute from %s[%d] to %s[%d]", src->cname(), src->id(), dst->cname(), dst->id()); - size_t table_size = vertices_.size(); + unsigned int table_size = getTableSize(); sg_platf_route_cbarg_t e_route = TO_ROUTE_FULL(src->id(), dst->id()); if (e_route != nullptr) { @@ -82,7 +82,7 @@ void FullZone::addRoute(sg_platf_route_cbarg_t route) NetPoint* dst = route->dst; addRouteCheckParams(route); - size_t table_size = vertices_.size(); + unsigned int table_size = getTableSize(); if (not routingTable_) routingTable_ = xbt_new0(sg_platf_route_cbarg_t, table_size * table_size); diff --git a/src/kernel/routing/RoutedZone.cpp b/src/kernel/routing/RoutedZone.cpp index d947b4a2b4..35f44d8955 100644 --- a/src/kernel/routing/RoutedZone.cpp +++ b/src/kernel/routing/RoutedZone.cpp @@ -72,8 +72,10 @@ RoutedZone::RoutedZone(NetZone* father, const char* name) : NetZoneImpl(father, void RoutedZone::getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges) { - for (auto my_src : vertices_) { - for (auto my_dst : vertices_) { + std::vector vertices = getVertices(); + + for (auto my_src : vertices) { + for (auto my_dst : vertices) { if (my_src == my_dst) continue;