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

ParameterDatabase Class Reference
[Data Processing]

#include <ParameterDatabase.h>

Inheritance diagram for ParameterDatabase:

CC_RootObject DC_BasicDatabase DC_SampleR1Database DC_SampleR2Database DC_SampleR3Database DC_DummyDatabase List of all members.

Detailed Description

Base class from which all parameter database classes are derived.

A parameter database object encapsulates a set of parameter values. Each parameter can have two values: the default value and the current value. The default value is the value of the parameters immediately after the database object is created or reset. The current values are initialized with the default values at the time the database object is created or reset and they can subsequently be modified.

Parameters are identified by a parameter identifier. Syntactically, this is a positive integer. Each application instantiated from the framework would have its own set of parameter identifiers.

In order to properly use the parameter database abstraction, it is necessary to understand the conceptual implementation model that is behind the interface defined in this class. Parameter database information is stored in two tables: the Default Table and the Operational Table. Each table stores a sequence of pairs. The pairs have the form: (parameter value, parameter identifier). Each entry in the table, in other words, contains the value of a parameter and its identifier. The two tables store values for the same set of parameters. They differ only because the values stored in the default table are intended to remain fixed whereas the values stored in the operational table can be dynamically updated. The operational table is initialized with a copy of the default table (this is done using the reset operation).

In many implementations, the default table will be stored in ROM and the operational table will be stored in RAM.

No methods are defined to set the default parameter values. This is because, in most cases, these are defined outside the parameter database class (they may, for instance, be burnt in PROM).

A parameter database is a low-level data structure whose implementation will usually require use of pointers. Most implementations of this class will therefore violate project specific coding rule PR3.1.

Client components can access the parameters in two ways. They can either get their values using the getter methods defined in this interface. Or they can link to the parameters using the getParameterPointer method. This method returns a pointer to a specific parameter (as identified by its identifier) which the client component can then store internally and use to directly access the parameter value.

Parameters have a type. The type of the parameter defines how the raw parameter value is interpreted and how it is returned to the external user of the database. The possible types for the parameters are: unsigned int, int, unsigned short, unsigned char, char, float, double. For each paramete type, there is a dedicated parameter getter method. Note that this interface does not mandate any protection against attempts to access parameters with the wrong type. Thus, for instance, if the parameter identified by identifier ID is intended to represent an integer, attempts to retrieve it as if it were of float type (using method getFloatParameter(ID)) will not necessarily result in an error and may produce a meaningless result. Avoiding this type of errors is the responsibility of the user. Subclasses, however, are free to introduce some run-time check to catch this kind of error.

For similar reasons, the interface defined by this class does not mandate any checks on the legality of the value of the parameter identifier in the method calls. Such checks can again be added by subclasses.

The methods declared by this class allow an application component to establish a link between their internal variables and the database parameters. The process whereby this link is established is called database linking. Two types of database linking are allowed by this class: copy link and pointer link.

In a copy link, the application component holds a reference to the parameter database and to the identifier of the target parameter and periodically updates the value of its internal variable by copying the value of the target database parameter.

In a pointer link, the application component internally defines a pointer which is then initialized to point to the target database parameter. The application component effectively uses the target database parameter as its internal variable.

This is an abstract class because the internal organization of the parameter database is application-dependent. All the class methods are declared abstract. In particular, the data structure used to represent the parameter tables and the way parameters and their identifiers are associated is application dependent.

Todo:
This class defines the setter and getter methods to be virtual. This is expensive in CPU time. Given that database implementations will often be generated automatically by XSL programs, and given that an application would normally only have one database component, it may be wiser to have the XSL program generate an implementation for class ParameterDatabase that is defined to have only non-virtual methods. The problem with this approach is that it is not possible to have multiple implementations of a database in a single delivery and that therefore it is not possible to have several database test cases in the same delivery (this could be alleviated by generating the test case for the database as well as the database implementation).
Author:
Alessandro Pasetti (P&P Software GmbH)
Version:
1.0

Definition at line 126 of file ParameterDatabase.h.

Public Member Functions

 ParameterDatabase (void)
 Instantiate a parameter database object.

virtual void reset (void)=0
 Load the current values of the parameters with their default values.

virtual void setParameter (TD_DatabaseId parId, unsigned int newValue)=0
 Set the current value of a parameter interpreted as an unsigned integer.

virtual void setParameter (TD_DatabaseId parId, int newValue)=0
 Set the current value of a parameter interpreted as an integer.

virtual void setParameter (TD_DatabaseId parId, unsigned short newValue)=0
 Set the current value of a parameter interpreted as an unsigned short.

virtual void setParameter (TD_DatabaseId parId, short newValue)=0
 Set the current value of a parameter interpreted as an short.

virtual void setParameter (TD_DatabaseId parId, bool newValue)=0
 Set the current value of a parameter interpreted as a boolean.

virtual void setParameter (TD_DatabaseId parId, char newValue)=0
 Set the current value of a parameter interpreted as a char.

virtual void setParameter (TD_DatabaseId parId, unsigned char newValue)=0
 Set the current value of a parameter interpreted as an unsigned char.

virtual void setParameter (TD_DatabaseId parId, float newValue)=0
 Set the current value of a parameter interpreted as a float.

virtual void setParameter (TD_DatabaseId parId, double newValue)=0
 Set the current value of a parameter interpreted as a double.

virtual unsigned int getParameterUnsignedInt (TD_DatabaseId parId)=0
 Get the current value of a parameter interpreted as an unsigned integer.

virtual int getParameterInt (TD_DatabaseId parId)=0
 Get the current value of a parameter interpreted as an integer.

virtual unsigned short getParameterUnsignedShort (TD_DatabaseId parId)=0
 Get the current value of a parameter interpreted as an unsigned short.

virtual short getParameterShort (TD_DatabaseId parId)=0
 Get the current value of a parameter interpreted as a short.

virtual bool getParameterBool (TD_DatabaseId parId)=0
 Get the current value of a parameter interpreted as a boolean.

virtual unsigned char getParameterUnsignedChar (TD_DatabaseId parId)=0
 Get the current value of a parameter interpreted as an unsigned char.

virtual char getParameterChar (TD_DatabaseId parId)=0
 Get the current value of a parameter interpreted as a char.

virtual float getParameterFloat (TD_DatabaseId parId)=0
 Get the current value of a parameter interpreted as a float.

virtual double getParameterDouble (TD_DatabaseId parId)=0
 Get the current value of a parameter interpreted as a double.

virtual unsigned int * getParameterPointerUnsignedInt (TD_DatabaseId parId)=0
 Return the pointer to the variable in the operational table storing the parameter identified by parId.

virtual int * getParameterPointerInt (TD_DatabaseId parId)=0
 Return the pointer to the variable in the operational table storing the parameter identified by parId.

virtual unsigned short * getParameterPointerUnsignedShort (TD_DatabaseId parId)=0
 Return the pointer to the variable in the operational table storing the parameter identified by parId.

virtual short * getParameterPointerShort (TD_DatabaseId parId)=0
 Return the pointer to the variable in the operational table storing the parameter identified by parId.

virtual unsigned char * getParameterPointerUnsignedChar (TD_DatabaseId parId)=0
 Return the pointer to the variable in the operational table storing the parameter identified by parId.

virtual char * getParameterPointerChar (TD_DatabaseId parId)=0
 Return the pointer to the variable in the operational table storing the parameter identified by parId.

virtual bool * getParameterPointerBool (TD_DatabaseId parId)=0
 Return the pointer to the variable in the operational table storing the parameter identified by parId.

virtual float * getParameterPointerFloat (TD_DatabaseId parId)=0
 Return the pointer to the variable in the operational table storing the parameter identified by parId.

virtual double * getParameterPointerDouble (TD_DatabaseId parId)=0
 Return the pointer to the variable in the operational table storing the parameter identified by parId.


Constructor & Destructor Documentation

ParameterDatabase::ParameterDatabase void   ) 
 

Instantiate a parameter database object.

This method returns without taking any actions.

Definition at line 13 of file ParameterDatabase.cpp.


Member Function Documentation

