LRAUV  revA
Handler.h
Go to the documentation of this file.
1 
9 #ifndef BLOCKHANDLER_H_
10 #define BLOCKHANDLER_H_
11 
12 #include "component/Component.h"
13 #include "logger/Logger.h"
14 
15 class PCaller;
16 
49 class Handler
50 {
51 public:
52 
58  Handler( Component &inComponent, const Str& name, bool idleThread = false );
59 
61  virtual ~Handler();
62 
64  virtual void run();
65 
67  virtual bool continueLoop( void );
68 
70  virtual void runOnce( void );
71 
73  virtual void runBetween( void );
74 
76  virtual void shutdown( void );
77 
79  virtual bool isRunning( void )
80  {
81  return running_;
82  }
83 
84  const Str& getName()
85  {
86  return logger_.getFacility();
87  }
88 
89  void setAsLogHandler( bool logHandler )
90  {
91  logHandler_ = logHandler;
92  }
93 
94  void setAsControlLoopHandler( bool controlLoopHandler )
95  {
96  controlLoopHandler_ = controlLoopHandler;
97  }
98 
99 #ifdef __FASTSIM
100  static void SetAllowFastSim( bool allowFastSim )
101  {
102  AllowFastSim_ = allowFastSim;
103  }
104 
105  static bool IsFastSimAllowed()
106  {
107  return AllowFastSim_;
108  }
109 #else
110  static bool IsFastSimAllowed()
111  {
112  return false;
113  }
114 #endif
115 
116 protected:
117 
120 
123 
125 
128 
129  bool running_;
130 
131  static const Timespan SMALL_INTERVAL;
132 
133 private:
134 
135  // Note that the copy constructor below is private and not given a body.
136  // Any attempt to call it will return a compiler error.
137  Handler( const Handler& old ); // disallow copy constructor
138 
141 
144 #ifdef __FASTSIM
145  static bool AllowFastSim_;
146 #endif
147 
148 
149 };
150 
153 
154 #endif /*BLOCKHANDLER_H_*/
Client-side interface for injecting log data into the log queue.
Definition: Logger.h:30
const Str & getName()
Definition: Handler.h:84
void setAsControlLoopHandler(bool controlLoopHandler)
Definition: Handler.h:94
virtual bool isRunning(void)
True if handler is running.
Definition: Handler.h:79
Logger logger_
Definition: Handler.h:124
Contains the Component class definition.
Timespan class, represents a delta of time.
Definition: Timestamp.h:248
virtual void run()
Run the component itself.
Definition: Handler.cpp:43
const CodedStr & getFacility() const
Definition: Logger.h:89
Timestamp componentStartTime_
Keep track of when the component is supposed to start next.
Definition: Handler.h:122
bool controlLoopHandler_
Definition: Handler.h:142
Replacement for standard template class string.
Definition: Str.h:12
virtual bool continueLoop(void)
Supplemental end conditions.
Definition: Handler.cpp:128
Base class for "handlers" of Components.
Definition: Handler.h:49
PCaller * pCaller_
Used for making protected calls.
Definition: Handler.h:127
Abstract Base class for software components.
Definition: Component.h:53
bool firstLoop_
true at object initialization, false after the first iteration through the run() loop.
Definition: Handler.h:140
bool running_
Definition: Handler.h:129
Contains the Logger class definition.
Handler(Component &inComponent, const Str &name, bool idleThread=false)
Constructor.
Definition: Handler.cpp:25
Simple class providing a flexible size array of pointers.
Definition: DataReader.h:19
void setAsLogHandler(bool logHandler)
Definition: Handler.h:89
bool logHandler_
Definition: Handler.h:143
FlexArray< Handler * > ListOfHandlerPtrs
A type for a list of Handlers.
Definition: Handler.h:152
static const Timespan SMALL_INTERVAL
Definition: Handler.h:131
virtual void runOnce(void)
Virtual function run only on first iteration of handler.
Definition: Handler.cpp:80
virtual void shutdown(void)
Stop the handler (and uninit the component)
Definition: Handler.cpp:133
virtual ~Handler()
Destructor.
Definition: Handler.cpp:37
Protected Caller.
Definition: PCaller.h:28
Represents absolute times.
Definition: Timestamp.h:31
virtual void runBetween(void)
Virtual function run after the first iteration of the handler.
Definition: Handler.cpp:86
static bool IsFastSimAllowed()
Definition: Handler.h:110
Component & component_
The "handled" Component.
Definition: Handler.h:119