Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
NetworkModelIntf: Interface to dynamic factors
[simgrid.git] / src / surf / network_cm02.hpp
1 /* Copyright (c) 2013-2021. The SimGrid Team. All rights reserved.          */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5
6 #ifndef SURF_NETWORK_CM02_HPP_
7 #define SURF_NETWORK_CM02_HPP_
8
9 #include <xbt/base.h>
10
11 #include "network_interface.hpp"
12 #include "simgrid/kernel/resource/NetworkModelIntf.hpp"
13 #include "xbt/graph.h"
14 #include "xbt/string.hpp"
15
16 /***********
17  * Classes *
18  ***********/
19
20 namespace simgrid {
21 namespace kernel {
22 namespace resource {
23
24 class XBT_PRIVATE NetworkCm02Model;
25 class XBT_PRIVATE NetworkCm02Action;
26 class XBT_PRIVATE NetworkSmpiModel;
27
28 /*********
29  * Model *
30  *********/
31
32 class NetworkCm02Model : public NetworkModel {
33 public:
34   explicit NetworkCm02Model(const std::string& name);
35   LinkImpl* create_link(const std::string& name, const std::vector<double>& bandwidths) final;
36   LinkImpl* create_wifi_link(const std::string& name, const std::vector<double>& bandwidths) override;
37   void update_actions_state_lazy(double now, double delta) override;
38   void update_actions_state_full(double now, double delta) override;
39   Action* communicate(s4u::Host* src, s4u::Host* dst, double size, double rate) override;
40   void set_lat_factor_cb(const std::function<NetworkFactorCb>& cb) override;
41   void set_bw_factor_cb(const std::function<NetworkFactorCb>& cb) override;
42
43 protected:
44   virtual void check_lat_factor_cb();
45   virtual void check_bw_factor_cb();
46   std::function<NetworkFactorCb> lat_factor_cb_;
47   std::function<NetworkFactorCb> bw_factor_cb_;
48 };
49
50 /************
51  * Resource *
52  ************/
53
54 class NetworkCm02Link : public LinkImpl {
55 public:
56   NetworkCm02Link(const std::string& name, double bandwidth, lmm::System* system);
57   void apply_event(kernel::profile::Event* event, double value) override;
58   void set_bandwidth(double value) override;
59   LinkImpl* set_latency(double value) override;
60 };
61
62 /**********
63  * Action *
64  **********/
65 class NetworkCm02Action : public NetworkAction {
66   friend Action* NetworkCm02Model::communicate(s4u::Host* src, s4u::Host* dst, double size, double rate);
67
68 public:
69   using NetworkAction::NetworkAction;
70   void update_remains_lazy(double now) override;
71 };
72 } // namespace resource
73 } // namespace kernel
74 } // namespace simgrid
75 #endif /* SURF_NETWORK_CM02_HPP_ */