Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
329955a538a0502b1a32cc36430aa2176b27e619
[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)
29 {
30   xbt_die("Impossible to change sharing policy of split-duplex links");
31 }
32
33 s4u::Link::SharingPolicy SplitDuplexLinkImpl::get_sharing_policy() const
34 {
35   return sharing_policy_;
36 }
37
38 void SplitDuplexLinkImpl::set_bandwidth(double value)
39 {
40   link_up_->set_bandwidth(value);
41   link_down_->set_bandwidth(value);
42 }
43
44 void SplitDuplexLinkImpl::set_latency(double value)
45 {
46   link_up_->set_latency(value);
47   link_down_->set_latency(value);
48 }
49
50 void SplitDuplexLinkImpl::turn_on()
51 {
52   link_up_->turn_on();
53   link_down_->turn_on();
54 }
55
56 void SplitDuplexLinkImpl::turn_off()
57 {
58   link_up_->turn_off();
59   link_down_->turn_off();
60 }
61
62 void SplitDuplexLinkImpl::apply_event(profile::Event* event, double value)
63 {
64   link_up_->apply_event(event, value);
65   link_down_->apply_event(event, value);
66 }
67
68 void SplitDuplexLinkImpl::seal()
69 {
70   if (is_sealed())
71     return;
72
73   link_up_->seal();
74   link_down_->seal();
75
76   Resource::seal();
77 }
78
79 void SplitDuplexLinkImpl::set_bandwidth_profile(profile::Profile* profile)
80 {
81   link_up_->set_bandwidth_profile(profile);
82   link_down_->set_bandwidth_profile(profile);
83 }
84
85 void SplitDuplexLinkImpl::set_latency_profile(profile::Profile* profile)
86 {
87   link_up_->set_latency_profile(profile);
88   link_down_->set_latency_profile(profile);
89 }
90
91 void SplitDuplexLinkImpl::set_concurrency_limit(int limit) const
92 {
93   link_up_->set_concurrency_limit(limit);
94   link_down_->set_concurrency_limit(limit);
95 }
96
97 } // namespace resource
98 } // namespace kernel
99 } // namespace simgrid