Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Move parse_routes to s_routing_component_t.
[simgrid.git] / src / surf / surf_routing.c
index dbe7b07..5c41905 100644 (file)
@@ -917,7 +917,7 @@ static xbt_dynar_t full_get_onelink_routes(routing_component_t rc)
   xbt_dynar_t ret = xbt_dynar_new(sizeof(onelink_t), xbt_free);
 
   routing_component_full_t routing = (routing_component_full_t) rc;
-  int table_size = xbt_dict_length(routing->generic_routing.to_index);
+  size_t table_size = xbt_dict_length(routing->generic_routing.to_index);
   xbt_dict_cursor_t c1 = NULL, c2 = NULL;
   char *k1, *d1, *k2, *d2;
   xbt_dict_foreach(routing->generic_routing.to_index, c1, k1, d1) {
@@ -962,7 +962,7 @@ static route_extended_t full_get_route(routing_component_t rc,
 
   /* set utils vars */
   routing_component_full_t routing = (routing_component_full_t) rc;
-  int table_size = xbt_dict_length(routing->generic_routing.to_index);
+  size_t table_size = xbt_dict_length(routing->generic_routing.to_index);
 
   generic_src_dst_check(rc, src, dst);
   int *src_id = xbt_dict_get_or_null(routing->generic_routing.to_index, src);
@@ -995,7 +995,7 @@ static route_extended_t full_get_route(routing_component_t rc,
 static void full_finalize(routing_component_t rc)
 {
   routing_component_full_t routing = (routing_component_full_t) rc;
-  int table_size = xbt_dict_length(routing->generic_routing.to_index);
+  size_t table_size = xbt_dict_length(routing->generic_routing.to_index);
   int i, j;
   if (routing) {
     /* Delete routing table */
@@ -1033,7 +1033,7 @@ static void *model_full_create(void)
   new_component->generic_routing.finalize = full_finalize;
   new_component->generic_routing.to_index = xbt_dict_new();
   new_component->bypassRoutes = xbt_dict_new();
-  new_component->parse_routes = xbt_dict_new();
+  new_component->generic_routing.parse_routes = xbt_dict_new();
   return new_component;
 }
 
@@ -1064,14 +1064,14 @@ static void model_full_end(void)
   /* set utils vars */
   routing_component_full_t routing =
       ((routing_component_full_t) current_routing);
-  int table_size = xbt_dict_length(routing->generic_routing.to_index);
+  size_t table_size = xbt_dict_length(routing->generic_routing.to_index);
 
   /* Create the routing table */
   routing->routing_table =
       xbt_new0(route_extended_t, table_size * table_size);
 
   /* Put the routes in position */
-  xbt_dict_foreach(routing->parse_routes, cursor, key, data) {
+  xbt_dict_foreach(routing->generic_routing.parse_routes, cursor, key, data) {
     keys = xbt_str_split_str(key, sep);
     src_id = strtol(xbt_dynar_get_as(keys, 0, char *), &end, 10);
     dst_id = strtol(xbt_dynar_get_as(keys, 1, char *), &end, 10);
@@ -1081,14 +1081,14 @@ static void model_full_end(void)
   }
 
   /* delete the parse table */
-  xbt_dict_foreach(routing->parse_routes, cursor, key, data) {
+  xbt_dict_foreach(routing->generic_routing.parse_routes, cursor, key, data) {
     route = (route_t) data;
     xbt_dynar_free(&(route->link_list));
     xbt_free(data);
   }
 
   /* delete parse dict */
-  xbt_dict_free(&(routing->parse_routes));
+  xbt_dict_free(&(routing->generic_routing.parse_routes));
 
   /* Add the loopback if needed */
   if (current_routing->hierarchy == SURF_ROUTING_BASE) {
@@ -1129,8 +1129,6 @@ typedef struct {
   int *predecessor_table;
   route_extended_t *link_table; /* char* -> int* */
   xbt_dict_t bypassRoutes;
-  /* store data during the parse process */
-  xbt_dict_t parse_routes;
 } s_routing_component_floyd_t, *routing_component_floyd_t;
 
 static route_extended_t floyd_get_route(routing_component_t rc,
@@ -1142,7 +1140,7 @@ static xbt_dynar_t floyd_get_onelink_routes(routing_component_t rc)
   xbt_dynar_t ret = xbt_dynar_new(sizeof(onelink_t), xbt_free);
 
   routing_component_floyd_t routing = (routing_component_floyd_t) rc;
-  //int table_size = xbt_dict_length(routing->generic_routing.to_index);
+  //size_t table_size = xbt_dict_length(routing->generic_routing.to_index);
   xbt_dict_cursor_t c1 = NULL, c2 = NULL;
   char *k1, *d1, *k2, *d2;
   xbt_dict_foreach(routing->generic_routing.to_index, c1, k1, d1) {
@@ -1181,7 +1179,7 @@ static route_extended_t floyd_get_route(routing_component_t rc,
 
   /* set utils vars */
   routing_component_floyd_t routing = (routing_component_floyd_t) rc;
-  int table_size = xbt_dict_length(routing->generic_routing.to_index);
+  size_t table_size = xbt_dict_length(routing->generic_routing.to_index);
 
   generic_src_dst_check(rc, src, dst);
   int *src_id = xbt_dict_get_or_null(routing->generic_routing.to_index, src);
@@ -1262,7 +1260,8 @@ static route_extended_t floyd_get_route(routing_component_t rc,
 static void floyd_finalize(routing_component_t rc)
 {
   routing_component_floyd_t routing = (routing_component_floyd_t) rc;
-  int i, j, table_size;
+  int i, j;
+  size_t table_size;
   if (routing) {
     table_size = xbt_dict_length(routing->generic_routing.to_index);
     /* Delete link_table */
@@ -1300,7 +1299,7 @@ static void *model_floyd_create(void)
   new_component->generic_routing.finalize = floyd_finalize;
   new_component->generic_routing.to_index = xbt_dict_new();
   new_component->bypassRoutes = xbt_dict_new();
-  new_component->parse_routes = xbt_dict_new();
+  new_component->generic_routing.parse_routes = xbt_dict_new();
   return new_component;
 }
 
@@ -1328,7 +1327,7 @@ static void model_floyd_end(void)
   unsigned int i, j, a, b, c;
 
   /* set the size of inicial table */
-  int table_size = xbt_dict_length(routing->generic_routing.to_index);
+  size_t table_size = xbt_dict_length(routing->generic_routing.to_index);
 
   /* Create Cost, Predecessor and Link tables */
   cost_table = xbt_new0(double, table_size * table_size);       /* link cost from host to host */
@@ -1344,7 +1343,7 @@ static void model_floyd_end(void)
     }
 
   /* Put the routes in position */
-  xbt_dict_foreach(routing->parse_routes, cursor, key, data) {
+  xbt_dict_foreach(routing->generic_routing.parse_routes, cursor, key, data) {
     keys = xbt_str_split_str(key, sep);
     src_id = strtol(xbt_dynar_get_as(keys, 0, char *), &end, 10);
     dst_id = strtol(xbt_dynar_get_as(keys, 1, char *), &end, 10);
@@ -1392,14 +1391,14 @@ static void model_floyd_end(void)
   }
 
   /* delete the parse table */
-  xbt_dict_foreach(routing->parse_routes, cursor, key, data) {
+  xbt_dict_foreach(routing->generic_routing.parse_routes, cursor, key, data) {
     route_t route = (route_t) data;
     xbt_dynar_free(&(route->link_list));
     xbt_free(data);
   }
 
   /* delete parse dict */
-  xbt_dict_free(&(routing->parse_routes));
+  xbt_dict_free(&(routing->generic_routing.parse_routes));
 
   /* cleanup */
   xbt_free(cost_table);
@@ -1415,7 +1414,6 @@ typedef struct {
   xbt_dict_t graph_node_map;    /* map */
   xbt_dict_t route_cache;       /* use in cache mode */
   int cached;
-  xbt_dict_t parse_routes;
 } s_routing_component_dijkstra_t, *routing_component_dijkstra_t;
 
 
@@ -1831,7 +1829,7 @@ static void *model_dijkstra_both_create(int cached)
   new_component->cached = cached;
   new_component->generic_routing.to_index = xbt_dict_new();
   new_component->bypassRoutes = xbt_dict_new();
-  new_component->parse_routes = xbt_dict_new();
+  new_component->generic_routing.parse_routes = xbt_dict_new();
   return new_component;
 }
 
@@ -1877,7 +1875,7 @@ static void model_dijkstra_both_end(void)
     routing->route_cache = xbt_dict_new();
 
   /* Put the routes in position */
-  xbt_dict_foreach(routing->parse_routes, cursor, key, data) {
+  xbt_dict_foreach(routing->generic_routing.parse_routes, cursor, key, data) {
     keys = xbt_str_split_str(key, sep);
     src_id = strtol(xbt_dynar_get_as(keys, 0, char *), &end, 10);
     dst_id = strtol(xbt_dynar_get_as(keys, 1, char *), &end, 10);
@@ -1888,14 +1886,14 @@ static void model_dijkstra_both_end(void)
   }
 
   /* delete the parse table */
-  xbt_dict_foreach(routing->parse_routes, cursor, key, data) {
+  xbt_dict_foreach(routing->generic_routing.parse_routes, cursor, key, data) {
     route = (route_t) data;
     xbt_dynar_free(&(route->link_list));
     xbt_free(data);
   }
 
   /* delete parse dict */
-  xbt_dict_free(&(routing->parse_routes));
+  xbt_dict_free(&(routing->generic_routing.parse_routes));
 
   /* Add the loopback if needed */
   if (current_routing->hierarchy == SURF_ROUTING_BASE)
@@ -2486,25 +2484,13 @@ static void generic_set_route(routing_component_t rc, const char *src,
                               const char *dst, route_t route)
 {
   DEBUG2("Load Route from \"%s\" to \"%s\"", src, dst);
-  model_type_t modeltype = rc->routing;
   xbt_dict_t _parse_routes;
   xbt_dict_t _to_index;
   char *route_name;
   int *src_id, *dst_id;
   _to_index = current_routing->to_index;
-
-  if (modeltype == &routing_models[SURF_MODEL_FULL]) {
-    _parse_routes = ((routing_component_full_t) rc)->parse_routes;
-
-  } else if (modeltype == &routing_models[SURF_MODEL_FLOYD]) {
-    _parse_routes = ((routing_component_floyd_t) rc)->parse_routes;
-
-  } else if (modeltype == &routing_models[SURF_MODEL_DIJKSTRA] ||
-             modeltype == &routing_models[SURF_MODEL_DIJKSTRACACHE]) {
-    _parse_routes = ((routing_component_dijkstra_t) rc)->parse_routes;
-
-  } else
-    xbt_die("\"generic_set_route\" not supported");
+  //TODO
+  _parse_routes = current_routing->parse_routes;
 
   src_id = xbt_dict_get_or_null(_to_index, src);
   dst_id = xbt_dict_get_or_null(_to_index, dst);
@@ -2529,25 +2515,14 @@ static void generic_set_ASroute(routing_component_t rc, const char *src,
 {
   DEBUG4("Load ASroute from \"%s(%s)\" to \"%s(%s)\"", src,
          e_route->src_gateway, dst, e_route->dst_gateway);
-  model_type_t modeltype = rc->routing;
+
   xbt_dict_t _parse_routes;
   xbt_dict_t _to_index;
   char *route_name;
   int *src_id, *dst_id;
   _to_index = current_routing->to_index;
-
-  if (modeltype == &routing_models[SURF_MODEL_FULL]) {
-    _parse_routes = ((routing_component_full_t) rc)->parse_routes;
-
-  } else if (modeltype == &routing_models[SURF_MODEL_FLOYD]) {
-    _parse_routes = ((routing_component_floyd_t) rc)->parse_routes;
-
-  } else if (modeltype == &routing_models[SURF_MODEL_DIJKSTRA] ||
-             modeltype == &routing_models[SURF_MODEL_DIJKSTRACACHE]) {
-    _parse_routes = ((routing_component_dijkstra_t) rc)->parse_routes;
-
-  } else
-    xbt_die("\"generic_set_route\" not supported");
+  //TODO
+  _parse_routes = current_routing->parse_routes;
 
   src_id = xbt_dict_get_or_null(_to_index, src);
   dst_id = xbt_dict_get_or_null(_to_index, dst);
@@ -2768,7 +2743,7 @@ generic_new_extended_route(e_surf_routing_hierarchy_t hierarchy,
   route_extended_t e_route, new_e_route;
   route_t route;
   unsigned int cpt;
-  xbt_dynar_t links, links_id;
+  xbt_dynar_t links = NULL, links_id = NULL;
 
   new_e_route = xbt_new0(s_route_extended_t, 1);
   new_e_route->generic_route.link_list =