#include <DC_EventRepository.h>
Inheritance diagram for DC_EventRepository:
An event repository is a generic container for event reports. An event report is intended to record an occurrence of relevance to an application. The event reports are stored in instances of an event class. To each event repository class is associated an event class. The event class associated to the DC_EventRepository
class is DC_Event.
Event repositories are characterized by one attribute and three services. The attribute is the repository size. The repository size defines the maximum number of event reports that can be stored in the repository. In a typical implementation, event reports might be stored in a circular buffer and only the S most recent reports are kept where S is the repository size.
The three services are the event creation service, the repository iteration service and the event enable service.
The event creation service allows a client to make a new entry in the event repository. Normally, to each type of event, some data that describe the circumstances that led to its creation are associated. The transfer of this information from the event creating component to the event repository component follows a mixed "push-pull" model. The component that creates the event passes an event type identifier to the event repository ("information push"). Additionally, it passes a reference to itself that allows the event repository to collect additional information about the event ("information pull"). This model makes it easy for designers to change the type and amount of information that is associated to each event since this is defined only in the event repository, not in the event creating component.
The repository iteration service allows clients to inspect all event reports currently stored in the repository in sequence starting with the most recently stored event report. The event repository maintains an event pointer that points to one of the event reports currently stored in the repository. This pointer can be made to iterate through the event reports in the repository using the latest
, previous
and isIterationFinished
methods. The attributes of the event report pointed at by the event pointer can be retrieved by using getter methods that are defined by the repository itself.
The event enable service allows creation of new event reports to be enabled and disabled. This can be done either globally by disabling the creation of all new event or selectively by disabling only some events.
This class offers a basic implementation of an event repository. Applications which need more specialized types of event reports or different implementation of the event report services, or additional services, should extend this class and, if necessary, the associated event class.
This class implements the event creation service in a single method called create
. This method takes as its input the pointer to the "event originator" and the event type. The originator of the event is seen as a generic component of type CC_RootObject
. Normally, the event originator is the component that is calling the create
method.
Subclasses can offer multiple implementations of method create
that differ on the basis of the type of the "event originator" (for instance, one could have a create
method for event originators of type Telecommand
that intercepts event reports originating from telecommands, another create
method for event originators of type Manouvre
that intercepts event reports for manoeuvres, etc). Each create
method would gather type-specific information from its event originator and create the appropriate event report.
Roberto Totaro
Definition at line 89 of file DC_EventRepository.h.
Public Member Functions | |
DC_EventRepository (void) | |
Instantiate an event repository. | |
void | setRepositorySize (unsigned int repositorySize) |
Setter method for the repository size. | |
virtual void | create (CC_RootObject *originator, TD_EventType eventId) |
Implement the event creation service. | |
void | setEnabled (bool isEnabled) |
Set the global enable status of the repository. | |
void | setEnabled (TD_EventType eventType, bool isEnabled) |
Set the selective enable status of the repository. | |
bool | isEnabled (void) const |
Check the global enable status of the repository. | |
bool | isEnabled (TD_EventType eventType) const |
Check the enable status for events of type eventType . | |
void | latest (void) |
Iteration method to position the event pointer on the most recently stored event. | |
void | previous (void) |
Iteration method to advance the event pointer to the next oldest event. | |
bool | isIterationFinished (void) const |
Iteration method to return true if the iteration is finished. | |
TD_EventType | getEventType (void) const |
Return the event identifier of the event currently pointed to by the event pointer. | |
TD_ObsTime | getTimeStamp (void) const |
Return the time stamp of the event currently pointed to by the event pointer. | |
unsigned int | getCounter (void) const |
Return the number of events that have been stored in the repository since it was created (including events that have been overwritten). | |
unsigned int | getRepositorySize (void) const |
Return the size of the event repository. | |
void | setObsClock (ObsClock *pObsClock) |
Load the OBS Clock component. | |
ObsClock * | getObsClock (void) const |
Return the OBS Clock component. | |
void | reset (void) |
Reset the repository. | |
virtual bool | isObjectConfigured (void) |
Perform a class-specific configuration check on a repository object: verify that the repository size has a legal value and that the OBS clock component has been loaded. | |
Protected Member Functions | |
virtual void | createEventDataStructure (void) |
Create the data structure holding the event instances in the repository. | |
Protected Attributes | |
DC_Event ** | pList |
Array of pointers to the events in the repository. | |
unsigned int | eventPointer |
Event pointer. |
|
Instantiate an event repository. The global enable status of the repository is initialized to "enabled". The selective enable status is initialized to "enabled" for all event types. The repository size is initialized with an illegal value to signify that the repository is not yet configured. Definition at line 23 of file DC_EventRepository.cpp. |
|
Implement the event creation service.
A call to this method causes a new event report to be stored in the repository if event creation is enabled. Event creation can be disabled either globally (through method if (isEnabled()) return; if (isEnabled(eventId)) . . . // add timestamp to event and store in repository else return;
Reimplemented in DC_PUSEventRepository. Definition at line 59 of file DC_EventRepository.cpp. |
|
Create the data structure holding the event instances in the repository.
This implementation creates a data structure for events of type
Definition at line 50 of file DC_EventRepository.cpp. |
|
Return the number of events that have been stored in the repository since it was created (including events that have been overwritten).
The event counter is stored in an
Definition at line 21 of file DC_EventRepository_inl.h. |
|
Return the event identifier of the event currently pointed to by the event pointer. This method is typically used in conjunctions with the iteration methods.
Definition at line 53 of file DC_EventRepository_inl.h. |
|
Return the OBS Clock component.
Definition at line 65 of file DC_EventRepository_inl.h. |
|
Return the size of the event repository.
Definition at line 25 of file DC_EventRepository_inl.h. |
|
Return the time stamp of the event currently pointed to by the event pointer. This method is typically used in conjunctions with the iteration methods.
Definition at line 59 of file DC_EventRepository_inl.h. |
|
Check the enable status for events of type
Definition at line 43 of file DC_EventRepository_inl.h. |
|
Check the global enable status of the repository.
Definition at line 39 of file DC_EventRepository_inl.h. |
|
Iteration method to return true if the iteration is finished.
The iteration is finished if method If the repository is empty, this method returns true.
Definition at line 49 of file DC_EventRepository_inl.h. |
|
Perform a class-specific configuration check on a repository object: verify that the repository size has a legal value and that the OBS clock component has been loaded.
Reimplemented from CC_RootObject. Reimplemented in DC_PUSEventRepository. Definition at line 89 of file DC_EventRepository.cpp. |
|
Iteration method to position the event pointer on the most recently stored event. The iteration methods are typically used in a loop like the following: for (latest(); !isIterationFinished(); previous()) . . . // process event pointed to by event pointerIf the repository is empty, the event pointer is set to the first (non-configured) event in the repository. The attributes of the event report pointed to by the event pointer can be retrieved with the getEventId and getTimeStamp methods. The effect of this and the other iterator methods is simply to update the value of the event pointer variable. The event pointer is declared as a protected variable and can therefore be accessed by subclasses. Subclasses can therefore re-use the iteration services declared by this class. Calling this method also has the effect of resetting an on-going iteration.
The implementation of this method is robust to calls of method Definition at line 72 of file DC_EventRepository.cpp. |
|
Iteration method to advance the event pointer to the next oldest event. If the repository is empty or if the oldest event in the repository has already been reached, then this methods has no effect.
Definition at line 77 of file DC_EventRepository.cpp. |
|
Reset the repository. When a repository is reset, all its event entries are cleared and the event pointer is reset to point to the first (non-configured) entry in the repository. Note that the event counter and the enable flags are not affected by a call to this method. Definition at line 84 of file DC_EventRepository.cpp. |
|
Set the selective enable status of the repository.
This method can be used to enabled or disable creation of events of type
Definition at line 33 of file DC_EventRepository_inl.h. |
|
Set the global enable status of the repository.
When the repository is disabled, a call to method
Definition at line 29 of file DC_EventRepository_inl.h. |
|
Load the OBS Clock component. The event repository needs access to this component in order to time-stamp events as they are created.
Definition at line 71 of file DC_EventRepository_inl.h. |
|
Setter method for the repository size. The repository size defines the maximum number of event reports that can be stored by the repository. A call to this method causes the internal data structure where event reports are stored to be created and initialized. This class offers a default implementation as follows: pList = new DC_Event*[repositorySize]; createEventDataStructure(repositorySize);The method thus creates and initializes the data structure that holds the pointers to the events in the repository but creation of the data structure where the event themselves are held is delegated to the (protected) method createEventDataStructure . Subclasses must re-implement this latter method to instantiate a data structure to hold events as instances of the appropriate subclass of DC_Event (recall that to each event repository class, an event class is associated). Method setRepositorySize can instead be re-used unchanged since it is independent of the concrete type of events that are stored in the repository. This is an initialization method. It should be called before the event repository is used for the first time and it should not be called more than once. It is not legal to set the repository size to 0.
Definition at line 38 of file DC_EventRepository.cpp. |
|
Event pointer. This variable is updated by the iterator methods.
Definition at line 115 of file DC_EventRepository.h. |
|
Array of pointers to the events in the repository.
Event repository classes differ, among other things, in the type of event reports they store. Individual event reports are stored in objects of type Definition at line 109 of file DC_EventRepository.h. |