Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
6f7a5682fd33d2e4f0409fc80706dbe3c45f5e23
[simgrid.git] / src / surf / surf_routing.hpp
1 #include "surf.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
33 /*FIXME:class RoutingModelDescription {
34   const char *p_name;
35   const char *p_desc;
36   AsPtr create();
37   void end(AsPtr as);
38 };*/
39
40 class As {
41 public:
42   xbt_dynar_t p_indexNetworkElm;
43   xbt_dict_t p_bypassRoutes;    /* store bypass routes */
44   routing_model_description_t p_modelDesc;
45   e_surf_routing_hierarchy_t p_hierarchy;
46   char *p_name;
47   AsPtr p_routingFather;
48   xbt_dict_t p_routingSons;
49   RoutingEdgePtr p_netElem;
50   xbt_dynar_t p_linkUpDownList;
51
52   As(){};
53   virtual ~As(){};
54
55   virtual void getRouteAndLatency(RoutingEdgePtr src, RoutingEdgePtr dst, sg_platf_route_cbarg_t into, double *latency)=0;
56   virtual xbt_dynar_t getOneLinkRoutes()=0;
57   virtual void getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges)=0;
58   virtual sg_platf_route_cbarg_t getBypassRoute(RoutingEdgePtr src, RoutingEdgePtr dst, double *lat)=0;
59
60   /* The parser calls the following functions to inform the routing models
61    * that a new element is added to the AS currently built.
62    *
63    * Of course, only the routing model of this AS is informed, not every ones */
64   virtual int parsePU(RoutingEdgePtr elm)=0; /* A host or a router, whatever */
65   virtual int parseAS( RoutingEdgePtr elm)=0;
66   virtual void parseRoute(sg_platf_route_cbarg_t route)=0;
67   virtual void parseASroute(sg_platf_route_cbarg_t route)=0;
68   virtual void parseBypassroute(sg_platf_route_cbarg_t e_route)=0;
69 };
70
71 class RoutingEdge {
72 public:
73   AsPtr p_rcComponent;
74   e_surf_network_element_type_t p_rcType;
75   int m_id;
76   char *p_name;
77 };
78
79 /*
80  * Link of lenght 1, alongside with its source and destination. This is mainly usefull in the bindings to gtnets and ns3
81  */
82 class Onelink {
83 public:
84   Onelink(void *link, RoutingEdgePtr src, RoutingEdgePtr dst)
85     : p_src(src), p_dst(dst), p_link(link) {};
86   RoutingEdgePtr p_src;
87   RoutingEdgePtr p_dst;
88   void *p_link;
89 };
90
91 class RoutingPlatf {
92 public:
93   AsPtr p_root;
94   void *p_loopback;
95   xbt_dynar_t p_lastRoute;
96   xbt_dynar_t getOneLinkRoutes(void);
97   xbt_dynar_t recursiveGetOneLinkRoutes(AsPtr rc);
98   void getRouteAndLatency(RoutingEdgePtr src, RoutingEdgePtr dst, xbt_dynar_t * links, double *latency);
99 };
100
101 #endif /* NETWORK_ROUTING_HPP_ */