Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Routing: kill some dupplicated code
[simgrid.git] / src / surf / surf_routing_generic.cpp
index fb94ab5..d332952 100644 (file)
@@ -24,7 +24,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_routing_generic, surf_route, "Generic imple
 
 static int no_bypassroute_declared = 1;
 
-void generic_free_route(sg_platf_route_cbarg_t route)
+void routing_route_free(sg_platf_route_cbarg_t route)
 {
   if (route) {
     xbt_dynar_free(&route->link_list);
@@ -47,26 +47,15 @@ void AsGeneric::getRouteAndLatency(NetCard */*src*/, NetCard */*dst*/, sg_platf_
   THROW_IMPOSSIBLE;
 }
 
-AsGeneric::AsGeneric() {
-  p_bypassRoutes = xbt_dict_new_homogeneous((void (*)(void *)) generic_free_route);
-}
-
-AsGeneric::~AsGeneric() {
-  xbt_dict_free(&p_bypassRoutes);
-}
-
-int AsGeneric::parsePU(NetCard *elm)
+AsGeneric::AsGeneric(const char*name)
+  : AsNone(name)
 {
-  XBT_DEBUG("Load process unit \"%s\"", elm->getName());
-  xbt_dynar_push_as(p_indexNetworkElm, NetCard*, elm);
-  return xbt_dynar_length(p_indexNetworkElm)-1;
+  bypassRoutes_ = xbt_dict_new_homogeneous((void (*)(void *)) routing_route_free);
 }
 
-int AsGeneric::parseAS(NetCard *elm)
+AsGeneric::~AsGeneric()
 {
-  XBT_DEBUG("Load Autonomous system \"%s\"", elm->getName());
-  xbt_dynar_push_as(p_indexNetworkElm, NetCard*, elm);
-  return xbt_dynar_length(p_indexNetworkElm)-1;
+  xbt_dict_free(&bypassRoutes_);
 }
 
 void AsGeneric::parseBypassroute(sg_platf_route_cbarg_t e_route)
@@ -78,7 +67,7 @@ void AsGeneric::parseBypassroute(sg_platf_route_cbarg_t e_route)
     XBT_DEBUG("Load bypassASroute from \"%s\" to \"%s\"", src, dst);
   else
     XBT_DEBUG("Load bypassRoute from \"%s\" to \"%s\"", src, dst);
-  xbt_dict_t dict_bypassRoutes = p_bypassRoutes;
+  xbt_dict_t dict_bypassRoutes = bypassRoutes_;
   char *route_name;
 
   route_name = bprintf("%s#%s", src, dst);
@@ -229,7 +218,7 @@ sg_platf_route_cbarg_t AsGeneric::getBypassRoute(NetCard *src,
     return NULL;
 
   sg_platf_route_cbarg_t e_route_bypass = NULL;
-  xbt_dict_t dict_bypassRoutes = p_bypassRoutes;
+  xbt_dict_t dict_bypassRoutes = bypassRoutes_;
 
   if(dst->getRcComponent() == this && src->getRcComponent() == this ){
     char *route_name = bprintf("%s#%s", src->getName(), dst->getName());
@@ -250,7 +239,7 @@ sg_platf_route_cbarg_t AsGeneric::getBypassRoute(NetCard *src,
     if (src == NULL || dst == NULL)
       xbt_die("Ask for route \"from\"(%s) or \"to\"(%s) no found at AS \"%s\"",
               src ? src->getName() : "(null)",
-              dst ? dst->getName() : "(null)", p_name);
+              dst ? dst->getName() : "(null)", name_);
 
     src_as = src->getRcComponent();
     dst_as = dst->getRcComponent();
@@ -260,13 +249,13 @@ sg_platf_route_cbarg_t AsGeneric::getBypassRoute(NetCard *src,
     current = src_as;
     while (current != NULL) {
       xbt_dynar_push(path_src, &current);
-      current = current->p_routingFather;
+      current = current->father_;
     }
     path_dst = xbt_dynar_new(sizeof(As*), NULL);
     current = dst_as;
     while (current != NULL) {
       xbt_dynar_push(path_dst, &current);
-      current = current->p_routingFather;
+      current = current->father_;
     }
 
     /* (3) find the common father */
@@ -294,9 +283,9 @@ sg_platf_route_cbarg_t AsGeneric::getBypassRoute(NetCard *src,
         if (i <= max_index_src && max <= max_index_dst) {
           char *route_name = bprintf("%s#%s",
               (*(As **)
-                  (xbt_dynar_get_ptr(path_src, i)))->p_name,
+                  (xbt_dynar_get_ptr(path_src, i)))->name_,
                   (*(As **)
-                      (xbt_dynar_get_ptr(path_dst, max)))->p_name);
+                      (xbt_dynar_get_ptr(path_dst, max)))->name_);
           e_route_bypass = (sg_platf_route_cbarg_t) xbt_dict_get_or_null(dict_bypassRoutes, route_name);
           xbt_free(route_name);
         }
@@ -305,9 +294,9 @@ sg_platf_route_cbarg_t AsGeneric::getBypassRoute(NetCard *src,
         if (max <= max_index_src && i <= max_index_dst) {
           char *route_name = bprintf("%s#%s",
               (*(As **)
-                  (xbt_dynar_get_ptr(path_src, max)))->p_name,
+                  (xbt_dynar_get_ptr(path_src, max)))->name_,
                   (*(As **)
-                      (xbt_dynar_get_ptr(path_dst, i)))->p_name);
+                      (xbt_dynar_get_ptr(path_dst, i)))->name_);
           e_route_bypass = (sg_platf_route_cbarg_t) xbt_dict_get_or_null(dict_bypassRoutes, route_name);
           xbt_free(route_name);
         }
@@ -321,9 +310,9 @@ sg_platf_route_cbarg_t AsGeneric::getBypassRoute(NetCard *src,
       if (max <= max_index_src && max <= max_index_dst) {
         char *route_name = bprintf("%s#%s",
             (*(As **)
-                (xbt_dynar_get_ptr(path_src, max)))->p_name,
+                (xbt_dynar_get_ptr(path_src, max)))->name_,
                 (*(As **)
-                    (xbt_dynar_get_ptr(path_dst, max)))->p_name);
+                    (xbt_dynar_get_ptr(path_dst, max)))->name_);
         e_route_bypass = (sg_platf_route_cbarg_t) xbt_dict_get_or_null(dict_bypassRoutes, route_name);
         xbt_free(route_name);
       }
@@ -402,24 +391,24 @@ void AsGeneric::srcDstCheck(NetCard *src, NetCard *dst)
     xbt_die("Ask for route \"from\"(%s) or \"to\"(%s) no found at AS \"%s\"",
             src ? src->getName() : "(null)",
             dst ? dst->getName() : "(null)",
-            p_name);
+            name_);
 
   As *src_as = src->getRcComponent();
   As *dst_as = dst->getRcComponent();
 
   if (src_as != dst_as)
     xbt_die("The src(%s in %s) and dst(%s in %s) are in differents AS",
-        src->getName(), src_as->p_name,
-        dst->getName(), dst_as->p_name);
+        src->getName(), src_as->name_,
+        dst->getName(), dst_as->name_);
 
   if (this != dst_as)
     xbt_die
     ("The routing component of src'%s' and dst'%s' is not the same as the network elements belong (%s?=%s?=%s)",
         src->getName(),
         dst->getName(),
-        src_as->p_name,
-        dst_as->p_name,
-        p_name);
+        src_as->name_,
+        dst_as->name_,
+        name_);
 }
 
 }