virtual bool ParameterDatabase::getParameterBool TD_DatabaseId  parId  )  [pure virtual]
 

Get the current value of a parameter interpreted as a boolean.

Parameters:
parId the identifier of the parameter to be set
Returns:
the current value of the parameter

Implemented in DC_BasicDatabase, DC_SampleR1Database, DC_SampleR2Database, and DC_SampleR3Database.

virtual char ParameterDatabase::getParameterChar TD_DatabaseId  parId  )  [pure virtual]
 

Get the current value of a parameter interpreted as a char.

Parameters:
parId the identifier of the parameter to be set
Returns:
the current value of the parameter

Implemented in DC_BasicDatabase, DC_SampleR1Database, DC_SampleR2Database, and DC_SampleR3Database.

virtual double ParameterDatabase::getParameterDouble TD_DatabaseId  parId  )  [pure virtual]
 

Get the current value of a parameter interpreted as a double.

Parameters:
parId the identifier of the parameter to be set
Returns:
the current value of the parameter

Implemented in DC_BasicDatabase, DC_SampleR1Database, DC_SampleR2Database, and DC_SampleR3Database.

virtual float ParameterDatabase::getParameterFloat TD_DatabaseId  parId  )  [pure virtual]
 

Get the current value of a parameter interpreted as a float.

Parameters:
parId the identifier of the parameter to be set
Returns:
the current value of the parameter

Implemented in DC_BasicDatabase, DC_SampleR1Database, DC_SampleR2Database, and DC_SampleR3Database.

virtual int ParameterDatabase::getParameterInt TD_DatabaseId  parId  )  [pure virtual]
 

Get the current value of a parameter interpreted as an integer.

Parameters:
parId the identifier of the parameter to be set
Returns:
the current value of the parameter

Implemented in DC_BasicDatabase, DC_SampleR1Database, DC_SampleR2Database, and DC_SampleR3Database.

virtual bool* ParameterDatabase::getParameterPointerBool TD_DatabaseId  parId  )  [pure virtual]
 

Return the pointer to the variable in the operational table storing the parameter identified by parId.

The variable is interpreted as of type bool.

See also:
getParameterPointerUnsignedInt
Returns:
the parameter pointer
Parameters:
parId the parameter identifier

Implemented in DC_BasicDatabase, DC_SampleR1Database, DC_SampleR2Database, and DC_SampleR3Database.

virtual char* ParameterDatabase::getParameterPointerChar TD_DatabaseId  parId  )  [pure virtual]
 

Return the pointer to the variable in the operational table storing the parameter identified by parId.

The variable is interpreted as of type char.

See also:
getParameterPointerUnsignedInt
Returns:
the parameter pointer
Parameters:
parId the parameter identifier

Implemented in DC_BasicDatabase, DC_SampleR1Database, DC_SampleR2Database, and DC_SampleR3Database.

virtual double* ParameterDatabase::getParameterPointerDouble TD_DatabaseId  parId  )  [pure virtual]
 

Return the pointer to the variable in the operational table storing the parameter identified by parId.

The variable is interpreted as of type double.

See also:
getParameterPointerUnsignedInt
Returns:
the parameter pointer
Parameters:
parId the parameter identifier

Implemented in DC_BasicDatabase, DC_SampleR1Database, DC_SampleR2Database, and DC_SampleR3Database.

virtual float* ParameterDatabase::getParameterPointerFloat TD_DatabaseId  parId  )  [pure virtual]
 

Return the pointer to the variable in the operational table storing the parameter identified by parId.

The variable is interpreted as of type float.

See also:
getParameterPointerUnsignedInt
Returns:
the parameter pointer
Parameters:
parId the parameter identifier

Implemented in DC_BasicDatabase, DC_SampleR1Database, DC_SampleR2Database, and DC_SampleR3Database.

virtual int* ParameterDatabase::getParameterPointerInt TD_DatabaseId  parId  )  [pure virtual]
 

Return the pointer to the variable in the operational table storing the parameter identified by parId.

The variable is interpreted as of type int.

See also:
getParameterPointerUnsignedInt
Returns:
the parameter pointer
Parameters:
parId the parameter identifier

