LRAUV  revA
DataReader.h
Go to the documentation of this file.
1 
10 #ifndef DATAREADER_H_
11 #define DATAREADER_H_
12 
13 #include "data/DataAccessor.h"
14 #include "data/Double.h"
15 #include "utils/Timestamp.h"
16 
17 class DataReader;
18 class Unit;
19 template<typename T> class FlexArray;
20 
30 class DataReader : public DataAccessor
31 {
32 public:
33  DataReader( Component* owner, DataElement& element,
34  const DataValue* defaultValue,
35  bool deleteDefaultValue = true );
36  DataReader( Component* owner, DataElement& element,
37  const Unit& defaultUnit );
38  virtual ~DataReader();
39 
40  const Unit* getDefaultUnit();
41 
42  //===============================================================
44  // (or these common, should be DataElement?)
45  bool isUnavailable( void );
46  bool isInvalid( void );
47  bool isOrphaned( void );
48  bool isActive( void );
49 
50  //===============================================================
52  bool read( const Unit& unit, unsigned char& readTo );
53  bool read( const Unit& unit, double& readTo );
54  bool read( const Unit& unit, float& readTo );
55  bool read( const Unit& unit, int& readTo );
56  bool read( bool& readTo );
57  bool read( Timespan& readTo );
58  bool read( DataValue& readTo );
59  int asInt( const Unit& unit );
60  double asDouble( const Unit& unit ) __attribute__( ( deprecated ) );
61  Str asString( const Unit& unit );
62 
67  const Timestamp& getTimestamp( void ) const;
68 
73  bool wasTouchedSinceLastRun( const Component* component );
74 
75  virtual void requestData( bool requestingData )
76  {
77  requestData( requestingData ? MIN_POWER : NO_STRATEGY );
78  }
79 
80  virtual void requestData( RequestStrategy requestStrategy )
81  {
82  requestStrategy_ = requestStrategy;
83  }
84 
85  bool isRequestingData( void )
86  {
87  return requestStrategy_ != NO_STRATEGY;
88  }
89 
91  {
92  return requestStrategy_;
93  }
94 
95  void setImplementor( bool implementor = true )
96  {
97  implementor_ = implementor;
98  }
99 
101  {
102  return implementor_;
103  }
104 
105 protected:
106 
112 
113 private:
114  // Note that the copy constructor below is private and not given a body.
115  // Any attempt to call it will return a compiler error.
116  DataReader( const DataReader& old ); // disallow copy constructor
117 };
118 
119 #endif /*DATAREADER_H_*/
struct SimHeadStruct __attribute__((packed))
bool isUnavailable(void)
Status and state functions.
Definition: DataReader.cpp:62
RequestStrategy getRequestStrategy(void)
Definition: DataReader.h:90
const Unit * getDefaultUnit()
Definition: DataReader.cpp:55
int asInt(const Unit &unit)
Definition: DataReader.cpp:221
virtual void requestData(RequestStrategy requestStrategy)
Definition: DataReader.h:80
A DataAccessor that reads values from the Slate Contains a default dataValue that must not be NULL...
Definition: DataReader.h:30
void setImplementor(bool implementor=true)
Definition: DataReader.h:95
Definition: DataAccessor.h:44
Definition: DataAccessor.h:43
Timespan class, represents a delta of time.
Definition: Timestamp.h:248
A DataValue is an abstract base class for a data value and associated engineering units of the value...
Definition: DataValue.h:35
bool implementor_
Definition: DataReader.h:111
bool isRequestingData(void)
Definition: DataReader.h:85
bool deleteDefaultValue_
Definition: DataReader.h:110
const Timestamp & getTimestamp(void) const
Returns the Timestamp of the last write to this reader's DataElement.
Definition: DataReader.cpp:294
RequestStrategy requestStrategy_
Definition: DataReader.h:107
Abstact base class of all elements which can write to, or read from the slate.
Definition: DataAccessor.h:29
DataReader(Component *owner, DataElement &element, const DataValue *defaultValue, bool deleteDefaultValue=true)
Definition: DataReader.cpp:15
Replacement for standard template class string.
Definition: Str.h:12
bool isImplementor()
Definition: DataReader.h:100
bool isInvalid(void)
Definition: DataReader.cpp:66
Abstract Base class for software components.
Definition: Component.h:53
bool read(const Unit &unit, unsigned char &readTo)
Get functions.
Definition: DataReader.cpp:82
virtual void requestData(bool requestingData)
Definition: DataReader.h:75
double asDouble(const Unit &unit) __attribute__((deprecated))
Definition: DataReader.cpp:248
bool isActive(void)
Definition: DataReader.cpp:74
virtual ~DataReader()
Definition: DataReader.cpp:44
Contains the DataAccessor class definition.
const Unit & defaultUnit_
Definition: DataReader.h:109
bool wasTouchedSinceLastRun(const Component *component)
Returns true if the value was touched since the last run of the indicated component.
Definition: DataReader.cpp:299
Simple class providing a flexible size array of pointers.
Definition: DataReader.h:19
bool isOrphaned(void)
Definition: DataReader.cpp:70
Contains the Timestamp and Timespan class declarations.
Str asString(const Unit &unit)
Definition: DataReader.cpp:275
const DataValue * defaultValue_
Definition: DataReader.h:108
Code that represents an engineering unit.
Definition: Unit.h:24
Contains the Double class definition.
Represents absolute times.
Definition: Timestamp.h:31
Abstact base class for one "element" of the Slate.
Definition: DataElement.h:37
RequestStrategy
Definition: DataAccessor.h:41