Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

DC_EventRepository Class Reference

#include <DC_EventRepository.h>

Inheritance diagram for DC_EventRepository:

CC_RootObject DC_PUSEventRepository List of all members.

Detailed Description

Base class from which all event repository classes are derived.

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.

See also:
DC_Event
Author:
Alessandro Pasetti (P&P Software)

Roberto Totaro

Version:
1.1

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.

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


Constructor & Destructor Documentation

DC_EventRepository::DC_EventRepository void   ) 
 

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.


Member Function Documentation

void DC_EventRepository::create CC_RootObject originator,
TD_EventType  eventId
[virtual]
 

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 setEnable(boolean)) or selectively (through method setSelectiveEnableMask(int)). Clients that call this method in order to report an event should pass to it a reference to the originator of the event and the event type identifier. The originator is the component that detected or triggered the event. The event type identifier is an enumeration value that identifies the type of event. An event repository can use the pointer to the event originator to acquire additional information about the event. This implementation however does not use it. It takes the event type identifier, adds a time stamp to it and stores it in a circular FIFO buffer. If the buffer is already full, the oldest event report is overwritten. The pseudo-code for this method is as follows:

    if (isEnabled())
         return;
    if (isEnabled(eventId))
         . . .  // add timestamp to event and store in repository
    else
         return; 
See also:
setEnabled
Parameters:
originator the originator of the event
eventId the event type identifier

Reimplemented in DC_PUSEventRepository.

Definition at line 59 of file DC_EventRepository.cpp.

void DC_EventRepository::createEventDataStructure void   )  [protected, virtual]
 

Create the data structure holding the event instances in the repository.

This implementation creates a data structure for events of type DC_Event. Repository subclasses that must hold different kinds of events should override this method to create a data structure appropriate to their type of events.

See also:
setRepositorySize

Definition at line 50 of file DC_EventRepository.cpp.

unsigned int DC_EventRepository::getCounter void   )  const [inline]
 

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 unsigned int variable. For reasons of run-time efficiency, there is no overflow check and this class will generate an exception when the number of events exceeds the capacity of the counter.

Returns:
number of events created in the repostory since repository creation.

Definition at line 21 of file DC_EventRepository_inl.h.

TD_EventType DC_EventRepository::getEventType void   )  const [inline]
 

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.

See also:
latest
Returns:
event identifier of the event currently pointed to by the event pointer

Definition at line 53 of file DC_EventRepository_inl.h.

ObsClock * DC_EventRepository::getObsClock void   )  const [inline]
 

Return the OBS Clock component.

See also:
setObsClock
Returns:
the OBS Clock component.

Definition at line 65 of file DC_EventRepository_inl.h.

unsigned int DC_EventRepository::getRepositorySize void   )  const [inline]
 

Return the size of the event repository.

Returns:
the size of the event repository

Definition at line 25 of file DC_EventRepository_inl.h.

TD_ObsTime DC_EventRepository::getTimeStamp void   )  const [inline]
 

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.

See also:
latest
Returns:
time stamp of the event currently pointed to by the event pointer

Definition at line 59 of file DC_EventRepository_inl.h.

bool DC_EventRepository::isEnabled TD_EventType  eventType  )  const [inline]
 

Check the enable status for events of type eventType.

Returns:
true if the generation of events of type eventType is enabled, false otherwise

Definition at line 43 of file DC_EventRepository_inl.h.

bool DC_EventRepository::isEnabled void   )  const [inline]
 

Check the global enable status of the repository.

Returns:
true if the repository is enabled, false otherwise

Definition at line 39 of file DC_EventRepository_inl.h.

bool DC_EventRepository::isIterationFinished void   )  const [inline]
 

Iteration method to return true if the iteration is finished.

The iteration is finished if method previous has been called N times since the last time method latest was called where N is either the size of the repository (if the repository is is full) of the number of items in the repository (if it is not full).

If the repository is empty, this method returns true.

See also:
latest
Returns:
true if the iteration is finished

Definition at line 49 of file DC_EventRepository_inl.h.

bool DC_EventRepository::isObjectConfigured void   )  [virtual]
 

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.

Returns:
true if the object is configured, false otherwise

Reimplemented from CC_RootObject.

Reimplemented in DC_PUSEventRepository.

Definition at line 89 of file DC_EventRepository.cpp.

void DC_EventRepository::latest void   ) 
 

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 pointer 
If 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 create during an on-going iteration. The effect of doing this is that the iterators may skip one event but the internal state of the repository remains consistent.

See also:
eventPointer

DC_Event::getEventType

DC_Event::getTimeStamp

Definition at line 72 of file DC_EventRepository.cpp.

void DC_EventRepository::previous void   ) 
 

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.

See also:
latest

Definition at line 77 of file DC_EventRepository.cpp.

void DC_EventRepository::reset void   ) 
 

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.

void DC_EventRepository::setEnabled TD_EventType  eventType,
bool  isEnabled
[inline]
 

Set the selective enable status of the repository.

This method can be used to enabled or disable creation of events of type eventType. When creation of events of a certain type is disabled, a call to method create for an event of that type has no effect.

Parameters:
eventType the event type
isEnabled the new enable status for events of the specified type

Definition at line 33 of file DC_EventRepository_inl.h.

void DC_EventRepository::setEnabled bool  isEnabled  )  [inline]
 

Set the global enable status of the repository.

When the repository is disabled, a call to method create has no effect.

Parameters:
isEnabled if true, then the repository is enabled; if false, then the repository is disabled

Definition at line 29 of file DC_EventRepository_inl.h.

void DC_EventRepository::setObsClock ObsClock pObsClock  )  [inline]
 

Load the OBS Clock component.

The event repository needs access to this component in order to time-stamp events as they are created.

Parameters:
pObsClock the OBS Clock component.

Definition at line 71 of file DC_EventRepository_inl.h.

void DC_EventRepository::setRepositorySize unsigned int  repositorySize  ) 
 

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.

See also:
createEventDataStructure

pList

Parameters:
repositorySize the maximum number of events that can be stored in the event repository

Definition at line 38 of file DC_EventRepository.cpp.


Member Data Documentation

unsigned int DC_EventRepository::eventPointer [protected]
 

Event pointer.

This variable is updated by the iterator methods.

See also:
latest

Definition at line 115 of file DC_EventRepository.h.

DC_Event** DC_EventRepository::pList [protected]
 

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 DC_Event. In general, to a subclass of DC_EventRepository there should correspond a subclass of DC_Event. In order to allow the implementation provided by this class to be as far as possible reused by its subclasses, the manipulation of the event reports is done through pointers to objects of type DC_Event.

Definition at line 109 of file DC_EventRepository.h.


The documentation for this class was generated from the following files:
Copyright 2003 P&P Software GmbH - All Rights Reserved