-/* 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. */
#include "src/kernel/routing/NetPoint.hpp"
#include "src/surf/network_interface.hpp"
-#include <float.h>
+#include <cfloat>
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_dijkstra, surf, "Routing part of surf -- dijkstra routing logic");
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<surf::LinkImpl*>(link)->latency();
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();
}
}
- 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<surf::LinkImpl*>(link)->latency();
/* 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);
// 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;