Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Misc sonar threats.
[simgrid.git] / src / surf / network_cm02.hpp
1 /* Copyright (c) 2013-2019. 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 "xbt/graph.h"
13 #include "xbt/string.hpp"
14
15 /***********
16  * Classes *
17  ***********/
18
19 namespace simgrid {
20 namespace kernel {
21 namespace resource {
22
23 class XBT_PRIVATE NetworkCm02Model;
24 class XBT_PRIVATE NetworkCm02Action;
25 class XBT_PRIVATE NetworkSmpiModel;
26
27 /*********
28  * Model *
29  *********/
30
31 class NetworkCm02Model : public NetworkModel {
32 public:
33   explicit NetworkCm02Model(lmm::System* (*make_new_sys)(bool) = &lmm::make_new_maxmin_system);
34   virtual ~NetworkCm02Model() = default;
35   LinkImpl* create_link(const std::string& name, const std::vector<double>& bandwidths, double latency,
36                         s4u::Link::SharingPolicy policy) 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 };
41
42 /************
43  * Resource *
44  ************/
45
46 class NetworkCm02Link : public LinkImpl {
47 public:
48   NetworkCm02Link(NetworkCm02Model* model, const std::string& name, double bandwidth, double latency,
49                   s4u::Link::SharingPolicy policy, lmm::System* system);
50   virtual ~NetworkCm02Link() = default;
51   void apply_event(kernel::profile::Event* event, double value) override;
52   void set_bandwidth(double value) override;
53   void set_latency(double value) override;
54 };
55
56 class NetworkWifiLink : public NetworkCm02Link {
57   /** @brief Hold every rates association between host and links (host name, rates id) */
58   std::map<xbt::string, int> host_rates_;
59
60   /** @brief A link can have several bandwith attach to it (mostly use by wifi model) */
61   std::vector<Metric> bandwidths_;
62
63 public:
64   NetworkWifiLink(NetworkCm02Model* model, const std::string& name, std::vector<double> bandwidths,
65                   s4u::Link::SharingPolicy policy, lmm::System* system);
66
67   void set_host_rate(sg_host_t host, int rate_level);
68 };
69
70 /**********
71  * Action *
72  **********/
73 class NetworkCm02Action : public NetworkAction {
74   friend Action* NetworkCm02Model::communicate(s4u::Host* src, s4u::Host* dst, double size, double rate);
75
76 public:
77   NetworkCm02Action(Model* model, double cost, bool failed) : NetworkAction(model, cost, failed){};
78   virtual ~NetworkCm02Action() = default;
79   void update_remains_lazy(double now) override;
80 };
81 }
82 }
83 } // namespace simgrid
84 #endif /* SURF_NETWORK_CM02_HPP_ */