|
LRAUV
revA
|
Keeps track of all Components currently loaded and their assignment to handlers. More...
#include <ComponentRegistry.h>

Classes | |
| struct | ComponentRegistryEntry |
| A structure for containing all the ComponentRegistry's "entry" about a component. More... | |
Static Public Member Functions | |
| static void | Initialize () |
| Initializes the list and logger. More... | |
| static void | Uninitialize () |
| Uninitializes the list. More... | |
| static void | UninitializeControlThread () |
| Uninitializes the control thread. More... | |
| static Handler * | Insert (Component *component, bool insertFront=false) |
| Add the component to the registry. More... | |
| static void | Remove (Component *component) |
| Remove the given component from the registry. More... | |
| static Component * | Find (const Str &name) |
| Finds a component given its name. More... | |
| static Handler * | FindHandler (const Str &name) |
| Finds a component handler given its name. More... | |
| static size_t | Length () |
| Returns the number of entries in the registry. More... | |
| static void | StartThreads (void) |
| Start (spawn) all of the Components which run in their own ThreadHandlers. More... | |
| static void | ShutdownThreads (void) |
| Stop all of the Components which run in their own ThreadHandlers. More... | |
| static void | DeleteAll (void) |
| Delete all contained components and handlers (cleanup). More... | |
| static const Timespan & | GetControlThreadPeriod () |
| Gets the period of the ControlThread. More... | |
| static void | SetControlThreadPeriod (const Timespan &period) |
| Sets the period of the ControlThread. More... | |
| static unsigned int | GetEntryCount (void) |
| Returns the number of Entries. More... | |
| static const Component * | GetIndexed (const unsigned int index) |
| Returns the component at the indexed position Returns NULL if there is no component at the indicated index. More... | |
Static Protected Member Functions | |
| static Component * | PurgeEntry (ComponentRegistryEntry *entry) |
| The actual "cleanup" function called by RemoveC and DeleteAll. More... | |
Private Types | |
| typedef FlexArray< ComponentRegistry::ComponentRegistryEntry * > | ListOfComponentRegistryEntries |
Private Member Functions | |
| ComponentRegistry () | |
| Private Constructor for static class. More... | |
Static Private Attributes | |
| static ListOfComponentRegistryEntries * | List_ |
| The list of ComponentRegistryEntries. More... | |
| static Logger * | Logger_ |
| Pointer to a Logger. More... | |
| static ControlThread * | ControlThread_ |
| Pointer to the ControlThread. More... | |
Keeps track of all Components currently loaded and their assignment to handlers.
It also "owns" the ControlThread.
In general, the ComponentRegistry does not handle Component destruction. It's critical, of course, that Components be unregistered from the registry before being deleted.
|
private |
|
inlineprivate |
Private Constructor for static class.
|
static |
Delete all contained components and handlers (cleanup).
Goes in reverse order of component insertion. Calls purgeEntry on each remaining entry, then delete the component (which purgeEntry and removeEntry do not do)
References ControlThread_, FlexArrayBase::isEmpty(), List_, FlexArray< T >::pop(), and PurgeEntry().
Referenced by Uninitialize().
Finds a component given its name.
Case sensitive.
| name | Name of component to be found |
References FlexArray< T >::get(), FlexArrayBase::getMaxIndex(), FlexArrayBase::getMinIndex(), Component::getName(), and List_.
Referenced by CommandLine::commandFailComponent(), Config::Instance(), ReadDataComponent::Instance(), and Config::LoadPersistedConfigSets().
Finds a component handler given its name.
Case sensitive.
| name | Name of component handler to be found |
References ComponentRegistry::ComponentRegistryEntry::component_, FlexArray< T >::get(), FlexArrayBase::getMaxIndex(), FlexArrayBase::getMinIndex(), Component::getName(), ComponentRegistry::ComponentRegistryEntry::handler_, and List_.
|
static |
Gets the period of the ControlThread.
References ControlThread_, and Component::getPeriod().
Referenced by Handler::runBetween().
|
static |
Returns the number of Entries.
References List_, and FlexArrayBase::size().
Referenced by Supervisor::configure(), CBIT::handleComponentFaults(), and CBIT::initialize().
|
static |
Returns the component at the indexed position Returns NULL if there is no component at the indicated index.
References ComponentRegistry::ComponentRegistryEntry::component_, FlexArray< T >::get(), and List_.
Referenced by CommandLine::commandFailComponent(), Supervisor::configure(), and CBIT::handleComponentFaults().
|
static |
Initializes the list and logger.
References ControlThread_, Insert(), List_, and Logger_.
Referenced by Supervisor::initialize().
Add the component to the registry.
Uses the component's handler preferences to match it to a handler.
| component | The component added to the registry. |
| insertFront | If true, the component is inserted at the front of the list (first to start, last to be stopped) — used to force the Logger to the front of the list |
References ControlThread::addComponent(), Component::COMPONENT_ASYNC, Component::COMPONENT_BEHAVIOR, Component::COMPONENT_CONFIG, Component::COMPONENT_SYNC, ControlThread_, Syslog::ERROR, FlexArray< T >::get(), Component::getComponentType(), FlexArrayBase::getMaxIndex(), FlexArrayBase::getMinIndex(), Component::getName(), ControlThread::getSyncHandler(), ComponentRegistry::ComponentRegistryEntry::handler_, List_, Logger_, FlexArray< T >::push(), Handler::setAsControlLoopHandler(), Handler::setAsLogHandler(), Logger::syslog(), and Component::ThreadHandler.
Referenced by Maintainer::addMaintain(), Initialize(), Supervisor::initialize(), Config::LoadConfigFilesInPath(), and Module::registerComponent().
|
static |
Returns the number of entries in the registry.
References List_, and FlexArrayBase::size().
Referenced by CommandLine::commandFailComponent().
|
staticprotected |
The actual "cleanup" function called by RemoveC and DeleteAll.
Doesn't remove entry from list_, assumes caller will do that.
| entry | Entry to clean up |
References ComponentRegistry::ComponentRegistryEntry::component_, Component::COMPONENT_ASYNC, Component::COMPONENT_BEHAVIOR, Component::COMPONENT_CONFIG, Component::COMPONENT_SYNC, ControlThread_, ComponentRegistry::ComponentRegistryEntry::handler_, ComponentRegistry::ComponentRegistryEntry::handlerType_, ControlThread::removeComponent(), and Handler::shutdown().
Referenced by DeleteAll(), and Remove().
|
static |
Remove the given component from the registry.
Does not delete the component, but does delete any handlers (uses purgeEntry)
| component | The component to be removed from the registry. |
References ComponentRegistry::ComponentRegistryEntry::component_, FlexArray< T >::get(), FlexArrayBase::getMaxIndex(), FlexArrayBase::getMinIndex(), List_, FlexArray< T >::pop(), and PurgeEntry().
Referenced by Config::Instance(), Maintainer::removeMaintain(), Module::unregisterComponent(), and Module::~Module().
|
static |
Sets the period of the ControlThread.
| period | Period of the ControlThread, in seconds |
References ControlThread_, and Component::setPeriod().
Referenced by LoopControl::run().
|
static |
Stop all of the Components which run in their own ThreadHandlers.
Goes in LIFO order, so the last threaded Component added is the first one shutdown.
References Component::COMPONENT_ASYNC, FlexArray< T >::get(), FlexArrayBase::getMaxIndex(), FlexArrayBase::getMinIndex(), Handler::getName(), ComponentRegistry::ComponentRegistryEntry::handler_, ComponentRegistry::ComponentRegistryEntry::handlerType_, Syslog::INFO, List_, Logger_, Handler::shutdown(), and Logger::syslog().
Referenced by Supervisor::uninitialize().
|
static |
Start (spawn) all of the Components which run in their own ThreadHandlers.
Threads are started in the order in which their Components were added to the registry.
References Component::COMPONENT_ASYNC, FlexArray< T >::get(), FlexArrayBase::getMaxIndex(), FlexArrayBase::getMinIndex(), ComponentRegistry::ComponentRegistryEntry::handler_, ComponentRegistry::ComponentRegistryEntry::handlerType_, Handler::isRunning(), List_, and Handler::run().
Referenced by Supervisor::run().
|
static |
Uninitializes the list.
References ControlThread_, DeleteAll(), List_, and Logger_.
Referenced by Supervisor::uninitialize().
|
static |
Uninitializes the control thread.
|
staticprivate |
Pointer to the ControlThread.
Referenced by DeleteAll(), GetControlThreadPeriod(), Initialize(), Insert(), PurgeEntry(), SetControlThreadPeriod(), and Uninitialize().
|
staticprivate |
The list of ComponentRegistryEntries.
Referenced by DeleteAll(), Find(), FindHandler(), GetEntryCount(), GetIndexed(), Initialize(), Insert(), Length(), Remove(), ShutdownThreads(), StartThreads(), and Uninitialize().
|
staticprivate |
Pointer to a Logger.
Referenced by Initialize(), Insert(), ShutdownThreads(), and Uninitialize().