Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' into actor-yield
[simgrid.git] / src / kernel / routing / DijkstraZone.hpp
1 /* Copyright (c) 2013-2017. 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/kernel/routing/RoutedZone.hpp"
10
11 struct s_graph_node_data_t {
12   int id;
13   int graph_id; /* used for caching internal graph id's */
14 };
15 typedef s_graph_node_data_t* graph_node_data_t;
16
17 namespace simgrid {
18 namespace kernel {
19 namespace routing {
20
21 /***********
22  * Classes *
23  ***********/
24
25 /** @ingroup ROUTING_API
26  *  @brief NetZone with an explicit routing computed on need with Dijsktra
27  *
28  *  The path between components is computed each time you request it,
29  *  using the Dijkstra algorithm. A cache can be used to reduce the computation.
30  *
31  *  This result in rather small platform file, very fast initialization, and very low memory requirements, but somehow long path resolution times.
32  */
33 class XBT_PRIVATE DijkstraZone : public RoutedZone {
34 public:
35   DijkstraZone(NetZone* father, std::string name, bool cached);
36   void seal() override;
37
38   ~DijkstraZone() override;
39   xbt_node_t routeGraphNewNode(int id, int graph_id);
40   xbt_node_t nodeMapSearch(int id);
41   void newRoute(int src_id, int dst_id, sg_platf_route_cbarg_t e_route);
42   /* For each vertex (node) already in the graph,
43    * make sure it also has a loopback link; this loopback
44    * can potentially already be in the graph, and in that
45    * case nothing will be done.
46    *
47    * If no loopback is specified for a node, we will use
48    * the loopback that is provided by the routing platform.
49    *
50    * After this function returns, any node in the graph
51    * will have a loopback attached to it.
52    */
53   void getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cbarg_t route, double* lat) override;
54   void addRoute(sg_platf_route_cbarg_t route) override;
55
56   xbt_graph_t routeGraph_  = nullptr; /* xbt_graph */
57   std::map<int, xbt_node_t> graphNodeMap_;     /* map */
58   bool cached_;                                /* cache mode */
59   std::map<int, std::vector<int>> routeCache_; /* use in cache mode */
60 };
61 }
62 }
63 } // namespaces
64
65 #endif /* SURF_ROUTING_DIJKSTRA_HPP_ */