Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
simplify writing in model setup + may fix issue with unit-tests
[simgrid.git] / src / surf / 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/surf/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, LinkImpl* link_up, LinkImpl* link_down)
19     : LinkImplIntf(name), piface_(this), link_up_(link_up), link_down_(link_down)
20 {
21 }
22
23 bool SplitDuplexLinkImpl::is_used() const
24 {
25   xbt_die("Impossible to call is_used() in split-duplex links. Call it for each individual link.");
26 }
27
28 void SplitDuplexLinkImpl::set_sharing_policy(s4u::Link::SharingPolicy policy, const s4u::NonLinearResourceCb& cb)
29 {
30   xbt_assert(policy != s4u::Link::SharingPolicy::SPLITDUPLEX && policy != s4u::Link::SharingPolicy::WIFI,
31              "Invalid sharing policy for split-duplex links");
32   link_up_->set_sharing_policy(policy, cb);
33   link_down_->set_sharing_policy(policy, cb);
34 }
35
36 void SplitDuplexLinkImpl::set_bandwidth(double value)
37 {
38   link_up_->set_bandwidth(value);
39   link_down_->set_bandwidth(value);
40 }
41
42 void SplitDuplexLinkImpl::set_latency(double value)
43 {
44   link_up_->set_latency(value);
45   link_down_->set_latency(value);
46 }
47
48 void SplitDuplexLinkImpl::turn_on()
49 {
50   link_up_->turn_on();
51   link_down_->turn_on();
52 }
53
54 void SplitDuplexLinkImpl::turn_off()
55 {
56   link_up_->turn_off();
57   link_down_->turn_off();
58 }
59
60 void SplitDuplexLinkImpl::apply_event(profile::Event* event, double value)
61 {
62   link_up_->apply_event(event, value);
63   link_down_->apply_event(event, value);
64 }
65
66 void SplitDuplexLinkImpl::seal()
67 {
68   if (is_sealed())
69     return;
70
71   link_up_->seal();
72   link_down_->seal();
73
74   Resource::seal();
75 }
76
77 void SplitDuplexLinkImpl::set_bandwidth_profile(profile::Profile* profile)
78 {
79   link_up_->set_bandwidth_profile(profile);
80   link_down_->set_bandwidth_profile(profile);
81 }
82
83 void SplitDuplexLinkImpl::set_latency_profile(profile::Profile* profile)
84 {
85   link_up_->set_latency_profile(profile);
86   link_down_->set_latency_profile(profile);
87 }
88
89 void SplitDuplexLinkImpl::set_concurrency_limit(int limit) const
90 {
91   link_up_->set_concurrency_limit(limit);
92   link_down_->set_concurrency_limit(limit);
93 }
94
95 } // namespace resource
96 } // namespace kernel
97 } // namespace simgrid