Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Kill a few globals.
[simgrid.git] / src / kernel / resource / SplitDuplexLinkImpl.hpp
1 /* Copyright (c) 2004-2023. 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 SIMGRID_KERNEL_RESOURCE_SDLINKIMPL_HPP
7 #define SIMGRID_KERNEL_RESOURCE_SDLINKIMPL_HPP
8
9 #include "src/kernel/resource/LinkImpl.hpp"
10 #include "src/kernel/resource/StandardLinkImpl.hpp"
11
12 namespace simgrid::kernel::resource {
13
14 /************
15  * Resource *
16  ************/
17 /** @ingroup SURF_network_interface
18  * @brief SURF network link interface class
19  * @details A Link represents the link between two [hosts](@ref HostImpl)
20  */
21 class SplitDuplexLinkImpl : public LinkImpl {
22   s4u::SplitDuplexLink piface_;
23   StandardLinkImpl* link_up_;
24   StandardLinkImpl* link_down_;
25
26 protected:
27   SplitDuplexLinkImpl(const StandardLinkImpl&) = delete;
28   SplitDuplexLinkImpl& operator=(const StandardLinkImpl&) = delete;
29
30 public:
31   SplitDuplexLinkImpl(const std::string& name, StandardLinkImpl* link_up, StandardLinkImpl* link_down);
32   /** @brief Public interface */
33   const s4u::SplitDuplexLink* get_iface() const { return &piface_; }
34   s4u::SplitDuplexLink* get_iface() { return &piface_; }
35
36   /** @brief Get the bandwidth in bytes per second of current Link */
37   double get_bandwidth() const override { return link_up_->get_bandwidth(); }
38   void set_bandwidth(double value) override;
39
40   /** @brief Get the latency in seconds of current Link */
41   double get_latency() const override { return link_up_->get_latency(); }
42   void set_latency(double value) override;
43
44   /** @brief The sharing policy */
45   void set_sharing_policy(s4u::Link::SharingPolicy policy, const s4u::NonLinearResourceCb& cb) override;
46   s4u::Link::SharingPolicy get_sharing_policy() const override { return s4u::Link::SharingPolicy::SPLITDUPLEX; }
47
48   /** @brief Get link composing this split-duplex link */
49   s4u::Link* get_link_up() const { return link_up_->get_iface(); }
50   s4u::Link* get_link_down() const { return link_down_->get_iface(); }
51
52   /** @brief Check if the Link is used */
53   bool is_used() const override;
54
55   void turn_on() override;
56   void turn_off() override;
57
58   void seal() override;
59
60   void apply_event(profile::Event* event, double value) override;
61
62   /* setup the profile file with bandwidth events (peak speed changes due to external load).
63    * Profile must contain percentages (value between 0 and 1). */
64   void set_bandwidth_profile(kernel::profile::Profile* profile) override;
65   /* setup the profile file with latency events (peak latency changes due to external load).
66    * Profile must contain absolute values */
67   void set_latency_profile(kernel::profile::Profile* profile) override;
68   void set_concurrency_limit(int limit) const override;
69 };
70
71 } // namespace simgrid::kernel::resource
72
73 #endif /* SIMGRID_KERNEL_RESOURCE_SDLINKIMPL_HPP */