Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
SplitDuplexLinkImpl always have SharingPolicy::SPLITDUPLEX. Use a sdingle assert...
[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   LinkImpl* link_up_;
29   LinkImpl* link_down_;
30
31 protected:
32   SplitDuplexLinkImpl(const LinkImpl&) = delete;
33   SplitDuplexLinkImpl& operator=(const LinkImpl&) = delete;
34
35 public:
36   SplitDuplexLinkImpl(const std::string& name, LinkImpl* link_up, LinkImpl* link_down);
37   /** @brief Public interface */
38   const s4u::SplitDuplexLink* get_iface() const { return &piface_; }
39   s4u::SplitDuplexLink* get_iface() { return &piface_; }
40
41   /** @brief Get the bandwidth in bytes per second of current Link */
42   double get_bandwidth() const override { return link_up_->get_bandwidth(); }
43   void set_bandwidth(double value) override;
44
45   /** @brief Get the latency in seconds of current Link */
46   double get_latency() const override { return link_up_->get_latency(); }
47   void set_latency(double value) override;
48
49   /** @brief The sharing policy */
50   void set_sharing_policy(s4u::Link::SharingPolicy policy) override;
51   s4u::Link::SharingPolicy get_sharing_policy() const override { return s4u::Link::SharingPolicy::SPLITDUPLEX; }
52
53   /** @brief Get link composing this split-duplex link */
54   s4u::Link* get_link_up() const { return link_up_->get_iface(); }
55   s4u::Link* get_link_down() const { return link_down_->get_iface(); }
56
57   /** @brief Check if the Link is used */
58   bool is_used() const override;
59
60   void turn_on() override;
61   void turn_off() override;
62
63   void seal() override;
64
65   void apply_event(profile::Event* event, double value) override;
66
67   /* setup the profile file with bandwidth events (peak speed changes due to external load).
68    * Profile must contain percentages (value between 0 and 1). */
69   void set_bandwidth_profile(kernel::profile::Profile* profile) override;
70   /* setup the profile file with latency events (peak latency changes due to external load).
71    * Profile must contain absolute values */
72   void set_latency_profile(kernel::profile::Profile* profile) override;
73   void set_concurrency_limit(int limit) const override;
74 };
75
76 } // namespace resource
77 } // namespace kernel
78 } // namespace simgrid
79
80 #endif /* SIMGRID_KERNEL_RESOURCE_SDLINKIMPL_HPP */