Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix a bug
[simgrid.git] / src / surf / surf_routing_dijkstra.cpp
index 417e3c9..64b1ce7 100644 (file)
@@ -5,14 +5,12 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "surf_routing_dijkstra.hpp"
-#include "network.hpp"
+#include "network_interface.hpp"
 
 /* Global vars */
 extern routing_platf_t routing_platf;
 
-extern "C" {
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_dijkstra, surf, "Routing part of surf -- dijkstra routing logic");
-}
 
 /* Free functions */
 
@@ -258,7 +256,7 @@ void AsDijkstra::getRouteAndLatency(RoutingEdgePtr src, RoutingEdgePtr dst, sg_p
     xbt_dynar_foreach(links, cpt, link) {
       xbt_dynar_unshift(route->link_list, &link);
       if (lat)
-        *lat += dynamic_cast<NetworkCm02LinkPtr>(static_cast<ResourcePtr>(link))->getLatency();
+        *lat += static_cast<NetworkLinkPtr>(link)->getLatency();
     }
 
   }
@@ -366,7 +364,7 @@ void AsDijkstra::getRouteAndLatency(RoutingEdgePtr src, RoutingEdgePtr dst, sg_p
       xbt_dynar_foreach(links, cpt, link) {
         xbt_dynar_insert_at(route->link_list, pos, &link);
         if (lat)
-          *lat += dynamic_cast<NetworkCm02LinkPtr>(static_cast<ResourcePtr>(link))->getLatency();
+          *lat += static_cast<NetworkLinkPtr>(link)->getLatency();
         pos++;
       }
     }
@@ -375,7 +373,7 @@ void AsDijkstra::getRouteAndLatency(RoutingEdgePtr src, RoutingEdgePtr dst, sg_p
     xbt_dynar_foreach(links, cpt, link) {
       xbt_dynar_unshift(route->link_list, &link);
       if (lat)
-        *lat += dynamic_cast<NetworkCm02LinkPtr>(static_cast<ResourcePtr>(link))->getLatency();
+        *lat += static_cast<NetworkLinkPtr>(link)->getLatency();
     }
     size++;
   }
@@ -409,10 +407,17 @@ AsDijkstra::~AsDijkstra()
 
 /* Creation routing model functions */
 
-AsDijkstra::AsDijkstra() : AsGeneric(), m_cached(0) {}
+AsDijkstra::AsDijkstra() : AsGeneric(), m_cached(0) {
+  p_routeGraph = NULL;
+  p_graphNodeMap = NULL;
+  p_routeCache = NULL;
+}
 
 AsDijkstra::AsDijkstra(int cached) : AsGeneric(), m_cached(cached)
 {
+  p_routeGraph = NULL;
+  p_graphNodeMap = NULL;
+  p_routeCache = NULL;
   /*new_component->generic_routing.parse_route = model_dijkstra_both_parse_route;
   new_component->generic_routing.parse_ASroute = model_dijkstra_both_parse_route;
   new_component->generic_routing.get_route_and_latency = dijkstra_get_route_and_latency;
@@ -435,7 +440,7 @@ void AsDijkstra::end()
   if(!p_graphNodeMap)
     p_graphNodeMap = xbt_dict_new_homogeneous(&graph_node_map_elem_free);
 
-  if (m_cached && p_routeCache)
+  if (m_cached && !p_routeCache)
     p_routeCache = xbt_dict_new_homogeneous(&route_cache_elem_free);
 
   /* Add the loopback if needed */