XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_routing_generic, surf_route, "Generic implementation of the surf routing");
+static int no_bypassroute_declared = 1;
+
AS_t model_generic_create_sized(size_t childsize) {
AS_t new_component = model_none_create_sized(childsize);
new_component->parse_route = NULL;
new_component->parse_ASroute = NULL;
new_component->parse_bypassroute = generic_parse_bypassroute;
- new_component->get_route = NULL;
- new_component->get_latency = generic_get_link_latency;
+ new_component->get_route_and_latency = NULL;
new_component->get_onelink_routes = NULL;
new_component->get_bypass_route =
generic_get_bypassroute;
new_component->finalize = model_generic_finalize;
- new_component->to_index = xbt_dict_new();
- new_component->bypassRoutes = xbt_dict_new();
+ new_component->to_index = xbt_dict_new_homogeneous(xbt_free);
+ new_component->bypassRoutes = xbt_dict_new_homogeneous((void (*)(void *)) generic_free_route);
return new_component;
}
xbt_dict_t _to_index;
_to_index = as->to_index;
*id = xbt_dict_length(_to_index);
- xbt_dict_set(_to_index, name, id, xbt_free);
+ xbt_dict_set(_to_index, name, id, NULL);
}
void generic_parse_AS(AS_t as, const char *name)
xbt_dict_t _to_index;
_to_index = as->to_index;
*id = xbt_dict_length(_to_index);
- xbt_dict_set(_to_index, name, id, xbt_free);
+ xbt_dict_set(_to_index, name, id, NULL);
}
void generic_parse_bypassroute(AS_t rc,
xbt_dynar_free(&(e_route->link_list));
xbt_free(e_route);
- xbt_dict_set(dict_bypassRoutes, route_name, new_e_route,
- (void (*)(void *)) generic_free_route);
+ xbt_dict_set(dict_bypassRoutes, route_name, new_e_route, NULL);
+ no_bypassroute_declared = 0;
xbt_free(route_name);
}
/* ************************************************************************** */
/* *********************** GENERIC BUSINESS METHODS ************************* */
-double generic_get_link_latency(AS_t rc,
- const char *src, const char *dst,
- route_t route)
-{
- int need_to_clean = route ? 0 : 1;
- void *link;
- unsigned int i;
- double latency = 0.0;
-
- if (route == NULL) {
- route = xbt_new0(s_route_t, 1);
- route->link_list = xbt_dynar_new(global_routing->size_of_link, NULL);
- rc->get_route(rc, src, dst, route);
- }
-
- xbt_dynar_foreach(route->link_list, i, link) {
- latency += surf_network_model->extension.network.get_link_latency(link);
- }
- if (need_to_clean)
- generic_free_route(route);
- return latency;
-}
-
-xbt_dynar_t generic_get_onelink_routes(AS_t rc)
-{
+xbt_dynar_t generic_get_onelink_routes(AS_t rc) { // FIXME: kill that stub
xbt_die("\"generic_get_onelink_routes\" not implemented yet");
+ return NULL;
}
-route_t generic_get_bypassroute(AS_t rc,
- const char *src, const char *dst)
+route_t generic_get_bypassroute(AS_t rc, const char *src, const char *dst)
{
+ // If never set a bypass route return NULL without any further computations
+ if(no_bypassroute_declared)
+ return NULL;
+
xbt_dict_t dict_bypassRoutes = rc->bypassRoutes;
AS_t src_as, dst_as;
int index_src, index_dst;