Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Unify models apis
[simgrid.git] / src / surf / network_cm02.hpp
1 /* Copyright (c) 2013-2014. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #include "network_interface.hpp"
8 #include "xbt/fifo.h"
9 #include "xbt/graph.h"
10
11 #ifndef SURF_NETWORK_CM02_HPP_
12 #define SURF_NETWORK_CM02_HPP_
13
14 /***********
15  * Classes *
16  ***********/
17 class NetworkCm02Model;
18 typedef NetworkCm02Model *NetworkCm02ModelPtr;
19
20 class NetworkCm02Link;
21 typedef NetworkCm02Link *NetworkCm02LinkPtr;
22
23 class NetworkCm02Action;
24 typedef NetworkCm02Action *NetworkCm02ActionPtr;
25
26 /*********
27  * Tools *
28  *********/
29
30 void net_define_callbacks(void);
31
32 /*********
33  * Model *
34  *********/
35 class NetworkCm02Model : public NetworkModel {
36 private:
37   void initialize();
38 public:
39   NetworkCm02Model(int /*i*/) : NetworkModel("network") {
40         f_networkSolve = lmm_solve;
41         m_haveGap = false;
42   };//FIXME: add network clean interface
43   NetworkCm02Model(const char *name) : NetworkModel(name) {
44     this->initialize();
45   }
46   NetworkCm02Model() : NetworkModel("network") {
47     this->initialize();
48   }
49   ~NetworkCm02Model() {
50   }
51   NetworkLinkPtr createNetworkLink(const char *name,
52                                    double bw_initial,
53                                    tmgr_trace_t bw_trace,
54                                    double lat_initial,
55                                    tmgr_trace_t lat_trace,
56                                    e_surf_resource_state_t state_initial,
57                                    tmgr_trace_t state_trace,
58                                    e_surf_link_sharing_policy_t policy,
59                                    xbt_dict_t properties);
60   void addTraces();
61   void updateActionsStateLazy(double now, double delta);
62   ActionPtr communicate(RoutingEdgePtr src, RoutingEdgePtr dst,
63                                            double size, double rate);
64 };
65
66 /************
67  * Resource *
68  ************/
69
70 class NetworkCm02Link : public NetworkLink {
71 public:
72   NetworkCm02Link(NetworkCm02ModelPtr model, const char *name, xbt_dict_t props,
73                                    lmm_system_t system,
74                                    double constraint_value,
75                                    tmgr_history_t history,
76                                    e_surf_resource_state_t state_init,
77                                    tmgr_trace_t state_trace,
78                                    double metric_peak,
79                                    tmgr_trace_t metric_trace,
80                                    double lat_initial,
81                                    tmgr_trace_t lat_trace,
82                                e_surf_link_sharing_policy_t policy);
83   void updateState(tmgr_trace_event_t event_type, double value, double date);
84   void updateBandwidth(double value, double date=surf_get_clock());
85   void updateLatency(double value, double date=surf_get_clock());
86 };
87
88
89 /**********
90  * Action *
91  **********/
92
93 class NetworkCm02Action : public NetworkAction {
94   friend ActionPtr NetworkCm02Model::communicate(RoutingEdgePtr src, RoutingEdgePtr dst, double size, double rate);
95
96 public:
97   NetworkCm02Action(ModelPtr model, double cost, bool failed)
98  : NetworkAction(model, cost, failed) {};
99   void updateRemainingLazy(double now);
100   void recycle();
101 };
102
103 #endif /* SURF_NETWORK_CM02_HPP_ */