Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
5a1de77adbc561f91917e9c7d9eb529293d868c3
[simgrid.git] / src / surf / surf_routing.hpp
1 #include "surf_interface.hpp"
2 #include <float.h>
3
4 #ifndef NETWORK_ROUTING_HPP_
5 #define NETWORK_ROUTING_HPP_
6
7 void routing_model_create( void *loopback);
8
9 /* ************************************************************************** */
10 /* ************************* GRAPH EXPORTING FUNCTIONS ********************** */
11 xbt_node_t new_xbt_graph_node (xbt_graph_t graph, const char *name, xbt_dict_t nodes);
12 xbt_edge_t new_xbt_graph_edge (xbt_graph_t graph, xbt_node_t s, xbt_node_t d, xbt_dict_t edges);
13
14 /***********
15  * Classes *
16  ***********/
17 class As;
18 typedef As *AsPtr;
19
20 class RoutingModelDescription;
21 typedef RoutingModelDescription *RoutingModelDescriptionPtr;
22
23 class RoutingEdge;
24 typedef RoutingEdge *RoutingEdgePtr;
25
26 class Onelink;
27 typedef Onelink *OnelinkPtr;
28
29 class RoutingPlatf;
30 typedef RoutingPlatf *RoutingPlatfPtr;
31
32 /** @ingroup SURF_routing_interface
33  * @brief The Autonomous System (AS) routing interface
34  * @details [TODO]
35  */
36 class As {
37 public:
38   xbt_dynar_t p_indexNetworkElm;
39   xbt_dict_t p_bypassRoutes;    /* store bypass routes */
40   routing_model_description_t p_modelDesc;
41   e_surf_routing_hierarchy_t p_hierarchy;
42   char *p_name;
43   AsPtr p_routingFather;
44   xbt_dict_t p_routingSons;
45   RoutingEdgePtr p_netElem;
46   xbt_dynar_t p_linkUpDownList;
47
48   /**
49    * @brief The As constructor
50    */
51   As(){};
52
53   /**
54    * @brief The As destructor
55    */
56   virtual ~As(){
57         xbt_free(p_name);
58   };
59
60   /**
61    * @brief Get the route and latency between two RoutingEdgs
62    * @details [long description]
63    * 
64    * @param src [description]
65    * @param dst [description]
66    * @param into [description]
67    * @param latency [description]
68    */
69   virtual void getRouteAndLatency(RoutingEdgePtr src, RoutingEdgePtr dst, sg_platf_route_cbarg_t into, double *latency)=0;
70   virtual xbt_dynar_t getOneLinkRoutes()=0;
71   virtual void getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges)=0;
72   virtual sg_platf_route_cbarg_t getBypassRoute(RoutingEdgePtr src, RoutingEdgePtr dst, double *lat)=0;
73
74   /* The parser calls the following functions to inform the routing models
75    * that a new element is added to the AS currently built.
76    *
77    * Of course, only the routing model of this AS is informed, not every ones */
78   virtual int parsePU(RoutingEdgePtr elm)=0; /* A host or a router, whatever */
79   virtual int parseAS( RoutingEdgePtr elm)=0;
80   virtual void parseRoute(sg_platf_route_cbarg_t route)=0;
81   virtual void parseASroute(sg_platf_route_cbarg_t route)=0;
82   virtual void parseBypassroute(sg_platf_route_cbarg_t e_route)=0;
83 };
84
85 /** @ingroup SURF_routing_interface
86  * @brief A routing edge
87  * @details [long description]
88  */
89 class RoutingEdge {
90 public:
91   ~RoutingEdge() { xbt_free(p_name);};
92   AsPtr p_rcComponent;
93   e_surf_network_element_type_t p_rcType;
94   int m_id;
95   char *p_name;
96 };
97
98
99 /** @ingroup SURF_routing_interface
100  * @brief Link of lenght 1, alongside with its source and destination. This is mainly usefull in the bindings to gtnets and ns3
101  */
102 class Onelink {
103 public:
104   Onelink(void *link, RoutingEdgePtr src, RoutingEdgePtr dst)
105     : p_src(src), p_dst(dst), p_link(link) {};
106   RoutingEdgePtr p_src;
107   RoutingEdgePtr p_dst;
108   void *p_link;
109 };
110
111 /** @ingroup SURF_routing_interface
112  * @brief The class representing a whole routing platform
113  */
114 class RoutingPlatf {
115 public:
116   ~RoutingPlatf();
117   AsPtr p_root;
118   void *p_loopback;
119   xbt_dynar_t p_lastRoute;
120   xbt_dynar_t getOneLinkRoutes(void);
121   xbt_dynar_t recursiveGetOneLinkRoutes(AsPtr rc);
122   void getRouteAndLatency(RoutingEdgePtr src, RoutingEdgePtr dst, xbt_dynar_t * links, double *latency);
123 };
124
125 #endif /* NETWORK_ROUTING_HPP_ */