Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
The code deal with <ASroute> in the exact same way than <route>. Disturbing
[simgrid.git] / src / surf / surf_routing_full.cpp
index bcbcbe2..151db08 100644 (file)
@@ -4,54 +4,51 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
-#include "surf_routing_full.hpp"
-#include "network_interface.hpp"
+#include "src/surf/surf_routing_private.hpp"
+#include "src/surf/surf_routing_full.hpp"
+#include "src/surf/network_interface.hpp"
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_full, surf, "Routing part of surf");
 
 #define TO_ROUTE_FULL(i,j) p_routingTable[(i)+(j)*table_size]
 
-AS_t model_full_create(void)
-{
-  return new AsFull();
-}
+namespace simgrid {
+namespace surf {
+  AsFull::AsFull(const char*name)
+    : AsGeneric(name)
+  {
+  }
 
-void model_full_end(AS_t _routing)
-{
+void AsFull::Seal() {
   int i;
   sg_platf_route_cbarg_t e_route;
 
   /* set utils vars */
-  AsFull *routing = static_cast<AsFull*>(_routing);
-  int table_size = (int)xbt_dynar_length(routing->p_indexNetworkElm);
+  int table_size = (int)xbt_dynar_length(vertices_);
 
   /* Create table if necessary */
-  if (!routing->p_routingTable)
-    routing->p_routingTable = xbt_new0(sg_platf_route_cbarg_t, table_size * table_size);
+  if (!p_routingTable)
+    p_routingTable = xbt_new0(sg_platf_route_cbarg_t, table_size * table_size);
 
   /* Add the loopback if needed */
-  if (routing_platf->p_loopback && routing->p_hierarchy == SURF_ROUTING_BASE) {
+  if (routing_platf->p_loopback && hierarchy_ == SURF_ROUTING_BASE) {
     for (i = 0; i < table_size; i++) {
-      e_route = routing->TO_ROUTE_FULL(i, i);
+      e_route = TO_ROUTE_FULL(i, i);
       if (!e_route) {
         e_route = xbt_new0(s_sg_platf_route_cbarg_t, 1);
         e_route->gw_src = NULL;
         e_route->gw_dst = NULL;
         e_route->link_list = xbt_dynar_new(sizeof(sg_routing_link_t), NULL);
         xbt_dynar_push(e_route->link_list, &routing_platf->p_loopback);
-        routing->TO_ROUTE_FULL(i, i) = e_route;
+        TO_ROUTE_FULL(i, i) = e_route;
       }
     }
   }
 }
 
-AsFull::AsFull(){
-  p_routingTable = 0;
-}
-
 AsFull::~AsFull(){
   if (p_routingTable) {
-    int table_size = (int)xbt_dynar_length(p_indexNetworkElm);
+    int table_size = (int)xbt_dynar_length(vertices_);
     int i, j;
     /* Delete routing table */
     for (i = 0; i < table_size; i++)
@@ -70,7 +67,7 @@ xbt_dynar_t AsFull::getOneLinkRoutes()
   xbt_dynar_t ret = xbt_dynar_new(sizeof(Onelink*), xbt_free_f);
 
   int src, dst;
-  int table_size = xbt_dynar_length(p_indexNetworkElm);
+  int table_size = xbt_dynar_length(vertices_);
 
   for(src=0; src < table_size; src++) {
     for(dst=0; dst< table_size; dst++) {
@@ -79,13 +76,13 @@ xbt_dynar_t AsFull::getOneLinkRoutes()
         if (xbt_dynar_length(route->link_list) == 1) {
           void *link = *(void **) xbt_dynar_get_ptr(route->link_list, 0);
           Onelink *onelink;
-          if (p_hierarchy == SURF_ROUTING_BASE) {
-               RoutingEdge *tmp_src = xbt_dynar_get_as(p_indexNetworkElm, src, sg_routing_edge_t);
+          if (hierarchy_ == SURF_ROUTING_BASE) {
+          NetCard *tmp_src = xbt_dynar_get_as(vertices_, src, sg_netcard_t);
             tmp_src->setId(src);
-               RoutingEdge *tmp_dst = xbt_dynar_get_as(p_indexNetworkElm, dst, sg_routing_edge_t);
-               tmp_dst->setId(dst);
+          NetCard *tmp_dst = xbt_dynar_get_as(vertices_, dst, sg_netcard_t);
+          tmp_dst->setId(dst);
             onelink = new Onelink(link, tmp_src, tmp_dst);
-          } else if (p_hierarchy == SURF_ROUTING_RECURSIVE)
+          } else if (hierarchy_ == SURF_ROUTING_RECURSIVE)
             onelink = new Onelink(link, route->gw_src, route->gw_dst);
           else
             onelink = new Onelink(link, NULL, NULL);
@@ -100,7 +97,7 @@ xbt_dynar_t AsFull::getOneLinkRoutes()
   return ret;
 }
 
-void AsFull::getRouteAndLatency(RoutingEdge *src, RoutingEdge *dst, sg_platf_route_cbarg_t res, double *lat)
+void AsFull::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg_t res, double *lat)
 {
   XBT_DEBUG("full_get_route_and_latency from %s[%d] to %s[%d]",
       src->getName(),
@@ -109,7 +106,7 @@ void AsFull::getRouteAndLatency(RoutingEdge *src, RoutingEdge *dst, sg_platf_rou
       dst->getId());
 
   /* set utils vars */
-  size_t table_size = xbt_dynar_length(p_indexNetworkElm);
+  size_t table_size = xbt_dynar_length(vertices_);
 
   sg_platf_route_cbarg_t e_route = NULL;
   void *link;
@@ -128,10 +125,6 @@ void AsFull::getRouteAndLatency(RoutingEdge *src, RoutingEdge *dst, sg_platf_rou
   }
 }
 
-void AsFull::parseASroute(sg_platf_route_cbarg_t route){
-  parseRoute(route);
-}
-
 static int full_pointer_resource_cmp(const void *a, const void *b)
 {
   return a != b;
@@ -142,14 +135,14 @@ void AsFull::parseRoute(sg_platf_route_cbarg_t route)
   int as_route = 0;
   char *src = (char*)(route->src);
   char *dst = (char*)(route->dst);
-  RoutingEdge *src_net_elm, *dst_net_elm;
-  src_net_elm = sg_routing_edge_by_name_or_null(src);
-  dst_net_elm = sg_routing_edge_by_name_or_null(dst);
+  NetCard *src_net_elm, *dst_net_elm;
+  src_net_elm = sg_netcard_by_name_or_null(src);
+  dst_net_elm = sg_netcard_by_name_or_null(dst);
 
   xbt_assert(src_net_elm, "Network elements %s not found", src);
   xbt_assert(dst_net_elm, "Network elements %s not found", dst);
 
-  size_t table_size = xbt_dynar_length(p_indexNetworkElm);
+  size_t table_size = xbt_dynar_length(vertices_);
 
   xbt_assert(!xbt_dynar_is_empty(route->link_list),
       "Invalid count of links, must be greater than zero (%s,%s)",
@@ -213,16 +206,16 @@ void AsFull::parseRoute(sg_platf_route_cbarg_t route)
       XBT_DEBUG("Load ASroute from \"%s\" to \"%s\"", src, dst);
       if (!route->gw_src ||
           route->gw_src->getRcType() == SURF_NETWORK_ELEMENT_NULL)
-       surf_parse_error("The src_gateway \"%s\" does not exist!",
+      surf_parse_error("The src_gateway \"%s\" does not exist!",
                 route->gw_src ? route->gw_src->getName() : "(null)");
       if (!route->gw_dst ||
           route->gw_dst->getRcType() == SURF_NETWORK_ELEMENT_NULL)
-       surf_parse_error("The dst_gateway \"%s\" does not exist!",
+      surf_parse_error("The dst_gateway \"%s\" does not exist!",
                 route->gw_dst ? route->gw_dst->getName() : "(null)");
       XBT_DEBUG("ASroute goes from \"%s\" to \"%s\"",
                 route->gw_src->getName(), route->gw_dst->getName());
     }
-    TO_ROUTE_FULL(src_net_elm->getId(), dst_net_elm->getId()) = newExtendedRoute(p_hierarchy, route, 1);
+    TO_ROUTE_FULL(src_net_elm->getId(), dst_net_elm->getId()) = newExtendedRoute(hierarchy_, route, 1);
     xbt_dynar_shrink(TO_ROUTE_FULL(src_net_elm->getId(), dst_net_elm->getId())->link_list, 0);
   }
 
@@ -230,7 +223,7 @@ void AsFull::parseRoute(sg_platf_route_cbarg_t route)
       || (route->symmetrical == TRUE && as_route == 1)
   ) {
     if (route->gw_dst && route->gw_src) {
-      sg_routing_edge_t gw_tmp;
+      sg_netcard_t gw_tmp;
       gw_tmp = route->gw_src;
       route->gw_src = route->gw_dst;
       route->gw_dst = gw_tmp;
@@ -257,13 +250,12 @@ void AsFull::parseRoute(sg_platf_route_cbarg_t route)
       else
         XBT_DEBUG("Load ASroute from \"%s(%s)\" to \"%s(%s)\"",
             dst, route->gw_src->getName(), src, route->gw_dst->getName());
-      TO_ROUTE_FULL(dst_net_elm->getId(), src_net_elm->getId()) = newExtendedRoute(p_hierarchy, route, 0);
+      TO_ROUTE_FULL(dst_net_elm->getId(), src_net_elm->getId()) = newExtendedRoute(hierarchy_, route, 0);
       xbt_dynar_shrink(TO_ROUTE_FULL(dst_net_elm->getId(), src_net_elm->getId())->link_list, 0);
     }
   }
   xbt_dynar_free(&route->link_list);
 }
 
-
-
-
+}
+}