LRAUV  revA
MultiHandler Class Referenceabstract

A pure virtual Handler for a group (list) of Components. More...

#include <MultiHandler.h>

Inheritance diagram for MultiHandler:
Collaboration diagram for MultiHandler:

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...
 
ComponentgetRunningComponent (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 StrgetName ()
 
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_
 
SyncComponentrunningComponent_
 
- Protected Attributes inherited from Handler
Componentcomponent_
 The "handled" Component. More...
 
Timestamp componentStartTime_
 Keep track of when the component is supposed to start next. More...
 
Logger logger_
 
PCallerpCaller_
 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 )
 

Detailed Description

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()

Member Typedef Documentation

Constructor & Destructor Documentation

MultiHandler::~MultiHandler ( )
virtual

Destructor.

MultiHandler::MultiHandler ( Component owner,
const Str name 
)
protected

Protected Constructor.

MultiHandler::MultiHandler ( const MultiHandler old)
private

Member Function Documentation

bool MultiHandler::addComponent ( SyncComponent component)
virtual void MultiHandler::allowRuns ( )
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().

Component* MultiHandler::getRunningComponent ( void  )
inline

Returns the component that is currently running.

Useful for fault handling.

References runningComponent_.

const bool MultiHandler::isRunnable ( )
inline

is the handler (and contained thread) runnable_?

References runnable_.

Referenced by runNext().

virtual bool MultiHandler::isRunning ( void  )
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.

Parameters
componentSyncComponent 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().

virtual void MultiHandler::run ( )
pure virtual

Run the component itself Should monitor the state of runnable_.

Reimplemented from Handler.

Implemented in SyncHandler.

void MultiHandler::runAll ( )
virtual

Run all items in the list of components.

References components_, runNext(), runNextIndex_, and FastMap< S, T >::size().

Referenced by SyncHandler::run().

virtual void MultiHandler::stopRuns ( )
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.

Parameters
loggerThe 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().

Member Data Documentation

Mutex MultiHandler::mutex_
private

Mutex for thread-safing an instance.

Referenced by shutdown().

bool MultiHandler::runnable_
protected

Referenced by allowRuns(), isRunnable(), and stopRuns().

unsigned int MultiHandler::runNextIndex_
protected

Referenced by runAll(), and runNext().

bool MultiHandler::running_
protected

Referenced by isRunning(), and runNext().

SyncComponent* MultiHandler::runningComponent_
protected

Referenced by getRunningComponent(), and runNext().


The documentation for this class was generated from the following files: