|
LRAUV
revA
|
A pure virtual Handler for a group (list) of Components. More...
#include <MultiHandler.h>


Public Types | |
| typedef FastMap< SyncComponent::CycleOrder, SyncComponent * > | OrderedComponents |
Public Member Functions | |
| virtual | ~MultiHandler () |
| Destructor. More... | |
| virtual void | run ()=0 |
| Run the component itself Should monitor the state of runnable_. More... | |
| virtual void | runAll () |
| Run all items in the list of components. More... | |
| virtual void | runNext () |
| Run next item in the list of components. More... | |
| virtual bool | isRunning () |
| Indicates whether the component is running. More... | |
| virtual void | allowRuns () |
| Allow runs. More... | |
| virtual void | stopRuns () |
| Stop the runs, if they are in progress, and disallow future runs. More... | |
| const bool | isRunnable () |
| is the handler (and contained thread) runnable_? More... | |
| virtual void | shutdown (void) |
| Stop the handler (and uninit the component) More... | |
| bool | addComponent (SyncComponent *component) |
| Put a component in the control thread's control. More... | |
| bool | removeComponent (SyncComponent *component) |
| Remove a component from the control thread's control. More... | |
| void | clearComponentList (void) |
| Empty the lists (doesn't actually delete the components) More... | |
| void | syslogComponentOrder (Logger &logger) |
| Dumps information about the components in the list to the given Logger. More... | |
| Component * | getRunningComponent (void) |
| Returns the component that is currently running. More... | |
Public Member Functions inherited from Handler | |
| Handler (Component &inComponent, const Str &name, bool idleThread=false) | |
| Constructor. More... | |
| virtual | ~Handler () |
| Destructor. More... | |
| virtual bool | continueLoop (void) |
| Supplemental end conditions. More... | |
| virtual void | runOnce (void) |
| Virtual function run only on first iteration of handler. More... | |
| virtual void | runBetween (void) |
| Virtual function run after the first iteration of the handler. More... | |
| const Str & | getName () |
| void | setAsLogHandler (bool logHandler) |
| void | setAsControlLoopHandler (bool controlLoopHandler) |
Protected Member Functions | |
| MultiHandler (Component &owner, const Str &name) | |
| Protected Constructor. More... | |
Protected Attributes | |
| OrderedComponents | components_ |
| unsigned int | runNextIndex_ |
| bool | runnable_ |
| bool | running_ |
| SyncComponent * | runningComponent_ |
Protected Attributes inherited from Handler | |
| Component & | component_ |
| The "handled" Component. More... | |
| Timestamp | componentStartTime_ |
| Keep track of when the component is supposed to start next. More... | |
| Logger | logger_ |
| PCaller * | pCaller_ |
| Used for making protected calls. More... | |
| bool | running_ |
Private Member Functions | |
| MultiHandler (const MultiHandler &old) | |
Private Attributes | |
| Mutex | mutex_ |
| Mutex for thread-safing an instance. More... | |
Additional Inherited Members | |
Static Public Member Functions inherited from Handler | |
| static bool | IsFastSimAllowed () |
Static Protected Attributes inherited from Handler | |
| static const Timespan | SMALL_INTERVAL = Timespan::FromMicros( 800 ) |
A pure virtual Handler for a group (list) of Components.
MultiHandler is a base class for Handlers which might need to store and keep track of more than one Component. For example, the SyncHandler must keep track of all of the Components running in the ControlThread.
Handles the bookkeeping for keeping a ListOfComponents where each Entry is a Component. Also includes basic functions for adding and removing Components.
MultiHandler is a pure virtual. Derived classes need to define run()
|
virtual |
Destructor.
|
private |
| bool MultiHandler::addComponent | ( | SyncComponent * | component | ) |
Put a component in the control thread's control.
Does not insert duplicates.
| component | The SyncComponent to be added |
References components_, SyncComponent::CYCLE_REPEAT_OFFSET, SyncComponent::getCycleOrder(), FastMap< S, T >::getIndexed(), SyncComponent::isRepeater(), Handler::pCaller_, PCaller::pInitialize(), FastMap< S, T >::put(), and FastMap< S, T >::size().
Referenced by ControlThread::addComponentsFromQueue().
|
inlinevirtual |
Allow runs.
References runnable_.
| void MultiHandler::clearComponentList | ( | void | ) |
Empty the lists (doesn't actually delete the components)
References components_, FastMap< S, T >::popIndexed(), and FastMap< S, T >::size().
Referenced by shutdown().
|
inline |
Returns the component that is currently running.
Useful for fault handling.
References runningComponent_.
|
inline |
|
inlinevirtual |
Indicates whether the component is running.
Reimplemented from Handler.
References running_.
Referenced by shutdown().
| bool MultiHandler::removeComponent | ( | SyncComponent * | component | ) |
Remove a component from the control thread's control.
(technically only removes the first instance but list should not allow duplicates.
| component | SyncComponent to remove (uses == to compare pointers) |
References components_, FastMap< S, T >::getIndexed(), FastMap< S, T >::popIndexed(), FastMap< S, T >::size(), and Component::uninitialize().
Referenced by ControlThread::removeComponentsFromQueue().
|
pure virtual |
Run the component itself Should monitor the state of runnable_.
Reimplemented from Handler.
Implemented in SyncHandler.
|
virtual |
Run all items in the list of components.
References components_, runNext(), runNextIndex_, and FastMap< S, T >::size().
Referenced by SyncHandler::run().
|
virtual |
Run next item in the list of components.
References components_, SyncComponent::CYCLE_INCREMENT, SyncComponent::CYCLE_REPEAT_OFFSET, CycleStarter::GetCycle(), SyncComponent::getDivisor(), FastMap< S, T >::getIndexedEntry(), MapEntry< S, T >::getItem(), MapEntry< S, T >::getKey(), SyncComponent::getModulo(), isRunnable(), Handler::pCaller_, PCaller::pExecute(), runNextIndex_, running_, runningComponent_, SyncComponent::setRepeating(), and FastMap< S, T >::size().
Referenced by runAll().
|
virtual |
Stop the handler (and uninit the component)
Reimplemented from Handler.
References clearComponentList(), Handler::component_, components_, Str::cStr(), FastMap< S, T >::getIndexed(), Component::getName(), isRunning(), mutex_, Handler::pCaller_, PCaller::pUninitialize(), Timespan::Seconds(), FastMap< S, T >::size(), Timespan::sleepFor(), and stopRuns().
Referenced by ControlThread::uninitialize().
|
inlinevirtual |
Stop the runs, if they are in progress, and disallow future runs.
References runnable_.
Referenced by shutdown().
| void MultiHandler::syslogComponentOrder | ( | Logger & | logger | ) |
Dumps information about the components in the list to the given Logger.
| logger | The Logger to dump the syslog to. |
References components_, FastMap< S, T >::getIndexed(), Component::getName(), FastMap< S, T >::size(), and Logger::syslog().
Referenced by ControlThread::initialize(), and ControlThread::run().
|
protected |
Referenced by addComponent(), clearComponentList(), removeComponent(), runAll(), runNext(), shutdown(), and syslogComponentOrder().
|
private |
Mutex for thread-safing an instance.
Referenced by shutdown().
|
protected |
Referenced by allowRuns(), isRunnable(), and stopRuns().
|
protected |
Referenced by isRunning(), and runNext().
|
protected |
Referenced by getRunningComponent(), and runNext().