LRAUV  revA
Behavior.h
Go to the documentation of this file.
1 
9 #ifndef BEHAVIOR_H_
10 #define BEHAVIOR_H_
11 
12 #include "Component.h"
13 #include "utils/FastMap.h"
15 
16 class ValueClause;
17 
32 class Behavior : public Component
33 {
34 public:
35 
37  {
43  };
44 
45  virtual ~Behavior();
46  bool executeIfUnsatisfied();
47  virtual bool runIfUnsatisfied();
48 
49  virtual void preempted()
50  {}
51 
52  ;
53  virtual bool isSatisfied()
54  {
55  return false;
56  }
57 
58  virtual bool isRunnable()
59  {
60  return runnable_;
61  }
62 
63  virtual bool isSatisfiable()
64  {
65  return satisfiable_;
66  }
67 
68  virtual bool isCommand()
69  {
70  return runnable_ && satisfiable_;
71  }
72 
74  {
75  return behaviorState_;
76  }
77 
78  void setBehaviorState( BehaviorState behaviorState )
79  {
80  this->behaviorState_ = behaviorState;
81  }
82 
84  virtual bool isCompleted( void )
85  {
87  }
88 
89  SettingReader* findSettingReader( const Str& settingURI );
90 
91  SettingReader* addValueClause( const Str& uriPart, ValueClause* valueClause );
92 
93  void addArgWriter( const Str& uriPart, DataWriter* argWriter );
94 
96  {
97  return timeout_;
98  }
99 
100  void setTimeout( const Timespan& timeout )
101  {
102  timeout_ = timeout;
103  }
104 
105 protected:
106  Behavior( const Str & name, const Module *module, const bool runnable, const bool satisfiable );
107 
108  // Note that the copy constructor below is private and not given a body.
109  // Any attempt to call it will return a compiler error.
110  Behavior( const Behavior& old ); // disallow copy constructor
111 
112  SettingReader* newSettingReader( const Str& uriPart, const DataValue* defaultValue, bool deleteDefaultValue = true ); // __attribute__( ( deprecated ) ); // ("Use Behavior::newSettingReader with SettingURI arg instead.") ));
113 
114  SettingReader* newSettingReader( const SettingURI& uriPart );
115 
116  bool runnable_;
119 
122 
123  DataWriter* findArgWriter( const OutputURI& uriPart );
124 
127 
128 };
129 
131 
137 typedef Behavior*( *BehaviorCreator )( const Str&, const Module* module );
138 
139 
140 #endif /*BEHAVIOR_H_*/
void addArgWriter(const Str &uriPart, DataWriter *argWriter)
Definition: Behavior.cpp:143
BehaviorState behaviorState_
Definition: Behavior.h:118
Definition: Behavior.h:42
virtual RunState runnable()
Should eventually follow a START request or RESETTING.
Definition: Component.h:223
bool runnable_
Definition: Behavior.h:116
Contains the Component class definition.
virtual bool isRunnable()
Definition: Behavior.h:58
virtual void preempted()
Definition: Behavior.h:49
Timespan class, represents a delta of time.
Definition: Timestamp.h:248
virtual bool isCommand()
Definition: Behavior.h:68
Behavior(const Str &name, const Module *module, const bool runnable, const bool satisfiable)
Protected constructor for abstract base class.
Definition: Behavior.cpp:162
Behavior is the abstract base class for components that implement mission behaviors and commands...
Definition: Behavior.h:32
A DataValue is an abstract base class for a data value and associated engineering units of the value...
Definition: DataValue.h:35
A DataAccessor that writes values to the Slate via its associated DataElement.
Definition: DataWriter.h:27
bool satisfiable_
Definition: Behavior.h:117
virtual bool isSatisfied()
Definition: Behavior.h:53
BehaviorState
Definition: Behavior.h:36
A ValueClause is a set of boolean conditions that may be specified as conditions for executing (or st...
Definition: ValueClause.h:26
Module is the abstract base class for a collection of Component objects that can be contained in a lo...
Definition: Module.h:45
DataWriter * findArgWriter(const OutputURI &uriPart)
Definition: Behavior.cpp:152
Definition: Behavior.h:40
void setBehaviorState(BehaviorState behaviorState)
Definition: Behavior.h:78
Replacement for standard template class string.
Definition: Str.h:12
BehaviorState getBehaviorState() const
Definition: Behavior.h:73
Definition: Behavior.h:41
Timespan timeout_
Time before this behavior must end – defaults no timeout.
Definition: Behavior.h:121
Contains the SettingReader class definition.
Definition: ElementURI.h:268
Abstract Base class for software components.
Definition: Component.h:53
SettingReader * newSettingReader(const Str &uriPart, const DataValue *defaultValue, bool deleteDefaultValue=true)
Definition: Behavior.cpp:97
const Timespan & getTimeout()
Definition: Behavior.h:95
virtual bool isCompleted(void)
Query if this component is completed.
Definition: Behavior.h:84
Definition: Behavior.h:39
SettingReader * addValueClause(const Str &uriPart, ValueClause *valueClause)
Definition: Behavior.cpp:76
Contains the FastMap class declaration.
bool executeIfUnsatisfied()
Combined run and test with metrics generation.
Definition: Behavior.cpp:27
SettingReader * findSettingReader(const Str &settingURI)
Definition: Behavior.cpp:134
Reads values from mission settings.
Definition: SettingReader.h:26
FastMap< const Str, DataWriter * > * argWriterMap_
Definition: Behavior.h:126
void setTimeout(const Timespan &timeout)
Definition: Behavior.h:100
Definition: ElementURI.h:255
virtual bool isSatisfiable()
Definition: Behavior.h:63
virtual bool runIfUnsatisfied()
Combined run and test Called by mission element: behaviorDone_.
Definition: Behavior.cpp:63
Definition: Behavior.h:38
FastMap< const Str, SettingReader * > * settingReaderMap_
Definition: Behavior.h:125
virtual ~Behavior()
Definition: Behavior.cpp:14