The MAUVE Toolchain
Relay.hpp
1 /*
2  * Copyright 2017 ONERA
3  *
4  * This file is part of the MAUVE Base Components project.
5  *
6  * MAUVE Base Components is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License version 3 as
8  * published by the Free Software Foundation.
9  *
10  * MAUVE Base Components is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with MAUVE. If not, see <https://www.gnu.org/licenses/lgpl-3.0>.
17  */
18 #ifndef MAUVE_BASE_RELAY_HPP
19 #define MAUVE_BASE_RELAY_HPP
20 
21 #include <mauve/runtime.hpp>
22 #include "PeriodicStateMachine.hpp"
23 
24 namespace mauve {
25  namespace base {
26 
30  template <typename T>
31  struct RelayShell : public runtime::Shell {
32  public:
34  runtime::ReadPort<T> & read_port = mk_read_port<T>("read", T());
36  runtime::WritePort<T> & write_port = mk_write_port<T>("write");
37  };
38 
42  template <typename T>
43  struct RelayCore : public runtime::Core< RelayShell<T> > {
44  public:
46  void update() {
47  auto data = this->shell().read_port.read();
48  this->shell().write_port.write(data);
49  };
50  };
51 
53  template <typename T>
56 
57  }
58 }
59 
60 #endif // MAUVE_BASE_PERIODICSTATEMACHINE_HPP
void update()
Relay the input data to output.
Definition: Relay.hpp:46
runtime::WritePort< T > & write_port
Output port.
Definition: Relay.hpp:36
Definition: HasPort.hpp:33
Defines a Relay core.
Definition: Relay.hpp:43
Component class.
Definition: Architecture.hpp:34
Definition: HasPort.hpp:36
The MAUVE namespace.
Definition: tracing.hpp:24
Defines a Relay shell.
Definition: Relay.hpp:31
A Shell is the interface of a component.
Definition: Shell.hpp:48
Defines a Periodic State Machine.
Definition: PeriodicStateMachine.hpp:32
The Core defines the methods of the component.
Definition: Core.hpp:38
runtime::ReadPort< T > & read_port
Input port.
Definition: Relay.hpp:34