LRAUV  revA
SettingReader.h
Go to the documentation of this file.
1 
10 #ifndef SETTINGREADER_H_
11 #define SETTINGREADER_H_
12 
13 #include "data/ElementURI.h"
14 #include "utils/Str.h"
15 
16 class DataValue;
17 class Timespan;
18 class Unit;
19 class ValueClause;
20 
27 {
28 public:
29 
30  SettingReader( const SettingURI& settingURI, ValueClause* valueClause );
31 
32  virtual ~SettingReader();
33 
34  //===============================================================
36 
37  bool isActive();
38 
39  //===============================================================
41  bool read( const Unit& unit, unsigned char& readTo );
42 
43  bool read( const Unit& unit, double& readTo );
44 
45  bool read( const Unit& unit, float& readTo );
46 
47  bool read( const Unit& unit, int& readTo );
48 
49  bool read( bool& readTo );
50 
51  bool read( Timespan& readTo );
52 
53  bool read( DataValue& readTo );
54 
55  int asInt( const Unit& unit );
56 
57  double asDouble( const Unit& unit ) __attribute__( ( deprecated ) );
58 
59  Str asString( const Unit& unit );
60 
62  {
63  return settingURI_;
64  }
65 
67  {
68  return defaultValue_;
69  }
70 
71  const Unit* getDefaultUnit();
72 
73 protected:
74 
79 
80  bool evalValueClause();
81 
82 private:
83  // Note that the copy constructor below is private and not given a body.
84  // Any attempt to call it will return a compiler error.
85  SettingReader( const SettingReader& old ); // disallow copy constructor
86 
87  friend class Behavior;
88 
89  SettingReader( const SettingURI& settingURI, const DataValue* defaultValue,
90  bool deleteDefaultValue = true );
91 
92  void setDefaultValue( const DataValue* defaultValue,
93  bool deleteDefaultValue = true )
94  {
95  defaultValue_ = defaultValue;
96  deleteDefaultValue_ = deleteDefaultValue;
97  }
98 
99  void setValueClause( ValueClause* valueClause )
100  {
101  valueClause_ = valueClause;
102  }
103 
104 };
105 
106 #endif /*SETTINGREADER_H_*/
struct SimHeadStruct __attribute__((packed))
const DataValue * getDefaultValue()
Definition: SettingReader.h:66
Timespan class, represents a delta of time.
Definition: Timestamp.h:248
Behavior is the abstract base class for components that implement mission behaviors and commands...
Definition: Behavior.h:32
void setValueClause(ValueClause *valueClause)
Definition: SettingReader.h:99
A DataValue is an abstract base class for a data value and associated engineering units of the value...
Definition: DataValue.h:35
A ValueClause is a set of boolean conditions that may be specified as conditions for executing (or st...
Definition: ValueClause.h:26
SettingReader(const SettingURI &settingURI, ValueClause *valueClause)
Definition: SettingReader.cpp:154
Replacement for standard template class string.
Definition: Str.h:12
bool evalValueClause()
Definition: SettingReader.cpp:133
const SettingURI settingURI_
Definition: SettingReader.h:75
Definition: ElementURI.h:268
Contains the ElementURI class definition.
bool read(const Unit &unit, unsigned char &readTo)
Get functions.
Definition: SettingReader.cpp:36
int asInt(const Unit &unit)
Definition: SettingReader.cpp:105
ValueClause * valueClause_
Definition: SettingReader.h:78
Reads values from mission settings.
Definition: SettingReader.h:26
bool isActive()
Status and state functions.
Definition: SettingReader.cpp:29
const SettingURI & getSettingURI()
Definition: SettingReader.h:61
bool deleteDefaultValue_
Definition: SettingReader.h:77
void setDefaultValue(const DataValue *defaultValue, bool deleteDefaultValue=true)
Definition: SettingReader.h:92
Str asString(const Unit &unit)
Definition: SettingReader.cpp:119
double asDouble(const Unit &unit) __attribute__((deprecated))
Definition: SettingReader.cpp:112
virtual ~SettingReader()
Definition: SettingReader.cpp:17
const Unit * getDefaultUnit()
Definition: SettingReader.cpp:128
const DataValue * defaultValue_
Definition: SettingReader.h:76
Code that represents an engineering unit.
Definition: Unit.h:24