ForwardSwitch.cci
Go to the documentation of this file.
1 //
2 // Copyright (c) 2020 Fraunhofer Institute for Applied Information Technology (FIT)
3 // Network Research Group (NET)
4 // Schloss Birlinghoven, 53754 Sankt Augustin, GERMANY
5 // Contact: support@wiback.org
6 //
7 // This file is part of the SENF code tree.
8 // It is licensed under the 3-clause BSD License (aka New BSD License).
9 // See LICENSE.txt in the top level directory for details or visit
10 // https://opensource.org/licenses/BSD-3-Clause
11 //
12 
13 
14 /** \file
15  \brief ForwardSwitch inline non-template implementation */
16 
17 #include "ForwardSwitch.hh"
18 
19 // Custom includes
20 
21 #define prefix_ inline
22 ///////////////////////////////cc.p////////////////////////////////////////
23 
24 prefix_ senf::emu::ForwardSwitch::ForwardSwitch(bool state)
25 {
26  route( input, output );
27  forward( state);
28 }
29 
30 prefix_ void senf::emu::ForwardSwitch::onRequest_discard()
31 {
32  input.read(); // discard automatically
33 }
34 
35 prefix_ void senf::emu::ForwardSwitch::onRequest_forward()
36 {
37  output.write( input.read());
38 }
39 
40 prefix_ bool senf::emu::ForwardSwitch::forward()
41  const
42 {
43  return forward_;
44 }
45 
46 prefix_ void senf::emu::ForwardSwitch::forward(bool state)
47 {
48  forward_ = state;
49  if (state)
50  input.onRequest( &ForwardSwitch::onRequest_forward );
51  else
52  input.onRequest( &ForwardSwitch::onRequest_discard );
53 }
54 
55 
56 ///////////////////////////////cci.e////////////////////////////////////////
57 #undef prefix_
58