Logo AND Algorithmique Numérique Distribuée

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