1 /* Copyright (c) 2004-2021. The SimGrid Team. All rights reserved. */
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. */
6 #ifndef SIMGRID_KERNEL_RESOURCE_SDLINKIMPL_HPP
7 #define SIMGRID_KERNEL_RESOURCE_SDLINKIMPL_HPP
9 #include "src/surf/LinkImpl.hpp"
10 #include "src/surf/LinkImplIntf.hpp"
22 /** @ingroup SURF_network_interface
23 * @brief SURF network link interface class
24 * @details A Link represents the link between two [hosts](@ref HostImpl)
26 class SplitDuplexLinkImpl : public LinkImplIntf {
27 s4u::SplitDuplexLink piface_;
32 SplitDuplexLinkImpl(const LinkImpl&) = delete;
33 SplitDuplexLinkImpl& operator=(const LinkImpl&) = delete;
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_; }
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;
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;
49 /** @brief The sharing policy */
50 void set_sharing_policy(s4u::Link::SharingPolicy policy, const s4u::NonLinearResourceCb& cb) override;
51 s4u::Link::SharingPolicy get_sharing_policy() const override { return s4u::Link::SharingPolicy::SPLITDUPLEX; }
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(); }
57 /** @brief Check if the Link is used */
58 bool is_used() const override;
60 void turn_on() override;
61 void turn_off() override;
65 void apply_event(profile::Event* event, double value) override;
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;
76 } // namespace resource
78 } // namespace simgrid
80 #endif /* SIMGRID_KERNEL_RESOURCE_SDLINKIMPL_HPP */