X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/a92d7b716f51a53dea7f59db8524d4add713b910..7a2718e5f7b23eaff7529cda8dac5d7332255171:/src/kernel/routing/DijkstraZone.cpp diff --git a/src/kernel/routing/DijkstraZone.cpp b/src/kernel/routing/DijkstraZone.cpp index 0efd92e0e4..2d978c90bf 100644 --- a/src/kernel/routing/DijkstraZone.cpp +++ b/src/kernel/routing/DijkstraZone.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2009-2016. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2009-2017. The SimGrid Team. All rights reserved. */ /* 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. */ @@ -7,7 +7,7 @@ #include "src/kernel/routing/NetPoint.hpp" #include "src/surf/network_interface.hpp" -#include +#include XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_dijkstra, surf, "Routing part of surf -- dijkstra routing logic"); @@ -167,7 +167,7 @@ void DijkstraZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cb sg_platf_route_cbarg_t e_route = (sg_platf_route_cbarg_t)xbt_graph_edge_get_data(edge); - for (auto link : *e_route->link_list) { + for (auto const& link : *e_route->link_list) { route->link_list->insert(route->link_list->begin(), link); if (lat) *lat += static_cast(link)->latency(); @@ -265,7 +265,7 @@ void DijkstraZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cb NetPoint* prev_gw_src_net_elm = nullptr; getGlobalRoute(gw_dst_net_elm, prev_gw_src_net_elm, &e_route_as_to_as, nullptr); auto pos = route->link_list->begin(); - for (auto link : e_route_as_to_as) { + for (auto const& link : e_route_as_to_as) { route->link_list->insert(pos, link); if (lat) *lat += link->latency(); @@ -273,7 +273,7 @@ void DijkstraZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cb } } - for (auto link : *e_route->link_list) { + for (auto const& link : *e_route->link_list) { route->link_list->insert(route->link_list->begin(), link); if (lat) *lat += static_cast(link)->latency(); @@ -307,7 +307,7 @@ DijkstraZone::~DijkstraZone() /* Creation routing model functions */ -DijkstraZone::DijkstraZone(NetZone* father, const char* name, bool cached) : RoutedZone(father, name) +DijkstraZone::DijkstraZone(NetZone* father, std::string name, bool cached) : RoutedZone(father, name) { if (cached) routeCache_ = xbt_dict_new_homogeneous(&route_cache_elem_free); @@ -337,20 +337,23 @@ void DijkstraZone::addRoute(sg_platf_route_cbarg_t route) // Symmetrical YES if (route->symmetrical == true) { - if (not route->gw_dst && not route->gw_src) - XBT_DEBUG("Load Route from \"%s\" to \"%s\"", dstName, srcName); - else - XBT_DEBUG("Load NetzoneRoute from %s@%s to %s@%s", dstName, route->gw_dst->name().c_str(), srcName, - route->gw_src->name().c_str()); xbt_dynar_t nodes = xbt_graph_get_nodes(routeGraph_); xbt_node_t node_s_v = xbt_dynar_get_as(nodes, src->id(), xbt_node_t); xbt_node_t node_e_v = xbt_dynar_get_as(nodes, dst->id(), xbt_node_t); xbt_edge_t edge = xbt_graph_get_edge(routeGraph_, node_e_v, node_s_v); - if (edge) - THROWF(arg_error, 0, "Route from %s@%s to %s@%s already exists", dstName, route->gw_dst->name().c_str(), srcName, + if (not route->gw_dst || not route->gw_src){ + XBT_DEBUG("Load Route from \"%s\" to \"%s\"", dstName, srcName); + if (edge) + THROWF(arg_error, 0, "Route from %s to %s already exists", dstName, srcName); + } else { + XBT_DEBUG("Load NetzoneRoute from %s@%s to %s@%s", dstName, route->gw_dst->name().c_str(), srcName, + route->gw_src->name().c_str()); + if (edge) + THROWF(arg_error, 0, "Route from %s@%s to %s@%s already exists", dstName, route->gw_dst->name().c_str(), srcName, route->gw_src->name().c_str()); + } if (route->gw_dst && route->gw_src) { NetPoint* gw_tmp = route->gw_src;