Implemented in DC_BasicDatabase, DC_SampleR1Database, DC_SampleR2Database, and DC_SampleR3Database.

virtual short* ParameterDatabase::getParameterPointerShort TD_DatabaseId  parId  )  [pure virtual]
 

Return the pointer to the variable in the operational table storing the parameter identified by parId.

The variable is interpreted as of type short.

See also:
getParameterPointerUnsignedInt
Returns:
the parameter pointer
Parameters:
parId the parameter identifier

Implemented in DC_BasicDatabase, DC_SampleR1Database, DC_SampleR2Database, and DC_SampleR3Database.

virtual unsigned char* ParameterDatabase::getParameterPointerUnsignedChar TD_DatabaseId  parId  )  [pure virtual]
 

Return the pointer to the variable in the operational table storing the parameter identified by parId.

The variable is interpreted as of type unsigned char.

See also:
getParameterPointerUnsignedInt
Returns:
the parameter pointer
Parameters:
parId the parameter identifier

Implemented in DC_BasicDatabase, DC_SampleR1Database, DC_SampleR2Database, and DC_SampleR3Database.

virtual unsigned int* ParameterDatabase::getParameterPointerUnsignedInt TD_DatabaseId  parId  )  [pure virtual]
 

Return the pointer to the variable in the operational table storing the parameter identified by parId.

The variable is interpreted as of type unsigned int.

This and other methods returing pointers to parameters are typically used to set up a pointer link between a target database parameter and the internal variable of an application component. This can be done as follows. Consider an application component instantiated from class Comp which defines an internal variable var. Suppose that it is desired to link this variable to the parameter characterized by identifier PAR_ID in the database pDatabase. The Comp class should expose a database linker method:

      class Comp {
          unsigned int* par;
          . . .
          void linkParToDatabase(TD_DatabaseId parId, ParameterDatabase* pDB) {
              par = pDB->getParameterPointerUnsignedInt(parId);
          }
          . . .  
The application component must then be configured as follows:<PRE> Comp* comp; // the application component ParameterDatabase* pDB; // the parameter database TD_DatabaseId PAR_ID; // the parameter identifier . . . comp->linkParToDatabase(PAR_ID,pDB); The last statement sets up a permanent link between the internal application component variable and the database parameter. Note that use of this mechanism entails a violation of coding rule PR3.1. This is inevitable if the database linking is to be performed in an efficient manner.
Returns:
the parameter pointer
Parameters:
parId the parameter identifier

Implemented in DC_BasicDatabase, DC_SampleR1Database, DC_SampleR2Database, and DC_SampleR3Database.

virtual unsigned short* ParameterDatabase::getParameterPointerUnsignedShort TD_DatabaseId  parId  )  [pure virtual]
 

Return the pointer to the variable in the operational table storing the parameter identified by parId.

The variable is interpreted as of type unsigned short.

See also:
getParameterPointerUnsignedInt
Returns:
the parameter pointer
Parameters:
parId the parameter identifier

Implemented in DC_BasicDatabase, DC_SampleR1Database, DC_SampleR2Database, and DC_SampleR3Database.

virtual short ParameterDatabase::getParameterShort TD_DatabaseId  parId  )  [pure virtual]
 

Get the current value of a parameter interpreted as a short.

Parameters:
parId the identifier of the parameter to be set
Returns:
the current value of the parameter

Implemented in DC_BasicDatabase, DC_SampleR1Database, DC_SampleR2Database, and DC_SampleR3Database.

virtual unsigned char ParameterDatabase::getParameterUnsignedChar TD_DatabaseId  parId  )  [pure virtual]
 

Get the current value of a parameter interpreted as an unsigned char.

Parameters:
parId the identifier of the parameter to be set
Returns:
the current value of the parameter

Implemented in DC_BasicDatabase, DC_SampleR1Database, DC_SampleR2Database, and DC_SampleR3Database.

virtual unsigned int ParameterDatabase::getParameterUnsignedInt TD_DatabaseId  parId  )  [pure virtual]
 

Get the current value of a parameter interpreted as an unsigned integer.

