RCKit
Main Page
Classes
Files
Examples
File List
File Members
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.3 2010/06/28 00:56:10 mikem Exp $
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
50
void
setFailsafeValue
(
int
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
59
Setter
*
_target
;
60
61
/// This is the failsafe value, which some setters use to set the output when
62
/// a failsafe call is made
63
int
_failsafeValue
;
64
65
private
:
66
};
67
68
#endif
Generated by
1.8.1