}
}
-AS_t model_dijkstra_create(void){
- return new simgrid::surf::AsDijkstra(0);
-}
-
-AS_t model_dijkstracache_create(void){
- return new simgrid::surf::AsDijkstra(1);
-}
+/* Utility functions */
-void model_dijkstra_both_end(AS_t as)
+namespace simgrid {
+namespace surf {
+void AsDijkstra::Seal()
{
- simgrid::surf::AsDijkstra *THIS_AS
- = static_cast<simgrid::surf::AsDijkstra*>(as);
- xbt_node_t node = NULL;
- unsigned int cursor2;
- xbt_dynar_t nodes = NULL;
-
/* Create the topology graph */
- if(!THIS_AS->p_routeGraph)
- THIS_AS->p_routeGraph = xbt_graph_new_graph(1, NULL);
- if(!THIS_AS->p_graphNodeMap)
- THIS_AS->p_graphNodeMap = xbt_dict_new_homogeneous(&graph_node_map_elem_free);
+ if(!p_routeGraph)
+ p_routeGraph = xbt_graph_new_graph(1, NULL);
+ if(!p_graphNodeMap)
+ p_graphNodeMap = xbt_dict_new_homogeneous(&graph_node_map_elem_free);
- if (THIS_AS->m_cached && !THIS_AS->p_routeCache)
- THIS_AS->p_routeCache = xbt_dict_new_homogeneous(&route_cache_elem_free);
+ if (m_cached && !p_routeCache)
+ p_routeCache = xbt_dict_new_homogeneous(&route_cache_elem_free);
/* Add the loopback if needed */
- if (routing_platf->p_loopback && as->p_hierarchy == SURF_ROUTING_BASE)
- THIS_AS->addLoopback();
+ if (routing_platf->p_loopback && hierarchy_ == SURF_ROUTING_BASE)
+ addLoopback();
/* initialize graph indexes in nodes after graph has been built */
- nodes = xbt_graph_get_nodes(THIS_AS->p_routeGraph);
+ xbt_dynar_t nodes = xbt_graph_get_nodes(p_routeGraph);
+ xbt_node_t node = NULL;
+ unsigned int cursor2;
xbt_dynar_foreach(nodes, cursor2, node) {
graph_node_data_t data = (graph_node_data_t) xbt_graph_node_get_data(node);
data->graph_id = cursor2;
}
}
-/* Utility functions */
-
-namespace simgrid {
-namespace surf {
-
xbt_node_t AsDijkstra::routeGraphNewNode(int id, int graph_id)
{
xbt_node_t node = NULL;
int src,dst;
NetCard *src_elm, *dst_elm;
- int table_size = (int)xbt_dynar_length(p_indexNetworkElm);
+ int table_size = (int)xbt_dynar_length(vertices_);
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, NetCard*);
- dst_elm = xbt_dynar_get_as(p_indexNetworkElm, dst, NetCard*);
+ src_elm = xbt_dynar_get_as(vertices_, src, NetCard*);
+ dst_elm = xbt_dynar_get_as(vertices_, 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);
Onelink *onelink;
- if (p_hierarchy == SURF_ROUTING_BASE)
+ if (hierarchy_ == SURF_ROUTING_BASE)
onelink = new Onelink(link, src_elm, dst_elm);
- else if (p_hierarchy == SURF_ROUTING_RECURSIVE)
+ else if (hierarchy_ == SURF_ROUTING_RECURSIVE)
onelink = new Onelink(link, route->gw_src, route->gw_dst);
else
onelink = new Onelink(link, NULL, NULL);
if (v == dst_node_id)
first_gw = gw_dst;
- if (p_hierarchy == SURF_ROUTING_RECURSIVE && v != dst_node_id
+ if (hierarchy_ == SURF_ROUTING_RECURSIVE && v != dst_node_id
&& strcmp(gw_dst->getName(), prev_gw_src->getName())) {
xbt_dynar_t e_route_as_to_as=NULL;
size++;
}
- if (p_hierarchy == SURF_ROUTING_RECURSIVE) {
+ if (hierarchy_ == SURF_ROUTING_RECURSIVE) {
route->gw_src = gw_src;
route->gw_dst = first_gw;
}
/* Creation routing model functions */
-AsDijkstra::AsDijkstra() : AsGeneric() {
-}
-
-AsDijkstra::AsDijkstra(bool cached) : AsGeneric(), m_cached(cached)
+AsDijkstra::AsDijkstra(const char*name, bool cached)
+ : AsGeneric(name)
+ , m_cached(cached)
{
p_routeGraph = NULL;
p_graphNodeMap = NULL;
p_routeCache = xbt_dict_new_homogeneous(&route_cache_elem_free);
/* Add the loopback if needed */
- if (routing_platf->p_loopback && p_hierarchy == SURF_ROUTING_BASE)
+ if (routing_platf->p_loopback && hierarchy_ == SURF_ROUTING_BASE)
addLoopback();
/* initialize graph indexes in nodes after graph has been built */
if (m_cached && !p_routeCache)
p_routeCache = xbt_dict_new_homogeneous(&route_cache_elem_free);
- sg_platf_route_cbarg_t e_route = newExtendedRoute(p_hierarchy, route, 1);
+ sg_platf_route_cbarg_t e_route = newExtendedRoute(hierarchy_, route, 1);
newRoute(src_net_elm->getId(), dst_net_elm->getId(), e_route);
// Symmetrical YES
route->gw_src = route->gw_dst;
route->gw_dst = gw_tmp;
}
- sg_platf_route_cbarg_t link_route_back = newExtendedRoute(p_hierarchy, route, 0);
+ sg_platf_route_cbarg_t link_route_back = newExtendedRoute(hierarchy_, route, 0);
newRoute(dst_net_elm->getId(), src_net_elm->getId(), link_route_back);
}
xbt_dynar_free(&route->link_list);