Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'battery-get-name' into 'master'
[simgrid.git] / src / kernel / resource / SplitDuplexLinkImpl.cpp
1 /* Copyright (c) 2013-2023. 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 #include "src/kernel/resource/SplitDuplexLinkImpl.hpp"
7
8 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(res_network);
9
10 /*********
11  * Model *
12  *********/
13
14 namespace simgrid::kernel::resource {
15
16 SplitDuplexLinkImpl::SplitDuplexLinkImpl(const std::string& name, StandardLinkImpl* link_up,
17                                          StandardLinkImpl* link_down)
18     : LinkImpl(name), piface_(this), link_up_(link_up), link_down_(link_down)
19 {
20 }
21
22 bool SplitDuplexLinkImpl::is_used() const
23 {
24   return link_up_->is_used() || link_down_->is_used();
25 }
26
27 void SplitDuplexLinkImpl::set_sharing_policy(s4u::Link::SharingPolicy policy, const s4u::NonLinearResourceCb& cb)
28 {
29   xbt_assert(policy != s4u::Link::SharingPolicy::SPLITDUPLEX && policy != s4u::Link::SharingPolicy::WIFI,
30              "Invalid sharing policy for split-duplex links");
31   link_up_->set_sharing_policy(policy, cb);
32   link_down_->set_sharing_policy(policy, cb);
33 }
34
35 void SplitDuplexLinkImpl::set_bandwidth(double value)
36 {
37   link_up_->set_bandwidth(value);
38   link_down_->set_bandwidth(value);
39 }
40
41 void SplitDuplexLinkImpl::set_latency(double value)
42 {
43   link_up_->set_latency(value);
44   link_down_->set_latency(value);
45 }
46
47 void SplitDuplexLinkImpl::turn_on()
48 {
49   link_up_->turn_on();
50   link_down_->turn_on();
51 }
52
53 void SplitDuplexLinkImpl::turn_off()
54 {
55   link_up_->turn_off();
56   link_down_->turn_off();
57 }
58
59 void SplitDuplexLinkImpl::apply_event(profile::Event* event, double value)
60 {
61   link_up_->apply_event(event, value);
62   link_down_->apply_event(event, value);
63 }
64
65 void SplitDuplexLinkImpl::seal()
66 {
67   if (is_sealed())
68     return;
69
70   link_up_->seal();
71   link_down_->seal();
72
73   Resource::seal();
74 }
75
76 void SplitDuplexLinkImpl::set_bandwidth_profile(profile::Profile* profile)
77 {
78   link_up_->set_bandwidth_profile(profile);
79   link_down_->set_bandwidth_profile(profile);
80 }
81
82 void SplitDuplexLinkImpl::set_latency_profile(profile::Profile* profile)
83 {
84   link_up_->set_latency_profile(profile);
85   link_down_->set_latency_profile(profile);
86 }
87
88 int SplitDuplexLinkImpl::get_concurrency_limit() const
89 {
90   return link_up_->get_concurrency_limit();
91 }
92
93 void SplitDuplexLinkImpl::set_concurrency_limit(int limit) const
94 {
95   link_up_->set_concurrency_limit(limit);
96   link_down_->set_concurrency_limit(limit);
97 }
98
99 } // namespace simgrid::kernel::resource