Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
make As->father_ protected
authorMartin Quinson <martin.quinson@loria.fr>
Fri, 14 Oct 2016 22:20:12 +0000 (00:20 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Fri, 14 Oct 2016 22:21:20 +0000 (00:21 +0200)
25 files changed:
include/simgrid/s4u/As.hpp
src/kernel/routing/AsCluster.cpp
src/kernel/routing/AsCluster.hpp
src/kernel/routing/AsClusterDragonfly.cpp
src/kernel/routing/AsClusterDragonfly.hpp
src/kernel/routing/AsClusterFatTree.cpp
src/kernel/routing/AsClusterFatTree.hpp
src/kernel/routing/AsClusterTorus.cpp
src/kernel/routing/AsClusterTorus.hpp
src/kernel/routing/AsDijkstra.cpp
src/kernel/routing/AsDijkstra.hpp
src/kernel/routing/AsFloyd.cpp
src/kernel/routing/AsFloyd.hpp
src/kernel/routing/AsFull.cpp
src/kernel/routing/AsFull.hpp
src/kernel/routing/AsImpl.cpp
src/kernel/routing/AsImpl.hpp
src/kernel/routing/AsNone.cpp
src/kernel/routing/AsNone.hpp
src/kernel/routing/AsRoutedGraph.cpp
src/kernel/routing/AsRoutedGraph.hpp
src/kernel/routing/AsVivaldi.cpp
src/kernel/routing/AsVivaldi.hpp
src/s4u/s4u_as.cpp
src/surf/sg_platf.cpp

index 7de5a36..6758f4e 100644 (file)
@@ -40,7 +40,7 @@ XBT_PUBLIC_CLASS As {
 protected:
   friend simgrid::kernel::routing::AsImpl;
 
-  explicit As(const char *name);
+  explicit As(As * father, const char* name);
   virtual ~As();
   
 public:
@@ -49,9 +49,8 @@ public:
   char *name();
   As *father();;
   xbt_dict_t children(); // Sub AS
-  xbt_dynar_t hosts();   // my content
+  xbt_dynar_t hosts();   // my content as a dynar
 
-  As *father_ = nullptr; // FIXME: hide me
 public:
   /* Add content to the AS, at parsing time. It should be sealed afterward. */
   virtual int addComponent(kernel::routing::NetCard *elm); /* A host, a router or an AS, whatever */
@@ -59,6 +58,7 @@ public:
   void addBypassRoute(sg_platf_route_cbarg_t e_route);
 
 protected:
+  As* father_          = nullptr;
   char *name_ = nullptr;
   xbt_dict_t children_ = xbt_dict_new_homogeneous(nullptr); // sub-ASes
   std::vector<kernel::routing::NetCard*> vertices_; // our content, as known to our graph routing algorithm (maps vertexId -> vertex)
index 011725a..339ae8e 100644 (file)
@@ -14,10 +14,10 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_cluster, surf, "Routing part of surf"
 namespace simgrid {
 namespace kernel {
 namespace routing {
-  AsCluster::AsCluster(const char*name)
-    : AsImpl(name)
-  {}
-  AsCluster::~AsCluster()=default;
+AsCluster::AsCluster(As* father, const char* name) : AsImpl(father, name)
+{
+}
+AsCluster::~AsCluster() = default;
 
 void AsCluster::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg_t route, double *lat)
 {
index 082333e..4526849 100644 (file)
@@ -16,7 +16,7 @@ namespace routing {
 
 class XBT_PRIVATE AsCluster: public AsImpl {
 public:
-  explicit AsCluster(const char*name);
+  explicit AsCluster(As* father, const char* name);
   ~AsCluster() override;
 
   void getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg_t into, double *latency) override;
index cfdb63a..bd992f6 100644 (file)
@@ -16,8 +16,8 @@ namespace simgrid {
 namespace kernel {
 namespace routing {
 
-AsClusterDragonfly::AsClusterDragonfly(const char*name)
-  : AsCluster(name) {
+AsClusterDragonfly::AsClusterDragonfly(As* father, const char* name) : AsCluster(father, name)
+{
 }
 
 AsClusterDragonfly::~AsClusterDragonfly() {
index e0ed5a6..4f58c53 100644 (file)
@@ -63,7 +63,7 @@ class XBT_PRIVATE DragonflyRouter {
 class XBT_PRIVATE AsClusterDragonfly
   : public AsCluster {
     public:
-      explicit AsClusterDragonfly(const char*name);
+      explicit AsClusterDragonfly(As* father, const char* name);
       ~AsClusterDragonfly() override;
 //      void create_links_for_node(sg_platf_cluster_cbarg_t cluster, int id, int rank, int position) override;
       void getRouteAndLatency(NetCard * src, NetCard * dst, sg_platf_route_cbarg_t into, double *latency) override;
index c5b518f..d9a5b3b 100644 (file)
@@ -23,8 +23,7 @@ namespace simgrid {
 namespace kernel {
 namespace routing {
 
-AsClusterFatTree::AsClusterFatTree(const char*name)
-  : AsCluster(name)
+AsClusterFatTree::AsClusterFatTree(As* father, const char* name) : AsCluster(father, name)
 {
   XBT_DEBUG("Creating a new fat tree.");
 }
index bff2627..9898e5b 100644 (file)
@@ -102,7 +102,7 @@ public:
  */
 class XBT_PRIVATE AsClusterFatTree : public AsCluster {
 public:
-  explicit AsClusterFatTree(const char*name);
+  explicit AsClusterFatTree(As* father, const char* name);
   ~AsClusterFatTree() override;
   void getRouteAndLatency(NetCard *src, NetCard *dst,
                                   sg_platf_route_cbarg_t into,
index d38511f..23c66c2 100644 (file)
@@ -27,8 +27,8 @@ inline unsigned int *rankId_to_coords(int rankId, xbt_dynar_t dimensions)
 namespace simgrid {
   namespace kernel {
   namespace routing {
-    AsClusterTorus::AsClusterTorus(const char*name)
-      : AsCluster(name) {
+  AsClusterTorus::AsClusterTorus(As* father, const char* name) : AsCluster(father, name)
+  {
     }
     AsClusterTorus::~AsClusterTorus() {
       xbt_dynar_free(&dimensions_);
index 1e4f264..b5b9aa4 100644 (file)
@@ -14,7 +14,7 @@ namespace routing {
 
     class XBT_PRIVATE AsClusterTorus : public AsCluster {
     public:
-      explicit AsClusterTorus(const char*name);
+      explicit AsClusterTorus(As* father, const char* name);
       ~AsClusterTorus() override;
       void create_links_for_node(sg_platf_cluster_cbarg_t cluster, int id, int rank, int position) override;
       void getRouteAndLatency(NetCard * src, NetCard * dst, sg_platf_route_cbarg_t into, double *latency) override;
index 29f4524..e813722 100644 (file)
@@ -306,8 +306,7 @@ AsDijkstra::~AsDijkstra()
 
 /* Creation routing model functions */
 
-AsDijkstra::AsDijkstra(const char*name, bool cached)
-  : AsRoutedGraph(name)
+AsDijkstra::AsDijkstra(As* father, const char* name, bool cached) : AsRoutedGraph(father, name)
 {
   if (cached)
     routeCache_ = xbt_dict_new_homogeneous(&route_cache_elem_free);
index 5dada5a..ea33413 100644 (file)
@@ -33,7 +33,7 @@ namespace routing {
 /** Dijkstra routing data: fast initialization, slow lookup, small memory requirements, shortest path routing only */
 class XBT_PRIVATE AsDijkstra : public AsRoutedGraph {
 public:
-  AsDijkstra(const char*name, bool cached);
+  AsDijkstra(As* father, const char* name, bool cached);
   void seal() override;
 
   ~AsDijkstra() override;
index f92328c..4fc153b 100644 (file)
@@ -19,8 +19,7 @@ namespace simgrid {
 namespace kernel {
 namespace routing {
 
-AsFloyd::AsFloyd(const char*name)
-  : AsRoutedGraph(name)
+AsFloyd::AsFloyd(As* father, const char* name) : AsRoutedGraph(father, name)
 {
   predecessorTable_ = nullptr;
   costTable_ = nullptr;
index c4327ff..c507f81 100644 (file)
@@ -15,7 +15,7 @@ namespace routing {
 /** Floyd routing data: slow initialization, fast lookup, lesser memory requirements, shortest path routing only */
 class XBT_PRIVATE AsFloyd: public AsRoutedGraph {
 public:
-  explicit AsFloyd(const char *name);
+  explicit AsFloyd(As* father, const char* name);
   ~AsFloyd() override;
 
   void getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg_t into, double *latency) override;
index 0b5807e..ac5bf96 100644 (file)
@@ -13,9 +13,8 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_full, surf, "Routing part of surf");
 namespace simgrid {
 namespace kernel {
 namespace routing {
-  AsFull::AsFull(const char*name)
-    : AsRoutedGraph(name)
-  {
+AsFull::AsFull(As* father, const char* name) : AsRoutedGraph(father, name)
+{
   }
 
 void AsFull::seal() {
index 66ca294..0bd7571 100644 (file)
@@ -15,8 +15,7 @@ namespace routing {
 /** Full routing: fast, large memory requirements, fully expressive */
 class XBT_PRIVATE AsFull: public AsRoutedGraph {
 public:
-
-  explicit AsFull(const char*name);
+  explicit AsFull(As* father, const char* name);
   void seal() override;
   ~AsFull() override;
 
index c6ab319..e4eb103 100644 (file)
@@ -14,11 +14,14 @@ namespace simgrid {
   namespace kernel {
   namespace routing {
 
-    AsImpl::AsImpl(const char *name) : As(name) { }
-    AsImpl::~AsImpl() = default;
-
-    xbt_dynar_t AsImpl::getOneLinkRoutes() {
-      return nullptr;
+  AsImpl::AsImpl(As* father, const char* name) : As(father, name)
+  {
+  }
+  AsImpl::~AsImpl() = default;
+
+  xbt_dynar_t AsImpl::getOneLinkRoutes()
+  {
+    return nullptr;
     }
 
     /** @brief Get the common ancestor and its first childs in each line leading to src and dst */
index 374b711..e202ca4 100644 (file)
@@ -26,7 +26,7 @@ namespace routing {
 XBT_PUBLIC_CLASS AsImpl : public s4u::As {
   friend simgrid::kernel::routing::RoutingPlatf;
 protected:
-  explicit AsImpl(const char *name);
+  explicit AsImpl(As * father, const char* name);
   ~AsImpl() override;
   
 public:
index f634393..66c5097 100644 (file)
@@ -15,8 +15,7 @@ namespace simgrid {
 namespace kernel {
 namespace routing {
 
-AsNone::AsNone(const char*name)
-  : AsImpl(name)
+AsNone::AsNone(As* father, const char* name) : AsImpl(father, name)
 {}
 
 AsNone::~AsNone()
index 391050c..de11e29 100644 (file)
@@ -15,7 +15,7 @@ namespace routing {
 /** No specific routing. Mainly useful with the constant network model */
 class XBT_PRIVATE AsNone : public AsImpl {
 public:
-  explicit AsNone(const char*name);
+  explicit AsNone(As* father, const char* name);
   ~AsNone() override;
 
   void getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg_t into, double *latency) override;
index db43c0c..c25a516 100644 (file)
@@ -25,9 +25,8 @@ void routing_route_free(sg_platf_route_cbarg_t route)
 namespace simgrid {
 namespace kernel {
 namespace routing {
-  
-AsRoutedGraph::AsRoutedGraph(const char*name)
-  : AsImpl(name)
+
+AsRoutedGraph::AsRoutedGraph(As* father, const char* name) : AsImpl(father, name)
 {
 }
 
index 1b5bfa4..9990166 100644 (file)
@@ -14,7 +14,7 @@ namespace routing {
 
 class XBT_PRIVATE AsRoutedGraph : public AsImpl {
 public:
-  explicit AsRoutedGraph(const char*name);
+  explicit AsRoutedGraph(As* father, const char* name);
   ~AsRoutedGraph() override;
 
   xbt_dynar_t getOneLinkRoutes() override;
index 007a453..a17352e 100644 (file)
@@ -48,8 +48,7 @@ namespace routing {
 
     return res;
   }
-  AsVivaldi::AsVivaldi(const char *name)
-    : AsCluster(name)
+  AsVivaldi::AsVivaldi(As* father, const char* name) : AsCluster(father, name)
   {}
 
 AsVivaldi::~AsVivaldi() {}
index 5667ddb..a1016f3 100644 (file)
@@ -15,7 +15,7 @@ namespace routing {
 /* This derivates from cluster because each host has a private link */
 class XBT_PRIVATE AsVivaldi: public AsCluster {
 public:
-  explicit AsVivaldi(const char *name);
+  explicit AsVivaldi(As* father, const char* name);
   ~AsVivaldi() override;
 
   xbt_dynar_t getOneLinkRoutes() override {return nullptr;};
index 685cefc..a86951c 100644 (file)
@@ -17,9 +17,8 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_as,"S4U autonomous systems");
 namespace simgrid {
   namespace s4u {
 
-    As::As(const char *name)
-    : name_(xbt_strdup(name))
-    {
+  As::As(As* father, const char* name) : father_(father), name_(xbt_strdup(name))
+  {
     }
     void As::seal()
     {
index a1ff3b1..65e6254 100644 (file)
@@ -821,16 +821,36 @@ simgrid::s4u::As * sg_platf_new_AS_begin(sg_platf_AS_cbarg_t AS)
   /* search the routing model */
   simgrid::kernel::routing::AsImpl *new_as = nullptr;
   switch(AS->routing){
-    case A_surfxml_AS_routing_Cluster:        new_as = new simgrid::kernel::routing::AsCluster(AS->id);        break;
-    case A_surfxml_AS_routing_ClusterDragonfly:   new_as = new simgrid::kernel::routing::AsClusterDragonfly(AS->id);   break;
-    case A_surfxml_AS_routing_ClusterTorus:   new_as = new simgrid::kernel::routing::AsClusterTorus(AS->id);   break;
-    case A_surfxml_AS_routing_ClusterFatTree: new_as = new simgrid::kernel::routing::AsClusterFatTree(AS->id); break;
-    case A_surfxml_AS_routing_Dijkstra:       new_as = new simgrid::kernel::routing::AsDijkstra(AS->id, 0);    break;
-    case A_surfxml_AS_routing_DijkstraCache:  new_as = new simgrid::kernel::routing::AsDijkstra(AS->id, 1);    break;
-    case A_surfxml_AS_routing_Floyd:          new_as = new simgrid::kernel::routing::AsFloyd(AS->id);          break;
-    case A_surfxml_AS_routing_Full:           new_as = new simgrid::kernel::routing::AsFull(AS->id);           break;
-    case A_surfxml_AS_routing_None:           new_as = new simgrid::kernel::routing::AsNone(AS->id);           break;
-    case A_surfxml_AS_routing_Vivaldi:        new_as = new simgrid::kernel::routing::AsVivaldi(AS->id);        break;
+    case A_surfxml_AS_routing_Cluster:
+      new_as = new simgrid::kernel::routing::AsCluster(current_routing, AS->id);
+      break;
+    case A_surfxml_AS_routing_ClusterDragonfly:
+      new_as = new simgrid::kernel::routing::AsClusterDragonfly(current_routing, AS->id);
+      break;
+    case A_surfxml_AS_routing_ClusterTorus:
+      new_as = new simgrid::kernel::routing::AsClusterTorus(current_routing, AS->id);
+      break;
+    case A_surfxml_AS_routing_ClusterFatTree:
+      new_as = new simgrid::kernel::routing::AsClusterFatTree(current_routing, AS->id);
+      break;
+    case A_surfxml_AS_routing_Dijkstra:
+      new_as = new simgrid::kernel::routing::AsDijkstra(current_routing, AS->id, 0);
+      break;
+    case A_surfxml_AS_routing_DijkstraCache:
+      new_as = new simgrid::kernel::routing::AsDijkstra(current_routing, AS->id, 1);
+      break;
+    case A_surfxml_AS_routing_Floyd:
+      new_as = new simgrid::kernel::routing::AsFloyd(current_routing, AS->id);
+      break;
+    case A_surfxml_AS_routing_Full:
+      new_as = new simgrid::kernel::routing::AsFull(current_routing, AS->id);
+      break;
+    case A_surfxml_AS_routing_None:
+      new_as = new simgrid::kernel::routing::AsNone(current_routing, AS->id);
+      break;
+    case A_surfxml_AS_routing_Vivaldi:
+      new_as = new simgrid::kernel::routing::AsVivaldi(current_routing, AS->id);
+      break;
     default:                                  xbt_die("Not a valid model!");                        break;
   }
 
@@ -841,10 +861,7 @@ simgrid::s4u::As * sg_platf_new_AS_begin(sg_platf_AS_cbarg_t AS)
     routing_platf->root_ = new_as;
   } else if (current_routing != nullptr && routing_platf->root_ != nullptr) {
 
-    xbt_assert(!xbt_dict_get_or_null(current_routing->children(), AS->id),
-               "The AS \"%s\" already exists", AS->id);
-    /* it is a part of the tree */
-    new_as->father_ = current_routing;
+    xbt_assert(!xbt_dict_get_or_null(current_routing->children(), AS->id), "The AS '%s' already exists", AS->id);
     /* set the father behavior */
     if (current_routing->hierarchy_ == simgrid::kernel::routing::AsImpl::RoutingMode::unset)
       current_routing->hierarchy_ = simgrid::kernel::routing::AsImpl::RoutingMode::recursive;