From 3ebf3e57d4c67aea514a515aa7ede30adeed347a Mon Sep 17 00:00:00 2001 From: navarrop Date: Mon, 22 Nov 2010 14:29:33 +0000 Subject: [PATCH] Add function generic_new_route. git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@8605 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- src/surf/surf_routing.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/src/surf/surf_routing.c b/src/surf/surf_routing.c index 7a6b6084a4..a077caa54b 100644 --- a/src/surf/surf_routing.c +++ b/src/surf/surf_routing.c @@ -134,6 +134,9 @@ static route_extended_t generic_get_bypassroute(routing_component_t rc, static route_extended_t generic_new_extended_route(e_surf_routing_hierarchy_t hierarchy, void *data, int order); +static route_t +generic_new_route(e_surf_routing_hierarchy_t hierarchy, + void *data, int order); static void generic_free_route(route_t route); static void generic_free_extended_route(route_extended_t e_route); static routing_component_t @@ -2816,6 +2819,44 @@ static route_extended_t generic_get_bypassroute(routing_component_t rc, /* ************************************************************************** */ /* ************************* GENERIC AUX FUNCTIONS ************************** */ +static route_t +generic_new_route(e_surf_routing_hierarchy_t hierarchy, + void *data, int order) +{ + + char *link_name; + route_t new_route; + unsigned int cpt; + xbt_dynar_t links = NULL, links_id = NULL; + + new_route = xbt_new0(s_route_t, 1); + new_route->link_list = + xbt_dynar_new(global_routing->size_of_link, NULL); + + xbt_assert0(hierarchy == SURF_ROUTING_BASE, + "the hierarchy type is not SURF_ROUTING_BASE"); + + links = ((route_t) data)->link_list; + + + links_id = new_route->link_list; + + xbt_dynar_foreach(links, cpt, link_name) { + + void *link = + xbt_dict_get_or_null(surf_network_model->resource_set, link_name); + if (link) { + if (order) + xbt_dynar_push(links_id, &link); + else + xbt_dynar_unshift(links_id, &link); + } else + THROW1(mismatch_error, 0, "Link %s not found", link_name); + } + + return new_route; +} + static route_extended_t generic_new_extended_route(e_surf_routing_hierarchy_t hierarchy, void *data, int order) -- 2.20.1