Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
try to please sonar and avoid protected fields
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Thu, 20 Jul 2017 08:24:08 +0000 (10:24 +0200)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Thu, 20 Jul 2017 08:24:08 +0000 (10:24 +0200)
include/simgrid/s4u/NetZone.hpp
src/kernel/routing/ClusterZone.cpp
src/kernel/routing/FloydZone.cpp
src/kernel/routing/FullZone.cpp
src/kernel/routing/RoutedZone.cpp

index cb9d1ee..fa5ca04 100644 (file)
@@ -71,10 +71,13 @@ public:
   static simgrid::xbt::signal<void(NetZone&)> onSeal;
 
 protected:
-  std::vector<kernel::routing::NetPoint*>
-      vertices_; // our content, as known to our graph routing algorithm (maps vertexId -> vertex)
+  unsigned int getTableSize() { return vertices_.size(); }
+  std::vector<kernel::routing::NetPoint*> getVertices() { return vertices_; }
 
 private:
+  // our content, as known to our graph routing algorithm (maps vertexId -> vertex)
+  std::vector<kernel::routing::NetPoint*> vertices_;
+
   std::unordered_map<std::string, std::string> properties_;
   NetZone* father_ = nullptr;
   char* name_      = nullptr;
index 73ab218..1a191c8 100644 (file)
@@ -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);
 
index 894aa18..457b0e1 100644 (file)
@@ -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<int>(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 */
index 89cdec6..7f6a98e 100644 (file)
@@ -20,7 +20,7 @@ FullZone::FullZone(NetZone* father, const char* name) : RoutedZone(father, name)
 
 void FullZone::seal()
 {
-  int table_size = static_cast<int>(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<int>(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);
index d947b4a..35f44d8 100644 (file)
@@ -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<kernel::routing::NetPoint*> vertices = getVertices();
+
+  for (auto my_src : vertices) {
+    for (auto my_dst : vertices) {
       if (my_src == my_dst)
         continue;