Logo AND Algorithmique Numérique Distribuée

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