Logo AND Algorithmique Numérique Distribuée

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