EEROS  0.4.1.0
API for the EEROS Real-Time Robotics Framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Input.hpp
Go to the documentation of this file.
1 #ifndef ORG_EEROS_CONTROL_INPUT_HPP_
2 #define ORG_EEROS_CONTROL_INPUT_HPP_
3 
6 
7 namespace eeros {
8  namespace control {
9 
10  template < typename T = double >
11  class Input {
12  public:
13  Input() : connectedOutput(nullptr) { }
14 
15  virtual bool connect(Output<T>& output) {
16  if(connectedOutput != nullptr) return false;
17  connectedOutput = &output;
18  return true;
19  }
20 
21  virtual bool connect(Output<T>* output) {
22  if(connectedOutput != nullptr) return false;
23  connectedOutput = output;
24  return true;
25  }
26 
27  virtual void disconnect() {
28  connectedOutput = nullptr;
29  }
30 
31  virtual bool isConnected() const {
32  return connectedOutput != nullptr;
33  }
34 
35  virtual Signal<T>& getSignal() {
36  if(isConnected()) return connectedOutput->getSignal();
37  // TODO error message or throw exception
39  }
40 
41  protected:
43  };
44 
45  };
46 };
47 
48 #endif /* ORG_EEROS_CONTROL_INPUT_HPP_ */
virtual bool connect(Output< T > *output)
Definition: Input.hpp:21
virtual bool isConnected() const
Definition: Input.hpp:31
Input()
Definition: Input.hpp:13
Definition: Output.hpp:10
Output< T > * connectedOutput
Definition: Input.hpp:42
static Signal< T > & getIllegalSignal()
Definition: Signal.hpp:82
virtual Signal< T > & getSignal()
Definition: Input.hpp:35
Definition: Signal.hpp:14
Definition: Input.hpp:11
virtual bool connect(Output< T > &output)
Definition: Input.hpp:15
virtual void disconnect()
Definition: Input.hpp:27