Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
move implementation bits of s4u::As into surf::AsImpl
[simgrid.git] / src / surf / surf_routing_RoutedGraph.cpp
index 5c00da3..cbacc5a 100644 (file)
@@ -32,7 +32,7 @@ namespace simgrid {
 namespace surf {
   
 AsRoutedGraph::AsRoutedGraph(const char*name)
-  : As(name)
+  : AsImpl(name)
 {
 }
 
@@ -91,6 +91,36 @@ xbt_edge_t new_xbt_graph_edge(xbt_graph_t graph, xbt_node_t s, xbt_node_t d, xbt
 namespace simgrid {
 namespace surf {
 
+  xbt_dynar_t AsRoutedGraph::getOneLinkRoutes()
+  {
+    xbt_dynar_t ret = xbt_dynar_new(sizeof(Onelink*), xbt_free_f);
+    sg_platf_route_cbarg_t route = xbt_new0(s_sg_platf_route_cbarg_t,1);
+    route->link_list = new std::vector<Link*>();
+
+    int table_size = (int)xbt_dynar_length(vertices_);
+    for(int src=0; src < table_size; src++) {
+      for(int dst=0; dst< table_size; dst++) {
+        route->link_list->clear();
+        NetCard *src_elm = xbt_dynar_get_as(vertices_, src, NetCard*);
+        NetCard *dst_elm = xbt_dynar_get_as(vertices_, dst, NetCard*);
+        this->getRouteAndLatency(src_elm, dst_elm,route, NULL);
+
+        if (route->link_list->size() == 1) {
+          Link *link = route->link_list->at(0);
+          Onelink *onelink;
+          if (hierarchy_ == AsImpl::ROUTING_BASE)
+            onelink = new Onelink(link, src_elm, dst_elm);
+          else if (hierarchy_ == AsImpl::ROUTING_RECURSIVE)
+            onelink = new Onelink(link, route->gw_src, route->gw_dst);
+          else
+            onelink = new Onelink(link, NULL, NULL);
+          xbt_dynar_push(ret, &onelink);
+        }
+      }
+    }
+    return ret;
+  }
+
 void AsRoutedGraph::getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges)
 {
   int src, dst;
@@ -154,7 +184,7 @@ void AsRoutedGraph::getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edg
 /* ************************************************************************** */
 /* ************************* GENERIC AUX FUNCTIONS ************************** */
 /* change a route containing link names into a route containing link entities */
-sg_platf_route_cbarg_t AsRoutedGraph::newExtendedRoute(e_surf_routing_hierarchy_t hierarchy,
+sg_platf_route_cbarg_t AsRoutedGraph::newExtendedRoute(AsImpl::RoutingKind hierarchy,
     sg_platf_route_cbarg_t routearg, int change_order)
 {
 
@@ -163,15 +193,12 @@ sg_platf_route_cbarg_t AsRoutedGraph::newExtendedRoute(e_surf_routing_hierarchy_
   result = xbt_new0(s_sg_platf_route_cbarg_t, 1);
   result->link_list = new std::vector<Link*>();
 
-  xbt_assert(hierarchy == SURF_ROUTING_BASE
-      || hierarchy == SURF_ROUTING_RECURSIVE,
+  xbt_assert(hierarchy == AsImpl::ROUTING_BASE || hierarchy == AsImpl::ROUTING_RECURSIVE,
       "The hierarchy of this AS is neither BASIC nor RECURSIVE, I'm lost here.");
 
-  if (hierarchy == SURF_ROUTING_RECURSIVE) {
-
+  if (hierarchy == AsImpl::ROUTING_RECURSIVE) {
     xbt_assert(routearg->gw_src && routearg->gw_dst, "NULL is obviously a deficient gateway");
 
-    /* remember not erase the gateway names */
     result->gw_src = routearg->gw_src;
     result->gw_dst = routearg->gw_dst;
   }
@@ -195,11 +222,11 @@ void AsRoutedGraph::getRouteCheckParams(NetCard *src, NetCard *dst)
   As *dst_as = dst->containingAS();
 
   xbt_assert(src_as == dst_as, "Internal error: %s@%s and %s@%s are not in the same AS as expected. Please report that bug.",
-        src->name(), src_as->name_, dst->name(), dst_as->name_);
+        src->name(), src_as->name(), dst->name(), dst_as->name());
 
   xbt_assert(this == dst_as,
       "Internal error: route destination %s@%s is not in AS %s as expected (route source: %s@%s). Please report that bug.",
-        src->name(), dst->name(),  src_as->name_, dst_as->name_,  name_);
+        src->name(), dst->name(),  src_as->name(), dst_as->name(),  name());
 }
 void AsRoutedGraph::addRouteCheckParams(sg_platf_route_cbarg_t route) {
   const char *srcName = route->src;