Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
ae5e000bfcddbebbf91f4667a4a338faba5df927
[simgrid.git] / src / surf / surf_routing_dijkstra.hpp
1 /* Copyright (c) 2013-2015. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #include <xbt/base.h>
8
9 #include "surf_routing_RoutedGraph.hpp"
10
11 #ifndef SURF_ROUTING_DIJKSTRA_HPP_
12 #define SURF_ROUTING_DIJKSTRA_HPP_
13
14 typedef struct graph_node_data {
15   int id;
16   int graph_id;                 /* used for caching internal graph id's */
17 } s_graph_node_data_t, *graph_node_data_t;
18
19 typedef struct graph_node_map_element {
20   xbt_node_t node;
21 } s_graph_node_map_element_t, *graph_node_map_element_t;
22
23 typedef struct route_cache_element {
24   int *pred_arr;
25   int size;
26 } s_route_cache_element_t, *route_cache_element_t;
27
28 namespace simgrid {
29 namespace surf {
30
31 /***********
32  * Classes *
33  ***********/
34
35 class XBT_PRIVATE AsDijkstra;
36
37 /** Dijkstra routing data: fast initialization, slow lookup, small memory requirements, shortest path routing only */
38 class AsDijkstra : public AsRoutedGraph {
39 public:
40   AsDijkstra(const char*name, bool cached);
41   void Seal() override;
42
43   ~AsDijkstra();
44   xbt_node_t routeGraphNewNode(int id, int graph_id);
45   graph_node_map_element_t nodeMapSearch(int id);
46   void newRoute(int src_id, int dst_id, sg_platf_route_cbarg_t e_route);
47     /**
48      * For each vertex (node) already in the graph,
49      * make sure it also has a loopback link; this loopback
50      * can potentially already be in the graph, and in that
51      * case nothing will be done.
52      *
53      * If no loopback is specified for a node, we will use
54      * the loopback that is provided by the routing platform.
55      *
56      * After this function returns, any node in the graph
57      * will have a loopback attached to it.
58      */
59   void getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg_t route, double *lat) override;
60   void getRouteAndLatency(sg_platf_route_cbarg_t route, double *lat); // FIXME: this function is dangerously not overriding because of diverging prototype
61   xbt_dynar_t getOneLinkRoutes() override;
62   void addRoute(sg_platf_route_cbarg_t route) override;
63
64   xbt_graph_t routeGraph_ = nullptr;     /* xbt_graph */
65   xbt_dict_t graphNodeMap_ = nullptr;    /* map */
66   xbt_dict_t routeCache_ = nullptr;      /* use in cache mode */
67 };
68
69 }
70 }
71
72 #endif /* SURF_ROUTING_DIJKSTRA_HPP_ */