Logo AND Algorithmique Numérique Distribuée

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