1 /* Copyright (c) 2004-2022. 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/kernel/resource/LinkImpl.hpp"
10 #include "src/kernel/resource/StandardLinkImpl.hpp"
19 /** @ingroup SURF_network_interface
20 * @brief SURF network link interface class
21 * @details A Link represents the link between two [hosts](@ref HostImpl)
23 class SplitDuplexLinkImpl : public LinkImpl {
24 s4u::SplitDuplexLink piface_;
25 StandardLinkImpl* link_up_;
26 StandardLinkImpl* link_down_;
29 SplitDuplexLinkImpl(const StandardLinkImpl&) = delete;
30 SplitDuplexLinkImpl& operator=(const StandardLinkImpl&) = delete;
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_; }
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;
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;
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; }
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(); }
54 /** @brief Check if the Link is used */
55 bool is_used() const override;
57 void turn_on() override;
58 void turn_off() override;
62 void apply_event(profile::Event* event, double value) override;
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;
73 } // namespace resource
75 } // namespace simgrid
77 #endif /* SIMGRID_KERNEL_RESOURCE_SDLINKIMPL_HPP */