RCKit
Setter.h
1 // Setter.h
2 //
3 // Virtual base class for classes that receive a value, maybe transform it and do something with it
4 //
5 /// \author Mike McCauley (mikem@airspayce.com)
6 ///
7 // Copyright (C) 2010 Mike McCauley
8 // $Id: Setter.h,v 1.4 2018/09/17 23:09:57 mikem Exp mikem $
9 
10 #ifndef Setter_h
11 #define Setter_h
12 
13 /////////////////////////////////////////////////////////////////////
14 /// \class Setter Setter.h <Setter.h>
15 /// \brief Virtual base class for classes that receive a value, maybe transform it and then
16 /// do something with it
17 ///
18 /// Setters (ie different subclasses of Setter) are designed to be chained together.
19 /// Each Setter in a chain transforms its input value in some way and then maybe passes it on to
20 /// its output Setter.
21 /// Setters can be designed to do almost any transformation with a number, including
22 /// changing it, sending it to some device, using the value to set a physical output etc.
23 /// Each setter can accept as input an int (ie a 16 bit signed number) although some Setters
24 /// may be more constrained as to which value ranges make physical sense.
25 class Setter
26 {
27 public:
28  /// Constructor.
29  Setter();
30 
31  /// Constructor with setting the target
32  Setter(Setter* target);
33 
34  /// This is where incoming values are set.
35  // This default implementation merely passes its value to the output
36  /// \param[in] value The input value
37  virtual void input(int value);
38 
39  /// Connects this Setter to a downstream Setter
40  /// \param[in] target Pointer to a sublass of Setter, whose input() function will be called
41  /// when a new value is available from this Setter.
42  virtual void setTarget(Setter* target);
43 
44  /// Called when the source of input data is lost, and the Setter is required to fail in a safe way.
45  /// Subclasses can override.
46  /// Default is to send to next Setter in the chain.
47  virtual void failsafe();
48 
49  /// Sets the failsafeValue
51 
52  /// Returns the most recently set failsafe value.
53  /// Base class does not use this
54  int failsafeValue();
55 
56 
57 protected:
58  /// This is the instance of Setter that will be given the transfotmed output value
60 
61  /// This is the failsafe value, which some setters use to set the output when
62  /// a failsafe call is made
64 
65 private:
66 };
67 
68 #endif
Setter::input
virtual void input(int value)
This is where incoming values are set.
Definition: Setter.cpp:26
Setter::failsafeValue
int failsafeValue()
Definition: Setter.cpp:52
Setter::Setter
Setter()
Constructor.
Definition: Setter.cpp:12
Setter::_failsafeValue
int _failsafeValue
Definition: Setter.h:63
Setter::failsafe
virtual void failsafe()
Definition: Setter.cpp:33
Setter::setFailsafeValue
void setFailsafeValue(int failsafeValue)
Sets the failsafeValue.
Definition: Setter.cpp:46
Setter::_target
Setter * _target
This is the instance of Setter that will be given the transfotmed output value.
Definition: Setter.h:59
Setter::setTarget
virtual void setTarget(Setter *target)
Definition: Setter.cpp:40
Setter
Virtual base class for classes that receive a value, maybe transform it and then do something with it...
Definition: Setter.h:25