Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
nicer API to the Netcard type
[simgrid.git] / src / surf / surf_routing_RoutedGraph.cpp
index 6af5f56..9f2e501 100644 (file)
@@ -54,8 +54,7 @@ static const char *instr_node_name(xbt_node_t node)
   return str;
 }
 
-xbt_node_t new_xbt_graph_node(xbt_graph_t graph, const char *name,
-                              xbt_dict_t nodes)
+xbt_node_t new_xbt_graph_node(xbt_graph_t graph, const char *name, xbt_dict_t nodes)
 {
   xbt_node_t ret = (xbt_node_t) xbt_dict_get_or_null(nodes, name);
   if (ret)
@@ -66,11 +65,8 @@ xbt_node_t new_xbt_graph_node(xbt_graph_t graph, const char *name,
   return ret;
 }
 
-xbt_edge_t new_xbt_graph_edge(xbt_graph_t graph, xbt_node_t s, xbt_node_t d,
-                              xbt_dict_t edges)
+xbt_edge_t new_xbt_graph_edge(xbt_graph_t graph, xbt_node_t s, xbt_node_t d, xbt_dict_t edges)
 {
-  xbt_edge_t ret;
-
   const char *sn = instr_node_name(s);
   const char *dn = instr_node_name(d);
   int len = strlen(sn) + strlen(dn) + 1;
@@ -78,7 +74,7 @@ xbt_edge_t new_xbt_graph_edge(xbt_graph_t graph, xbt_node_t s, xbt_node_t d,
 
 
   snprintf(name, len, "%s%s", sn, dn);
-  ret = (xbt_edge_t) xbt_dict_get_or_null(edges, name);
+  xbt_edge_t ret = (xbt_edge_t) xbt_dict_get_or_null(edges, name);
   if (ret == NULL) {
     snprintf(name, len, "%s%s", dn, sn);
     ret = (xbt_edge_t) xbt_dict_get_or_null(edges, name);
@@ -226,20 +222,16 @@ void AsRoutedGraph::addRouteCheckParams(sg_platf_route_cbarg_t route) {
     xbt_assert(src, "Cannot add a route from %s to %s: %s does not exist.", srcName, dstName, srcName);
     xbt_assert(dst, "Cannot add a route from %s to %s: %s does not exist.", srcName, dstName, dstName);
     xbt_assert(!xbt_dynar_is_empty(route->link_list), "Empty route (between %s and %s) forbidden.", srcName, dstName);
-    xbt_assert(src->getRcType()==SURF_NETWORK_ELEMENT_HOST || src->getRcType()==SURF_NETWORK_ELEMENT_ROUTER,
-        "When defining a route, src must be an host or a router but '%s' is not. Did you meant to have an ASroute?", srcName);
-    xbt_assert(dst->getRcType()==SURF_NETWORK_ELEMENT_HOST || dst->getRcType()==SURF_NETWORK_ELEMENT_ROUTER,
-        "When defining a route, dst must be an host or a router but '%s' is not. Did you meant to have an ASroute?", dstName);
+    xbt_assert(! src->isAS(), "When defining a route, src cannot be an AS such as '%s'. Did you meant to have an ASroute?", srcName);
+    xbt_assert(! dst->isAS(), "When defining a route, dst cannot be an AS such as '%s'. Did you meant to have an ASroute?", dstName);
   } else {
     XBT_DEBUG("Load ASroute from %s@%s to %s@%s", srcName, route->gw_src->name(), dstName, route->gw_dst->name());
-    xbt_assert(src->getRcType()==SURF_NETWORK_ELEMENT_AS,
-        "When defining an ASroute, src must be an AS but '%s' is not", srcName);
-    xbt_assert(dst->getRcType()==SURF_NETWORK_ELEMENT_AS,
-        "When defining an ASroute, dst must be an AS but '%s' is not", dstName);
+    xbt_assert(src->isAS(), "When defining an ASroute, src must be an AS but '%s' is not", srcName);
+    xbt_assert(dst->isAS(), "When defining an ASroute, dst must be an AS but '%s' is not", dstName);
 
-    xbt_assert(route->gw_src->getRcType()==SURF_NETWORK_ELEMENT_HOST || route->gw_src->getRcType()==SURF_NETWORK_ELEMENT_ROUTER,
+    xbt_assert(route->gw_src->isHost() || route->gw_src->isRouter(),
         "When defining an ASroute, gw_src must be an host or a router but '%s' is not.", srcName);
-    xbt_assert(route->gw_dst->getRcType()==SURF_NETWORK_ELEMENT_HOST || route->gw_dst->getRcType()==SURF_NETWORK_ELEMENT_ROUTER,
+    xbt_assert(route->gw_dst->isHost() || route->gw_dst->isRouter(),
         "When defining an ASroute, gw_dst must be an host or a router but '%s' is not.", dstName);
 
     xbt_assert(route->gw_src != route->gw_dst, "Cannot define an ASroute from '%s' to itself", route->gw_src->name());