Logo AND Algorithmique Numérique Distribuée

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