Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
snake_case routing::NetPoint
[simgrid.git] / include / simgrid / kernel / routing / DijkstraZone.hpp
1 /* Copyright (c) 2013-2018. 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 <simgrid/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
32  * long path resolution times.
33  */
34 class XBT_PRIVATE DijkstraZone : public RoutedZone {
35 public:
36   DijkstraZone(NetZoneImpl* father, std::string name, bool cached);
37   void seal() override;
38
39   ~DijkstraZone() override;
40
41 private:
42   xbt_node_t route_graph_new_node(int id, int graph_id);
43   xbt_node_t node_map_search(int id);
44   void new_route(int src_id, int dst_id, RouteCreationArgs* e_route);
45
46 public:
47   /* For each vertex (node) already in the graph,
48    * make sure it also has a loopback link; this loopback
49    * can potentially already be in the graph, and in that
50    * case nothing will be done.
51    *
52    * If no loopback is specified for a node, we will use
53    * the loopback that is provided by the routing platform.
54    *
55    * After this function returns, any node in the graph
56    * will have a loopback attached to it.
57    */
58   void get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* route, double* lat) override;
59   void add_route(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoint* gw_dst,
60                  std::vector<resource::LinkImpl*>& link_list, bool symmetrical) override;
61
62   xbt_graph_t route_graph_ = nullptr;          /* xbt_graph */
63   std::map<int, xbt_node_t> graph_node_map_;   /* map */
64   bool cached_;                                /* cache mode */
65   std::map<int, std::vector<int>> route_cache_; /* use in cache mode */
66 };
67 } // namespace routing
68 } // namespace kernel
69 } // namespace simgrid
70
71 #endif /* SURF_ROUTING_DIJKSTRA_HPP_ */