Parameters:
parId the identifier of the parameter to be set
Returns:
the current value of the parameter

Implemented in DC_BasicDatabase, DC_SampleR1Database, DC_SampleR2Database, and DC_SampleR3Database.

virtual unsigned short ParameterDatabase::getParameterUnsignedShort TD_DatabaseId  parId  )  [pure virtual]
 

Get the current value of a parameter interpreted as an unsigned short.

Parameters:
parId the identifier of the parameter to be set
Returns:
the current value of the parameter

Implemented in DC_BasicDatabase, DC_SampleR1Database, DC_SampleR2Database, and DC_SampleR3Database.

virtual void ParameterDatabase::setParameter TD_DatabaseId  parId,
double  newValue
[pure virtual]
 

Set the current value of a parameter interpreted as a double.

Parameters:
parId the identifier of the parameter to be set
newValue the new current value of the parameter

Implemented in DC_BasicDatabase, DC_SampleR1Database, DC_SampleR2Database, and DC_SampleR3Database.

virtual void ParameterDatabase::setParameter TD_DatabaseId  parId,
float  newValue
[pure virtual]
 

Set the current value of a parameter interpreted as a float.

Parameters:
parId the identifier of the parameter to be set
newValue the new current value of the parameter

Implemented in DC_BasicDatabase, DC_SampleR1Database, DC_SampleR2Database, and DC_SampleR3Database.

virtual void ParameterDatabase::setParameter TD_DatabaseId  parId,
unsigned char  newValue
[pure virtual]
 

Set the current value of a parameter interpreted as an unsigned char.

Parameters:
parId the identifier of the parameter to be set
newValue the new current value of the parameter

Implemented in DC_BasicDatabase, DC_SampleR1Database, DC_SampleR2Database, and DC_SampleR3Database.

virtual void ParameterDatabase::setParameter TD_DatabaseId  parId,
char  newValue
[pure virtual]
 

Set the current value of a parameter interpreted as a char.

Parameters:
parId the identifier of the parameter to be set
newValue the new current value of the parameter

Implemented in DC_BasicDatabase, DC_SampleR1Database, DC_SampleR2Database, and DC_SampleR3Database.

virtual void ParameterDatabase::setParameter TD_DatabaseId  parId,
bool  newValue
[pure virtual]
 

Set the current value of a parameter interpreted as a boolean.

Parameters:
parId the identifier of the parameter to be set
newValue the new current value of the parameter

Implemented in DC_BasicDatabase, DC_SampleR1Database, DC_SampleR2Database, and DC_SampleR3Database.

virtual void ParameterDatabase::setParameter TD_DatabaseId  parId,
short  newValue
[pure virtual]
 

Set the current value of a parameter interpreted as an short.

Parameters:
parId the identifier of the parameter to be set
newValue the new current value of the parameter

Implemented in DC_BasicDatabase, DC_SampleR1Database, DC_SampleR2Database, and DC_SampleR3Database.

virtual void ParameterDatabase::setParameter TD_DatabaseId  parId,
unsigned short  newValue
[pure virtual]
 

Set the current value of a parameter interpreted as an unsigned short.

Parameters:
parId the identifier of the parameter to be set
newValue the new current value of the parameter

Implemented in DC_BasicDatabase, DC_SampleR1Database, DC_SampleR2Database, and DC_SampleR3Database.

virtual void ParameterDatabase::setParameter TD_DatabaseId  parId,
int  newValue
[pure virtual]
 

Set the current value of a parameter interpreted as an integer.

Parameters:
parId the identifier of the parameter to be set
newValue the new current value of the parameter

Implemented in DC_BasicDatabase, DC_SampleR1Database, DC_SampleR2Database, and DC_SampleR3Database.

virtual void ParameterDatabase::setParameter TD_DatabaseId  parId,
unsigned int  newValue
[pure virtual]
 

Set the current value of a parameter interpreted as an unsigned integer.

Parameters:
parId the identifier of the parameter to be set
newValue the new current value of the parameter

Implemented in DC_BasicDatabase, DC_SampleR1Database, DC_SampleR2Database, and DC_SampleR3Database.


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