LRAUV  revA
ComponentRegistry Class Reference

Keeps track of all Components currently loaded and their assignment to handlers. More...

#include <ComponentRegistry.h>

Collaboration diagram for ComponentRegistry:

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 HandlerInsert (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 ComponentFind (const Str &name)
 Finds a component given its name. More...
 
static HandlerFindHandler (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 TimespanGetControlThreadPeriod ()
 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 ComponentGetIndexed (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 ComponentPurgeEntry (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 ListOfComponentRegistryEntriesList_
 The list of ComponentRegistryEntries. More...
 
static LoggerLogger_
 Pointer to a Logger. More...
 
static ControlThreadControlThread_
 Pointer to the ControlThread. More...
 

Detailed Description

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.

Member Typedef Documentation

Constructor & Destructor Documentation

ComponentRegistry::ComponentRegistry ( )
inlineprivate

Private Constructor for static class.

Member Function Documentation

void ComponentRegistry::DeleteAll ( void  )
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().

Component * ComponentRegistry::Find ( const Str name)
static

Finds a component given its name.

Case sensitive.

Parameters
nameName of component to be found
Returns
Pointer to component if found, or NULL if not found

References FlexArray< T >::get(), FlexArrayBase::getMaxIndex(), FlexArrayBase::getMinIndex(), Component::getName(), and List_.

Referenced by CommandLine::commandFailComponent(), Config::Instance(), ReadDataComponent::Instance(), and Config::LoadPersistedConfigSets().

Handler * ComponentRegistry::FindHandler ( const Str name)
static

Finds a component handler given its name.

Case sensitive.

Parameters
nameName of component handler to be found
Returns
Pointer to handler if found, or NULL if not found

References ComponentRegistry::ComponentRegistryEntry::component_, FlexArray< T >::get(), FlexArrayBase::getMaxIndex(), FlexArrayBase::getMinIndex(), Component::getName(), ComponentRegistry::ComponentRegistryEntry::handler_, and List_.

const Timespan & ComponentRegistry::GetControlThreadPeriod ( )
static

Gets the period of the ControlThread.

Returns
period of the ControlThread, in seconds

References ControlThread_, and Component::getPeriod().

Referenced by Handler::runBetween().

unsigned int ComponentRegistry::GetEntryCount ( void  )
static

Returns the number of Entries.

References List_, and FlexArrayBase::size().

Referenced by Supervisor::configure(), CBIT::handleComponentFaults(), and CBIT::initialize().

const Component * ComponentRegistry::GetIndexed ( const unsigned int  index)
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().

void ComponentRegistry::Initialize ( )
static

Initializes the list and logger.

References ControlThread_, Insert(), List_, and Logger_.

Referenced by Supervisor::initialize().

Handler * ComponentRegistry::Insert ( Component component,
bool  insertFront = false 
)
static
size_t ComponentRegistry::Length ( )
static

Returns the number of entries in the registry.

Returns
Number of entries in the registry.

References List_, and FlexArrayBase::size().

Referenced by CommandLine::commandFailComponent().

Component * ComponentRegistry::PurgeEntry ( ComponentRegistryEntry entry)
staticprotected

The actual "cleanup" function called by RemoveC and DeleteAll.

Doesn't remove entry from list_, assumes caller will do that.

Parameters
entryEntry to clean up
Returns
Component contained in the entry (or NULL), which isn't touched.

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

void ComponentRegistry::Remove ( Component component)
static

Remove the given component from the registry.

Does not delete the component, but does delete any handlers (uses purgeEntry)

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

void ComponentRegistry::SetControlThreadPeriod ( const Timespan period)
static

Sets the period of the ControlThread.

Parameters
periodPeriod of the ControlThread, in seconds

References ControlThread_, and Component::setPeriod().

Referenced by LoopControl::run().

void ComponentRegistry::ShutdownThreads ( void  )
static
void ComponentRegistry::StartThreads ( void  )
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().

void ComponentRegistry::Uninitialize ( )
static

Uninitializes the list.

References ControlThread_, DeleteAll(), List_, and Logger_.

Referenced by Supervisor::uninitialize().

static void ComponentRegistry::UninitializeControlThread ( )
static

Uninitializes the control thread.

Member Data Documentation

ControlThread * ComponentRegistry::ControlThread_
staticprivate
Logger * ComponentRegistry::Logger_
staticprivate

Pointer to a Logger.

Referenced by Initialize(), Insert(), ShutdownThreads(), and Uninitialize().


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