|
LRAUV
revA
|
Base class for "handlers" of Components. More...
#include <Handler.h>


Public Member Functions | |
| Handler (Component &inComponent, const Str &name, bool idleThread=false) | |
| Constructor. More... | |
| virtual | ~Handler () |
| Destructor. More... | |
| virtual void | run () |
| Run the component itself. 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... | |
| virtual void | shutdown (void) |
| Stop the handler (and uninit the component) More... | |
| virtual bool | isRunning (void) |
| True if handler is running. More... | |
| const Str & | getName () |
| void | setAsLogHandler (bool logHandler) |
| void | setAsControlLoopHandler (bool controlLoopHandler) |
Static Public Member Functions | |
| static bool | IsFastSimAllowed () |
Protected Attributes | |
| 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_ |
Static Protected Attributes | |
| static const Timespan | SMALL_INTERVAL = Timespan::FromMicros( 800 ) |
Private Member Functions | |
| Handler (const Handler &old) | |
Private Attributes | |
| bool | firstLoop_ |
| true at object initialization, false after the first iteration through the run() loop. More... | |
| bool | controlLoopHandler_ |
| bool | logHandler_ |
Base class for "handlers" of Components.
Trying to make equivalence between Components which run within another thread (control, supervisor) and those that run in their own thread. ThreadHandler derives from this class. Decided that ThreadHandler would "have a" Component rather than "be a" Component.
Basic non-threaded component handler.
Essentially a glorified while(1) loop. Relies on the component to indicate when it's going to yield through Component::completed flag.
Should be moderately extensible through its virtual functions. Run() does the following:
So runonce() can be used to initialize the Handler itself And runBetween() can be used to update the Handler, sleep, wait for a signal or condition variable, etc
Constructor.
| inComponent | The component being handled. |
| name | Name of the component (fed to its logger_) |
| idleThread | If true, run thread at idle priority |
|
virtual |
Destructor.
References pCaller_.
|
private |
|
virtual |
Supplemental end conditions.
Reimplemented in ThreadHandler.
References component_, and Component::isCompleted().
Referenced by ThreadHandler::continueLoop(), and run().
|
inline |
References Logger::getFacility(), and logger_.
Referenced by ComponentRegistry::ShutdownThreads().
|
inlinestatic |
Referenced by CommandLine::commandQuick().
|
inlinevirtual |
True if handler is running.
Reimplemented in MultiHandler.
References running_.
Referenced by ComponentRegistry::StartThreads().
|
virtual |
Run the component itself.
Initialize the component, run it, then un-initialize it.
Reimplemented in MultiHandler, ThreadHandler, and SyncHandler.
References component_, continueLoop(), firstLoop_, Syslog::INFO, logger_, pCaller_, PCaller::pExecute(), PCaller::pInitialize(), PCaller::pUninitialize(), runBetween(), running_, runOnce(), and Logger::syslog().
Referenced by ThreadHandler::runInThread(), Supervisor::startCommandLine(), and ComponentRegistry::StartThreads().
|
virtual |
Virtual function run after the first iteration of the handler.
References Timestamp::asDouble(), Component::BLOCK_CONTINUOUS, Component::BLOCK_PERIODIC, component_, componentStartTime_, controlLoopHandler_, ComponentRegistry::GetControlThreadPeriod(), Component::getPeriod(), Component::getState(), Component::isFailed(), Supervisor::IsRunningSimsInRealTime(), logHandler_, Timestamp::Now(), Timespan::sleepFor(), Timestamp::sleepTill(), and SMALL_INTERVAL.
Referenced by run().
|
virtual |
Virtual function run only on first iteration of handler.
Protected methods.
References componentStartTime_, and Timestamp::Now().
Referenced by run().
|
inline |
References controlLoopHandler_.
Referenced by ComponentRegistry::Insert().
|
inline |
References logHandler_.
Referenced by ComponentRegistry::Insert().
|
virtual |
Stop the handler (and uninit the component)
Reimplemented in MultiHandler, and ThreadHandler.
References component_, and Component::setEnabled().
Referenced by ComponentRegistry::PurgeEntry(), ThreadHandler::shutdown(), ComponentRegistry::ShutdownThreads(), and Supervisor::uninitialize().
|
protected |
The "handled" Component.
Referenced by ThreadHandler::cleanup(), continueLoop(), ThreadHandler::joinThread(), run(), runBetween(), shutdown(), and MultiHandler::shutdown().
|
protected |
Keep track of when the component is supposed to start next.
Referenced by runBetween(), and runOnce().
|
private |
Referenced by runBetween(), and setAsControlLoopHandler().
|
private |
|
protected |
Referenced by ThreadHandler::cancelThread(), getName(), run(), and ThreadHandler::runInThread().
|
private |
Referenced by runBetween(), and setAsLogHandler().
|
protected |
Used for making protected calls.
Referenced by MultiHandler::addComponent(), run(), MultiHandler::runNext(), MultiHandler::shutdown(), and ~Handler().
|
protected |
Referenced by isRunning(), and run().
|
staticprotected |
Referenced by runBetween().