bool sealed_ = false; // We cannot add more content when sealed
- std::map<std::pair<std::string, std::string>, std::vector<surf::Link*>*> bypassRoutes_; // srcName x dstName -> route
+ std::map<std::pair<std::string, std::string>, std::vector<surf::Link*>*> bypassRoutes_; // src x dst -> route
xbt_dict_t children_ = xbt_dict_new_homogeneous(nullptr); // sub-ASes
};
/** Retrieves an host from its name, or return nullptr */
static Host* by_name_or_null(const char* name);
+ /** Retrieves an host from its name, or return nullptr */
+ static Host* by_name_or_null(std::string name);
/** Retrieves an host from its name, or die */
static s4u::Host *by_name(std::string name);
/** Retrieves the host on which the current actor is running */
void AsCluster::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg_t route, double *lat)
{
s_surf_parsing_link_up_down_t info;
- XBT_VERB("cluster_get_route_and_latency from '%s'[%d] to '%s'[%d]",
- src->name(), src->id(), dst->name(), dst->id());
+ XBT_VERB("cluster_get_route_and_latency from '%s'[%d] to '%s'[%d]", src->name().c_str(), src->id(),
+ dst->name().c_str(), dst->id());
xbt_assert(!privateLinks_.empty(), "Cluster routing : no links attached to the source node - did you use host_link tag?");
if (! src->isRouter()) { // No specific link for router
void AsCluster::getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges)
{
- xbt_node_t current, previous, backboneNode = nullptr, routerNode;
+ xbt_node_t current, previous, backboneNode = nullptr;
s_surf_parsing_link_up_down_t info;
xbt_assert(router_,"Malformed cluster. This may be because your platform file is a hypergraph while it must be a graph.");
/* create the router */
- char *link_name = router_->name();
- routerNode = new_xbt_graph_node(graph, link_name, nodes);
+ xbt_node_t routerNode = new_xbt_graph_node(graph, router_->name().c_str(), nodes);
if(backbone_) {
const char *link_nameR = backbone_->getName();
for (auto src: vertices_){
if (! src->isRouter()) {
- previous = new_xbt_graph_node(graph, src->name(), nodes);
+ previous = new_xbt_graph_node(graph, src->name().c_str(), nodes);
info = privateLinks_.at(src->id());
if (dst->isRouter() || src->isRouter())
return;
- XBT_VERB("dragonfly_get_route_and_latency from '%s'[%d] to '%s'[%d]", src->name(), src->id(), dst->name(), dst->id());
+ XBT_VERB("dragonfly_get_route_and_latency from '%s'[%d] to '%s'[%d]", src->name().c_str(), src->id(),
+ dst->name().c_str(), dst->id());
if ((src->id() == dst->id()) && hasLoopback_) {
s_surf_parsing_link_up_down_t info = privateLinks_.at(src->id() * linkCountPerNode_);
// xbt_die -> assert
if (tempIter == this->computeNodes_.end()) {
- xbt_die("Could not find the source %s [%d] in the fat tree", src->name(),
- src->id());
+ xbt_die("Could not find the source %s [%d] in the fat tree", src->name().c_str(), src->id());
}
source = tempIter->second;
tempIter = this->computeNodes_.find(dst->id());
if (tempIter == this->computeNodes_.end()) {
- xbt_die("Could not find the destination %s [%d] in the fat tree",
- dst->name(), dst->id());
+ xbt_die("Could not find the destination %s [%d] in the fat tree", dst->name().c_str(), dst->id());
}
destination = tempIter->second;
-
- XBT_VERB("Get route and latency from '%s' [%d] to '%s' [%d] in a fat tree",
- src->name(), src->id(), dst->name(), dst->id());
+
+ XBT_VERB("Get route and latency from '%s' [%d] to '%s' [%d] in a fat tree", src->name().c_str(), src->id(),
+ dst->name().c_str(), dst->id());
/* In case destination is the source, and there is a loopback, let's get
through it instead of going up to a switch*/
void AsClusterTorus::getRouteAndLatency(NetCard * src, NetCard * dst, sg_platf_route_cbarg_t route, double *lat) {
- XBT_VERB("torus_get_route_and_latency from '%s'[%d] to '%s'[%d]",
- src->name(), src->id(), dst->name(), dst->id());
+ XBT_VERB("torus_get_route_and_latency from '%s'[%d] to '%s'[%d]", src->name().c_str(), src->id(),
+ dst->name().c_str(), dst->id());
if (dst->isRouter() || src->isRouter())
return;
xbt_edge_t edge = xbt_graph_get_edge(routeGraph_, node_s_v, node_e_v);
if (edge == nullptr)
- THROWF(arg_error, 0, "No route from '%s' to '%s'", src->name(), dst->name());
+ THROWF(arg_error, 0, "No route from '%s' to '%s'", src->name().c_str(), dst->name().c_str());
e_route = (sg_platf_route_cbarg_t) xbt_graph_edge_get_data(edge);
xbt_edge_t edge = xbt_graph_get_edge(routeGraph_, node_pred_v, node_v);
if (edge == nullptr)
- THROWF(arg_error, 0, "No route from '%s' to '%s'", src->name(), dst->name());
+ THROWF(arg_error, 0, "No route from '%s' to '%s'", src->name().c_str(), dst->name().c_str());
prev_gw_src = gw_src;
if (v == dst_node_id)
first_gw = gw_dst;
- if (hierarchy_ == RoutingMode::recursive && v != dst_node_id && strcmp(gw_dst->name(), prev_gw_src->name())) {
+ if (hierarchy_ == RoutingMode::recursive && v != dst_node_id &&
+ strcmp(gw_dst->name().c_str(), prev_gw_src->name().c_str())) {
std::vector<Link*> *e_route_as_to_as = new std::vector<Link*>();
routing_platf->getRouteAndLatency(gw_dst_net_elm, prev_gw_src_net_elm, e_route_as_to_as, nullptr);
{
NetCard *src = route->src;
NetCard *dst = route->dst;
- const char *srcName = src->name();
- const char *dstName = dst->name();
+ const char* srcName = src->name().c_str();
+ const char* dstName = dst->name().c_str();
addRouteCheckParams(route);
if(!route->gw_dst && !route->gw_src)
XBT_DEBUG("Load Route from \"%s\" to \"%s\"", dstName, srcName);
else
- XBT_DEBUG("Load ASroute from %s@%s to %s@%s", dstName, route->gw_dst->name(), srcName, route->gw_src->name());
+ XBT_DEBUG("Load ASroute 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_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(), srcName, route->gw_src->name());
+ 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) {
NetCard *gw_tmp = route->gw_src;
do {
pred = TO_FLOYD_PRED(src->id(), cur);
if (pred == -1)
- THROWF(arg_error, 0, "No route from '%s' to '%s'", src->name(), dst->name());
+ THROWF(arg_error, 0, "No route from '%s' to '%s'", src->name().c_str(), dst->name().c_str());
route_stack.push_back(TO_FLOYD_LINK(pred, cur));
cur = pred;
} while (cur != src->id());
while (!route_stack.empty()) {
sg_platf_route_cbarg_t e_route = route_stack.back();
route_stack.pop_back();
- if (hierarchy_ == RoutingMode::recursive && prev_dst_gw != nullptr && strcmp(prev_dst_gw->name(), e_route->gw_src->name())) {
+ if (hierarchy_ == RoutingMode::recursive && prev_dst_gw != nullptr &&
+ strcmp(prev_dst_gw->name().c_str(), e_route->gw_src->name().c_str())) {
routing_platf->getRouteAndLatency(prev_dst_gw, e_route->gw_src, route->link_list, lat);
}
/* Check that the route does not already exist */
if (route->gw_dst) // AS route (to adapt the error message, if any)
xbt_assert(nullptr == TO_FLOYD_LINK(route->src->id(), route->dst->id()),
- "The route between %s@%s and %s@%s already exists (Rq: routes are symmetrical by default).",
- route->src->name(),route->gw_src->name(),route->dst->name(),route->gw_dst->name());
+ "The route between %s@%s and %s@%s already exists (Rq: routes are symmetrical by default).",
+ route->src->name().c_str(), route->gw_src->name().c_str(), route->dst->name().c_str(),
+ route->gw_dst->name().c_str());
else
xbt_assert(nullptr == TO_FLOYD_LINK(route->src->id(), route->dst->id()),
- "The route between %s and %s already exists (Rq: routes are symmetrical by default).", route->src->name(),route->dst->name());
+ "The route between %s and %s already exists (Rq: routes are symmetrical by default).",
+ route->src->name().c_str(), route->dst->name().c_str());
TO_FLOYD_LINK(route->src->id(), route->dst->id()) = newExtendedRoute(hierarchy_, route, 1);
TO_FLOYD_PRED(route->src->id(), route->dst->id()) = route->src->id();
if (route->symmetrical == true) {
if (route->gw_dst) // AS route (to adapt the error message, if any)
- xbt_assert(nullptr == TO_FLOYD_LINK(route->dst->id(), route->src->id()),
+ xbt_assert(
+ nullptr == TO_FLOYD_LINK(route->dst->id(), route->src->id()),
"The route between %s@%s and %s@%s already exists. You should not declare the reverse path as symmetrical.",
- route->dst->name(),route->gw_dst->name(),route->src->name(),route->gw_src->name());
+ route->dst->name().c_str(), route->gw_dst->name().c_str(), route->src->name().c_str(),
+ route->gw_src->name().c_str());
else
xbt_assert(nullptr == TO_FLOYD_LINK(route->dst->id(), route->src->id()),
- "The route between %s and %s already exists. You should not declare the reverse path as symmetrical.",
- route->dst->name(),route->src->name());
+ "The route between %s and %s already exists. You should not declare the reverse path as symmetrical.",
+ route->dst->name().c_str(), route->src->name().c_str());
if(route->gw_dst && route->gw_src) {
NetCard* gw_tmp = route->gw_src;
}
if(!route->gw_src && !route->gw_dst)
- XBT_DEBUG("Load Route from \"%s\" to \"%s\"", route->dst->name(), route->src->name());
+ XBT_DEBUG("Load Route from \"%s\" to \"%s\"", route->dst->name().c_str(), route->src->name().c_str());
else
- XBT_DEBUG("Load ASroute from \"%s(%s)\" to \"%s(%s)\"", route->dst->name(),
- route->gw_src->name(), route->src->name(), route->gw_dst->name());
+ XBT_DEBUG("Load ASroute from \"%s(%s)\" to \"%s(%s)\"", route->dst->name().c_str(), route->gw_src->name().c_str(),
+ route->src->name().c_str(), route->gw_dst->name().c_str());
TO_FLOYD_LINK(route->dst->id(), route->src->id()) = newExtendedRoute(hierarchy_, route, 0);
TO_FLOYD_PRED(route->dst->id(), route->src->id()) = route->dst->id();
void AsFull::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg_t res, double *lat)
{
- XBT_DEBUG("full_get_route_and_latency from %s[%d] to %s[%d]",
- src->name(), src->id(), dst->name(), dst->id());
+ XBT_DEBUG("full_get_route_and_latency from %s[%d] to %s[%d]", src->name().c_str(), src->id(), dst->name().c_str(),
+ dst->id());
/* set utils vars */
size_t table_size = vertices_.size();
void AsFull::addRoute(sg_platf_route_cbarg_t route)
{
- NetCard *src_net_elm = route->src;
- NetCard *dst_net_elm = route->dst;
- const char *src = src_net_elm->name();
- const char *dst = dst_net_elm->name();
+ NetCard* src = route->src;
+ NetCard* dst = route->dst;
+ const char* srcName = src->name().c_str();
+ const char* dstName = dst->name().c_str();
addRouteCheckParams(route);
/* Check that the route does not already exist */
if (route->gw_dst) // AS route (to adapt the error message, if any)
- xbt_assert(nullptr == TO_ROUTE_FULL(src_net_elm->id(), dst_net_elm->id()),
- "The route between %s@%s and %s@%s already exists (Rq: routes are symmetrical by default).",
- src,route->gw_src->name(),dst,route->gw_dst->name());
+ xbt_assert(nullptr == TO_ROUTE_FULL(src->id(), dst->id()),
+ "The route between %s@%s and %s@%s already exists (Rq: routes are symmetrical by default).", srcName,
+ route->gw_src->name().c_str(), dstName, route->gw_dst->name().c_str());
else
- xbt_assert(nullptr == TO_ROUTE_FULL(src_net_elm->id(), dst_net_elm->id()),
- "The route between %s and %s already exists (Rq: routes are symmetrical by default).", src,dst);
+ xbt_assert(nullptr == TO_ROUTE_FULL(src->id(), dst->id()),
+ "The route between %s and %s already exists (Rq: routes are symmetrical by default).", srcName, dstName);
/* Add the route to the base */
- TO_ROUTE_FULL(src_net_elm->id(), dst_net_elm->id()) = newExtendedRoute(hierarchy_, route, 1);
- TO_ROUTE_FULL(src_net_elm->id(), dst_net_elm->id())->link_list->shrink_to_fit();
+ TO_ROUTE_FULL(src->id(), dst->id()) = newExtendedRoute(hierarchy_, route, 1);
+ TO_ROUTE_FULL(src->id(), dst->id())->link_list->shrink_to_fit();
- if (route->symmetrical == true && src_net_elm != dst_net_elm) {
+ if (route->symmetrical == true && src != dst) {
if (route->gw_dst && route->gw_src) {
NetCard* gw_tmp = route->gw_src;
route->gw_src = route->gw_dst;
route->gw_dst = gw_tmp;
}
if (route->gw_dst) // AS route (to adapt the error message, if any)
- xbt_assert(nullptr == TO_ROUTE_FULL(dst_net_elm->id(), src_net_elm->id()),
+ xbt_assert(
+ nullptr == TO_ROUTE_FULL(dst->id(), src->id()),
"The route between %s@%s and %s@%s already exists. You should not declare the reverse path as symmetrical.",
- dst,route->gw_dst->name(),src,route->gw_src->name());
+ dstName, route->gw_dst->name().c_str(), srcName, route->gw_src->name().c_str());
else
- xbt_assert(nullptr == TO_ROUTE_FULL(dst_net_elm->id(), src_net_elm->id()),
- "The route between %s and %s already exists. You should not declare the reverse path as symmetrical.", dst,src);
+ xbt_assert(nullptr == TO_ROUTE_FULL(dst->id(), src->id()),
+ "The route between %s and %s already exists. You should not declare the reverse path as symmetrical.",
+ dstName, srcName);
- TO_ROUTE_FULL(dst_net_elm->id(), src_net_elm->id()) = newExtendedRoute(hierarchy_, route, 0);
- TO_ROUTE_FULL(dst_net_elm->id(), src_net_elm->id())->link_list->shrink_to_fit();
+ TO_ROUTE_FULL(dst->id(), src->id()) = newExtendedRoute(hierarchy_, route, 0);
+ TO_ROUTE_FULL(dst->id(), src->id())->link_list->shrink_to_fit();
}
}
AsImpl* src_as = src->containingAS();
AsImpl* dst_as = dst->containingAS();
- xbt_assert(src_as, "Host %s must be in an AS", src->name());
- xbt_assert(dst_as, "Host %s must be in an AS", dst->name());
+ xbt_assert(src_as, "Host %s must be in an AS", src->name().c_str());
+ xbt_assert(dst_as, "Host %s must be in an AS", dst->name().c_str());
/* (2) find the path to the root routing component */
std::vector<AsImpl*> path_src;
/* OUT */ std::vector<surf::Link*>* links, double* latency)
{
// If never set a bypass route return nullptr without any further computations
- XBT_DEBUG("generic_get_bypassroute from %s to %s", src->name(), dst->name());
+ XBT_DEBUG("generic_get_bypassroute from %s to %s", src->name().c_str(), dst->name().c_str());
if (bypassRoutes_.empty())
return false;
s_sg_platf_route_cbarg_t route;
memset(&route,0,sizeof(route));
- XBT_DEBUG("Solve route/latency \"%s\" to \"%s\"", src->name(), dst->name());
+ XBT_DEBUG("Solve route/latency \"%s\" to \"%s\"", src->name().c_str(), dst->name().c_str());
/* Find how src and dst are interconnected */
AsImpl *common_ancestor, *src_ancestor, *dst_ancestor;
route.link_list = new std::vector<surf::Link*>();
common_ancestor->getRouteAndLatency(src_ancestor->netcard_, dst_ancestor->netcard_, &route, latency);
- xbt_assert((route.gw_src != nullptr) && (route.gw_dst != nullptr),
- "bad gateways for route from \"%s\" to \"%s\"", src->name(), dst->name());
+ xbt_assert((route.gw_src != nullptr) && (route.gw_dst != nullptr), "bad gateways for route from \"%s\" to \"%s\"",
+ src->name().c_str(), dst->name().c_str());
/* If source gateway is not our source, we have to recursively find our way up to this point */
if (src != route.gw_src)
getRouteAndLatency(my_src, my_dst, route, nullptr);
- XBT_DEBUG ("get_route_and_latency %s -> %s", my_src->name(), my_dst->name());
+ XBT_DEBUG("get_route_and_latency %s -> %s", my_src->name().c_str(), my_dst->name().c_str());
xbt_node_t current, previous;
const char *previous_name, *current_name;
if (route->gw_src) {
- previous = new_xbt_graph_node(graph, route->gw_src->name(), nodes);
- previous_name = route->gw_src->name();
+ previous = new_xbt_graph_node(graph, route->gw_src->name().c_str(), nodes);
+ previous_name = route->gw_src->name().c_str();
} else {
- previous = new_xbt_graph_node(graph, my_src->name(), nodes);
- previous_name = my_src->name();
+ previous = new_xbt_graph_node(graph, my_src->name().c_str(), nodes);
+ previous_name = my_src->name().c_str();
}
for (auto link: *route->link_list) {
}
if (route->gw_dst) {
- current = new_xbt_graph_node(graph, route->gw_dst->name(), nodes);
- current_name = route->gw_dst->name();
+ current = new_xbt_graph_node(graph, route->gw_dst->name().c_str(), nodes);
+ current_name = route->gw_dst->name().c_str();
} else {
- current = new_xbt_graph_node(graph, my_dst->name(), nodes);
- current_name = my_dst->name();
+ current = new_xbt_graph_node(graph, my_dst->name().c_str(), nodes);
+ current_name = my_dst->name().c_str();
}
new_xbt_graph_edge(graph, previous, current, edges);
XBT_DEBUG (" %s -> %s", previous_name, current_name);
void AsRoutedGraph::getRouteCheckParams(NetCard *src, NetCard *dst)
{
- xbt_assert(src,"Cannot find a route from nullptr to %s", dst->name());
- xbt_assert(dst,"Cannot find a route from %s to nullptr", src->name());
+ xbt_assert(src, "Cannot find a route from nullptr to %s", dst->name().c_str());
+ xbt_assert(dst, "Cannot find a route from %s to nullptr", src->name().c_str());
As *src_as = src->containingAS();
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());
+ 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().c_str(), src_as->name(), dst->name().c_str(), 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());
+ 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().c_str(), dst->name().c_str(), src_as->name(), dst_as->name(), name());
}
void AsRoutedGraph::addRouteCheckParams(sg_platf_route_cbarg_t route) {
NetCard *src = route->src;
NetCard *dst = route->dst;
- const char *srcName = src->name();
- const char *dstName = dst->name();
+ const char* srcName = src->name().c_str();
+ const char* dstName = dst->name().c_str();
if(!route->gw_dst && !route->gw_src) {
XBT_DEBUG("Load Route from \"%s\" to \"%s\"", srcName, 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_DEBUG("Load ASroute from %s@%s to %s@%s", srcName, route->gw_src->name().c_str(), dstName,
+ route->gw_dst->name().c_str());
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_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());
+ xbt_assert(route->gw_src != route->gw_dst, "Cannot define an ASroute from '%s' to itself",
+ route->gw_src->name().c_str());
- xbt_assert(src, "Cannot add a route from %s@%s to %s@%s: %s does not exist.",
- srcName,route->gw_src->name(), dstName,route->gw_dst->name(), srcName);
- xbt_assert(dst, "Cannot add a route from %s@%s to %s@%s: %s does not exist.",
- srcName,route->gw_src->name(), dstName,route->gw_dst->name(), dstName);
- xbt_assert(! route->link_list->empty(), "Empty route (between %s@%s and %s@%s) forbidden.",
- srcName,route->gw_src->name(), dstName,route->gw_dst->name());
+ xbt_assert(src, "Cannot add a route from %s@%s to %s@%s: %s does not exist.", srcName,
+ route->gw_src->name().c_str(), dstName, route->gw_dst->name().c_str(), srcName);
+ xbt_assert(dst, "Cannot add a route from %s@%s to %s@%s: %s does not exist.", srcName,
+ route->gw_src->name().c_str(), dstName, route->gw_dst->name().c_str(), dstName);
+ xbt_assert(!route->link_list->empty(), "Empty route (between %s@%s and %s@%s) forbidden.", srcName,
+ route->gw_src->name().c_str(), dstName, route->gw_dst->name().c_str());
}
}
char *tmp_name;
if(nc->isHost()){
- tmp_name = bprintf("peer_%s", nc->name());
+ tmp_name = bprintf("peer_%s", nc->name().c_str());
simgrid::s4u::Host *host = simgrid::s4u::Host::by_name_or_null(tmp_name);
if (host == nullptr)
host = simgrid::s4u::Host::by_name_or_null(nc->name());
res = (xbt_dynar_t) host->extension(COORD_HOST_LEVEL);
}
else if(nc->isRouter() || nc->isAS()){
- tmp_name = bprintf("router_%s", nc->name());
+ tmp_name = bprintf("router_%s", nc->name().c_str());
res = (xbt_dynar_t) xbt_lib_get_or_null(as_router_lib, tmp_name, COORD_ASR_LEVEL);
}
else{
void AsVivaldi::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg_t route, double *lat)
{
- XBT_DEBUG("vivaldi_get_route_and_latency from '%s'[%d] '%s'[%d]", src->name(), src->id(), dst->name(), dst->id());
+ XBT_DEBUG("vivaldi_get_route_and_latency from '%s'[%d] '%s'[%d]", src->name().c_str(), src->id(), dst->name().c_str(),
+ dst->id());
if(src->isAS()) {
- char *src_name = bprintf("router_%s",src->name());
- char *dst_name = bprintf("router_%s",dst->name());
- route->gw_src = (sg_netcard_t) xbt_lib_get_or_null(as_router_lib, src_name, ROUTING_ASR_LEVEL);
- route->gw_dst = (sg_netcard_t) xbt_lib_get_or_null(as_router_lib, dst_name, ROUTING_ASR_LEVEL);
- xbt_free(src_name);
- xbt_free(dst_name);
+ char* srcName = bprintf("router_%s", src->name().c_str());
+ char* dstName = bprintf("router_%s", dst->name().c_str());
+ route->gw_src = (sg_netcard_t)xbt_lib_get_or_null(as_router_lib, srcName, ROUTING_ASR_LEVEL);
+ route->gw_dst = (sg_netcard_t)xbt_lib_get_or_null(as_router_lib, dstName, ROUTING_ASR_LEVEL);
+ xbt_free(srcName);
+ xbt_free(dstName);
}
/* Retrieve the private links */
{
/* Argument validity checks */
if (e_route->gw_dst) {
- XBT_DEBUG("Load bypassASroute from %s@%s to %s@%s", e_route->src->name(), e_route->gw_src->name(),
- e_route->dst->name(), e_route->gw_dst->name());
+ XBT_DEBUG("Load bypassASroute from %s@%s to %s@%s", e_route->src->name().c_str(), e_route->gw_src->name().c_str(),
+ e_route->dst->name().c_str(), e_route->gw_dst->name().c_str());
xbt_assert(!e_route->link_list->empty(), "Bypass route between %s@%s and %s@%s cannot be empty.",
- e_route->src->name(), e_route->gw_src->name(), e_route->dst->name(), e_route->gw_dst->name());
+ e_route->src->name().c_str(), e_route->gw_src->name().c_str(), e_route->dst->name().c_str(),
+ e_route->gw_dst->name().c_str());
xbt_assert(bypassRoutes_.find({e_route->src->name(), e_route->dst->name()}) == bypassRoutes_.end(),
- "The bypass route between %s@%s and %s@%s already exists.", e_route->src->name(),
- e_route->gw_src->name(), e_route->dst->name(), e_route->gw_dst->name());
+ "The bypass route between %s@%s and %s@%s already exists.", e_route->src->name().c_str(),
+ e_route->gw_src->name().c_str(), e_route->dst->name().c_str(), e_route->gw_dst->name().c_str());
} else {
- XBT_DEBUG("Load bypassRoute from %s to %s", e_route->src->name(), e_route->dst->name());
- xbt_assert(!e_route->link_list->empty(), "Bypass route between %s and %s cannot be empty.", e_route->src->name(),
- e_route->dst->name());
+ XBT_DEBUG("Load bypassRoute from %s to %s", e_route->src->name().c_str(), e_route->dst->name().c_str());
+ xbt_assert(!e_route->link_list->empty(), "Bypass route between %s and %s cannot be empty.",
+ e_route->src->name().c_str(), e_route->dst->name().c_str());
xbt_assert(bypassRoutes_.find({e_route->src->name(), e_route->dst->name()}) == bypassRoutes_.end(),
- "The bypass route between %s and %s already exists.", e_route->src->name(), e_route->dst->name());
+ "The bypass route between %s and %s already exists.", e_route->src->name().c_str(),
+ e_route->dst->name().c_str());
}
/* Build a copy that will be stored in the dict */
return host_list.at(name); // Will raise a std::out_of_range if the host does not exist
}
Host* Host::by_name_or_null(const char* name)
+{
+ return by_name_or_null(std::string(name));
+}
+Host* Host::by_name_or_null(std::string name)
{
if (host_list.find(name) == host_list.end())
return nullptr;
if (as_cluster->privateLinks_.find(netcard->id()) != as_cluster->privateLinks_.end())
surf_parse_error("Host_link for '%s' is already defined!",hostlink->id);
- XBT_DEBUG("Push Host_link for host '%s' to position %d", netcard->name(), netcard->id());
+ XBT_DEBUG("Push Host_link for host '%s' to position %d", netcard->name().c_str(), netcard->id());
as_cluster->privateLinks_.insert({netcard->id(), link_up_down});
}
*/
void RoutingPlatf::getRouteAndLatency(NetCard *src, NetCard *dst, std::vector<Link*> * route, double *latency)
{
- XBT_DEBUG("getRouteAndLatency from %s to %s", src->name(), dst->name());
+ XBT_DEBUG("getRouteAndLatency from %s to %s", src->name().c_str(), dst->name().c_str());
AsImpl::getRouteRecursive(src, dst, route, latency);
}
*/
class NetCard {
public:
- virtual ~NetCard(){};
+ virtual ~NetCard() = default;
virtual unsigned int id()=0; // Our rank in the vertices_ array of our containing AS.
- virtual char *name()=0;
+ virtual std::string name() = 0;
virtual AsImpl *containingAS()=0; // This is the AS in which I am
virtual bool isAS()=0;
virtual bool isHost()=0;
struct XBT_PRIVATE NetCardImpl : public NetCard {
public:
- NetCardImpl(const char *name, NetCard::Type componentType, AsImpl *containingAS)
- : name_(xbt_strdup(name)),
- componentType_(componentType),
- containingAS_(containingAS)
+ NetCardImpl(std::string name, NetCard::Type componentType, AsImpl* containingAS)
+ : name_(name), componentType_(componentType), containingAS_(containingAS)
{
if (containingAS != nullptr)
id_ = containingAS->addComponent(this);
simgrid::kernel::routing::netcardCreatedCallbacks(this);
}
- ~NetCardImpl() { xbt_free(name_);};
+ ~NetCardImpl() = default;
unsigned int id() override {return id_;}
- char *name() override {return name_;}
+ std::string name() override { return name_; }
AsImpl *containingAS() override {return containingAS_;}
bool isAS() override {return componentType_ == Type::As;}
private:
unsigned int id_;
- char *name_;
+ std::string name_;
NetCard::Type componentType_;
AsImpl *containingAS_;
};