-/* Copyright (c) 2009-2014. The SimGrid Team.
+/* Copyright (c) 2009-2015. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
AS_t model_floyd_create(void)
{
- return new AsFloyd();
+ return new simgrid::surf::AsFloyd();
}
void model_floyd_end(AS_t current_routing)
{
- static_cast<AsFloydPtr>(current_routing)->end();
+ static_cast<simgrid::surf::AsFloyd*>(current_routing)->end();
}
+namespace simgrid {
+namespace surf {
+
AsFloyd::AsFloyd(): AsGeneric() {
p_predecessorTable = NULL;
p_costTable = NULL;
int i, j;
int table_size;
table_size = (int)xbt_dynar_length(p_indexNetworkElm);
- /* Delete link_table */
- for (i = 0; i < table_size; i++)
- for (j = 0; j < table_size; j++)
- generic_free_route(TO_FLOYD_LINK(i, j));
- xbt_free(p_linkTable);
- /* Delete bypass dict */
- xbt_dict_free(&p_bypassRoutes);
- /* Delete predecessor and cost table */
- xbt_free(p_predecessorTable);
- xbt_free(p_costTable);
+ if (p_linkTable == NULL) // Dealing with a parse error in the file?
+ return;
+ /* Delete link_table */
+ for (i = 0; i < table_size; i++)
+ for (j = 0; j < table_size; j++) {
+ generic_free_route(TO_FLOYD_LINK(i, j));
+ }
+ xbt_free(p_linkTable);
+ /* Delete bypass dict */
+ xbt_dict_free(&p_bypassRoutes);
+ /* Delete predecessor and cost table */
+ xbt_free(p_predecessorTable);
+ xbt_free(p_costTable);
}
/* Business methods */
xbt_dynar_t AsFloyd::getOneLinkRoutes()
{
- xbt_dynar_t ret = xbt_dynar_new(sizeof(OnelinkPtr), xbt_free);
+ 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 = xbt_dynar_new(sizeof(sg_routing_link_t), NULL);
int src,dst;
- sg_routing_edge_t src_elm, dst_elm;
+ sg_netcard_t src_elm, dst_elm;
int table_size = xbt_dynar_length(p_indexNetworkElm);
for(src=0; src < table_size; src++) {
for(dst=0; dst< table_size; dst++) {
xbt_dynar_reset(route->link_list);
- src_elm = xbt_dynar_get_as(p_indexNetworkElm, src, RoutingEdgePtr);
- dst_elm = xbt_dynar_get_as(p_indexNetworkElm, dst, RoutingEdgePtr);
+ src_elm = xbt_dynar_get_as(p_indexNetworkElm, src, NetCard*);
+ dst_elm = xbt_dynar_get_as(p_indexNetworkElm, dst, NetCard*);
this->getRouteAndLatency(src_elm, dst_elm, route, NULL);
if (xbt_dynar_length(route->link_list) == 1) {
void *link = *(void **) xbt_dynar_get_ptr(route->link_list, 0);
- OnelinkPtr onelink;
+ Onelink *onelink;
if (p_hierarchy == SURF_ROUTING_BASE)
onelink = new Onelink(link, src_elm, dst_elm);
else if (p_hierarchy == SURF_ROUTING_RECURSIVE)
return ret;
}
-void AsFloyd::getRouteAndLatency(RoutingEdgePtr src, RoutingEdgePtr dst, sg_platf_route_cbarg_t res, double *lat)
+void AsFloyd::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg_t res, double *lat)
{
/* set utils vars */
res->gw_dst = xbt_dynar_getfirst_as(route_stack, sg_platf_route_cbarg_t)->gw_dst;
}
- sg_routing_edge_t prev_dst_gw = NULL;
+ sg_netcard_t prev_dst_gw = NULL;
while (!xbt_dynar_is_empty(route_stack)) {
sg_platf_route_cbarg_t e_route = xbt_dynar_pop_as(route_stack, sg_platf_route_cbarg_t);
xbt_dynar_t links;
xbt_dynar_foreach(links, cpt, link) {
xbt_dynar_push_as(res->link_list, sg_routing_link_t, link);
if (lat)
- *lat += static_cast<NetworkLinkPtr>(link)->getLatency();
+ *lat += static_cast<Link*>(link)->getLatency();
}
prev_dst_gw = e_route->gw_dst;
/* set the size of table routing */
int table_size = (int)xbt_dynar_length(p_indexNetworkElm);
- RoutingEdgePtr src_net_elm, dst_net_elm;
+ NetCard *src_net_elm, *dst_net_elm;
- src_net_elm = sg_routing_edge_by_name_or_null(src);
- dst_net_elm = sg_routing_edge_by_name_or_null(dst);
+ src_net_elm = sg_netcard_by_name_or_null(src);
+ dst_net_elm = sg_netcard_by_name_or_null(dst);
xbt_assert(src_net_elm, "Network elements %s not found", src);
xbt_assert(dst_net_elm, "Network elements %s not found", dst);
XBT_DEBUG("Load ASroute from \"%s(%s)\" to \"%s(%s)\"", src,
route->gw_src->getName(), dst, route->gw_dst->getName());
if(route->gw_dst->getRcType() == SURF_NETWORK_ELEMENT_NULL)
- xbt_die("The dst_gateway '%s' does not exist!",route->gw_dst->getName());
+ surf_parse_error("The dst_gateway '%s' does not exist!",route->gw_dst->getName());
if(route->gw_src->getRcType() == SURF_NETWORK_ELEMENT_NULL)
- xbt_die("The src_gateway '%s' does not exist!",route->gw_src->getName());
+ surf_parse_error("The src_gateway '%s' does not exist!",route->gw_src->getName());
}
if(TO_FLOYD_LINK(src_net_elm->getId(), dst_net_elm->getId()))
xbt_dynar_t link_route_to_test = xbt_dynar_new(sizeof(sg_routing_link_t), NULL);
xbt_dynar_foreach(route->link_list,cpt,link_name)
{
- void *link = xbt_lib_get_or_null(link_lib, link_name, SURF_LINK_LEVEL);
+ void *link = Link::byName(link_name);
xbt_assert(link,"Link : '%s' doesn't exists.",link_name);
xbt_dynar_push(link_route_to_test,&link);
}
for(i=xbt_dynar_length(route->link_list) ;i>0 ;i--)
{
link_name = xbt_dynar_get_as(route->link_list,i-1,char *);
- void *link = xbt_lib_get_or_null(link_lib, link_name, SURF_LINK_LEVEL);
+ void *link = Link::byName(link_name);
xbt_assert(link,"Link : '%s' doesn't exists.",link_name);
xbt_dynar_push(link_route_to_test,&link);
}
{
if(route->gw_dst && route->gw_src)
{
- sg_routing_edge_t gw_src = route->gw_src;
- sg_routing_edge_t gw_dst = route->gw_dst;
+ sg_netcard_t gw_src = route->gw_src;
+ sg_netcard_t gw_dst = route->gw_dst;
route->gw_src = gw_dst;
route->gw_dst = gw_src;
}
}
}
}
+
+}
+}