Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix c++ issue with variable set in class body
[simgrid.git] / src / surf / network.hpp
1 #include "surf.hpp"
2 #include "xbt/fifo.h"
3 #include "xbt/graph.h"
4 #include "surf_routing.hpp"
5
6 #ifndef SURF_MODEL_NETWORK_H_
7 #define SURF_MODEL_NETWORK_H_
8
9 /***********
10  * Classes *
11  ***********/
12 class NetworkCm02Model;
13 typedef NetworkCm02Model *NetworkCm02ModelPtr;
14
15 class NetworkCm02Link;
16 typedef NetworkCm02Link *NetworkCm02LinkPtr;
17
18 class NetworkCm02LinkLmm;
19 typedef NetworkCm02LinkLmm *NetworkCm02LinkLmmPtr;
20
21 class NetworkCm02Action;
22 typedef NetworkCm02Action *NetworkCm02ActionPtr;
23
24 class NetworkCm02ActionLmm;
25 typedef NetworkCm02ActionLmm *NetworkCm02ActionLmmPtr;
26
27 /*********
28  * Tools *
29  *********/
30 extern NetworkCm02ModelPtr surf_network_model;
31
32 void net_define_callbacks(void);
33
34 /*********
35  * Model *
36  *********/
37 class NetworkCm02Model : public Model {
38 public:
39   NetworkCm02Model(int i) : Model("network") {
40         f_networkSolve = lmm_solve;
41         m_haveGap = false;
42   };//FIXME: add network clean interface
43   NetworkCm02Model(string name);
44   NetworkCm02Model();
45   //FIXME:NetworkCm02LinkPtr createResource(string name);
46   NetworkCm02LinkLmmPtr createResource(const char *name,
47                                    double bw_initial,
48                                    tmgr_trace_t bw_trace,
49                                    double lat_initial,
50                                    tmgr_trace_t lat_trace,
51                                    e_surf_resource_state_t state_initial,
52                                    tmgr_trace_t state_trace,
53                                    e_surf_link_sharing_policy_t policy,
54                                    xbt_dict_t properties);
55   void updateActionsStateLazy(double now, double delta);
56   virtual void gapAppend(double size, const NetworkCm02LinkLmmPtr link, NetworkCm02ActionLmmPtr action) {};
57   virtual ActionPtr communicate(RoutingEdgePtr src, RoutingEdgePtr dst,
58                                            double size, double rate);
59   xbt_dynar_t getRoute(RoutingEdgePtr src, RoutingEdgePtr dst); //FIXME: kill field? That is done by the routing nowadays
60   //FIXME: virtual void addTraces() =0;
61   void (*f_networkSolve)(lmm_system_t);
62   virtual double latencyFactor(double size);
63   virtual double bandwidthFactor(double size);
64   virtual double bandwidthConstraint(double rate, double bound, double size);
65   bool m_haveGap;
66 };
67
68 /************
69  * Resource *
70  ************/
71
72 class NetworkCm02Link : virtual public Resource {
73 public:
74   NetworkCm02Link(){};
75   NetworkCm02Link(NetworkCm02ModelPtr model, const char* name, xbt_dict_t properties) : Resource(model, name, properties) {};
76   virtual double getBandwidth()=0;
77   virtual double getLatency();
78   virtual bool isShared()=0;
79   /* Using this object with the public part of
80     model does not make sense */
81   double m_latCurrent;
82   tmgr_trace_event_t p_latEvent;
83 };
84
85 class NetworkCm02LinkLmm : public ResourceLmm, public NetworkCm02Link {
86 public:
87   NetworkCm02LinkLmm(NetworkCm02ModelPtr model, const char* name, xbt_dict_t properties)
88    : ResourceLmm(), NetworkCm02Link(model, name, properties) {};
89   NetworkCm02LinkLmm(NetworkCm02ModelPtr model, const char *name, xbt_dict_t props,
90                                    lmm_system_t system,
91                                    double constraint_value,
92                                    tmgr_history_t history,
93                                    e_surf_resource_state_t state_init,
94                                    tmgr_trace_t state_trace,
95                                    double metric_peak,
96                                    tmgr_trace_t metric_trace,
97                                    double lat_initial,
98                                    tmgr_trace_t lat_trace,
99                                e_surf_link_sharing_policy_t policy);
100   bool isShared();
101   bool isUsed();
102   double getBandwidth();
103   void updateState(tmgr_trace_event_t event_type, double value, double date);
104 };
105
106
107 /**********
108  * Action *
109  **********/
110 class NetworkCm02Action : virtual public Action {
111 public:
112   NetworkCm02Action(ModelPtr model, double cost, bool failed)
113  : Action(model, cost, failed) {};
114   double m_latency;
115   double m_latCurrent;
116   double m_weight;
117   double m_rate;
118   const char* p_senderLinkName;
119   double m_senderGap;
120   double m_senderSize;
121   xbt_fifo_item_t p_senderFifoItem;
122 #ifdef HAVE_LATENCY_BOUND_TRACKING
123   int m_latencyLimited;
124 #endif
125
126 };
127
128 class NetworkCm02ActionLmm : public ActionLmm, public NetworkCm02Action {
129 public:
130   NetworkCm02ActionLmm(ModelPtr model, double cost, bool failed)
131  : Action(model, cost, failed),
132    ActionLmm(model, cost, failed),
133    NetworkCm02Action(model, cost, failed) {};
134   void updateRemainingLazy(double now);
135   void recycle();
136 };
137
138 #endif /* SURF_MODEL_NETWORK_H_ */