LRAUV  revA
MultiHandler.h
Go to the documentation of this file.
1 
9 #ifndef MULTIHANDLER_H_
10 #define MULTIHANDLER_H_
11 
13 #include "logger/Logger.h"
14 #include "process/Handler.h"
15 #include "utils/FastMap.h"
16 
35 class MultiHandler : public Handler
36 {
37 public:
38 
40 
42  virtual ~MultiHandler();
43 
46  virtual void run() = 0;
47 
49  virtual void runAll();
50 
52  virtual void runNext();
53 
55  virtual bool isRunning()
56  {
57  return running_;
58  }
59 
61  virtual void allowRuns()
62  {
63  runnable_ = true;
64  }
65 
67  virtual void stopRuns()
68  {
69  runnable_ = false;
70  }
71 
73  const bool isRunnable()
74  {
75  return runnable_;
76  }
77 
79  virtual void shutdown( void );
80 
81  //== Functions for dealing with the list of components ==
86  bool addComponent( SyncComponent* component );
87 
93  bool removeComponent( SyncComponent* component );
94 
96  void clearComponentList( void );
97 
102  void syslogComponentOrder( Logger &logger );
103 
107  {
108  return runningComponent_;
109  }
110 
111 protected:
112 
114  MultiHandler( Component& owner, const Str& name );
115 
116  OrderedComponents components_;
117  unsigned int runNextIndex_;
118  bool runnable_;
119  bool running_;
121 
122 private:
123  // Note that the copy constructor below is private and not given a body.
124  // Any attempt to call it will return a compiler error.
125  MultiHandler( const MultiHandler& old ); // disallow copy constructor
126 
129 };
130 
131 
132 #endif /*MULTIHANDLER_H_*/
Client-side interface for injecting log data into the log queue.
Definition: Logger.h:30
bool removeComponent(SyncComponent *component)
Remove a component from the control thread's control.
Definition: MultiHandler.cpp:94
bool running_
Definition: MultiHandler.h:119
MultiHandler(Component &owner, const Str &name)
Protected Constructor.
Definition: MultiHandler.cpp:15
Contains the SyncComponent class definition.
bool addComponent(SyncComponent *component)
Put a component in the control thread's control.
Definition: MultiHandler.cpp:54
A pure virtual Handler for a group (list) of Components.
Definition: MultiHandler.h:35
Component * getRunningComponent(void)
Returns the component that is currently running.
Definition: MultiHandler.h:106
A simple pthread Mutex abstraction.
Definition: Mutex.h:20
Mutex mutex_
Mutex for thread-safing an instance.
Definition: MultiHandler.h:128
bool runnable_
Definition: MultiHandler.h:118
virtual ~MultiHandler()
Destructor.
Definition: MultiHandler.cpp:26
virtual void run()=0
Run the component itself Should monitor the state of runnable_.
Abstract Base class for software components that run in the computation cycle.
Definition: SyncComponent.h:22
virtual void shutdown(void)
Stop the handler (and uninit the component)
Definition: MultiHandler.cpp:29
virtual void allowRuns()
Allow runs.
Definition: MultiHandler.h:61
Replacement for standard template class string.
Definition: Str.h:12
Base class for "handlers" of Components.
Definition: Handler.h:49
Abstract Base class for software components.
Definition: Component.h:53
OrderedComponents components_
Definition: MultiHandler.h:116
Contains the FastMap class declaration.
Contains the Logger class definition.
Contains the Handler class declaration.
virtual bool isRunning()
Indicates whether the component is running.
Definition: MultiHandler.h:55
unsigned int runNextIndex_
Definition: MultiHandler.h:117
virtual void stopRuns()
Stop the runs, if they are in progress, and disallow future runs.
Definition: MultiHandler.h:67
void syslogComponentOrder(Logger &logger)
Dumps information about the components in the list to the given Logger.
Definition: MultiHandler.cpp:159
SyncComponent * runningComponent_
Definition: MultiHandler.h:120
virtual void runAll()
Run all items in the list of components.
Definition: MultiHandler.cpp:113
const bool isRunnable()
is the handler (and contained thread) runnable_?
Definition: MultiHandler.h:73
void clearComponentList(void)
Empty the lists (doesn't actually delete the components)
Definition: MultiHandler.cpp:151
virtual void runNext()
Run next item in the list of components.
Definition: MultiHandler.cpp:123
FastMap< SyncComponent::CycleOrder, SyncComponent * > OrderedComponents
Definition: MultiHandler.h:39