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

DC_BasicDatabase Class Reference

#include <DC_BasicDatabase.h>

Inheritance diagram for DC_BasicDatabase:

ParameterDatabase CC_RootObject DC_DummyDatabase List of all members.

Detailed Description

Default component implementing a basic parameter database.

The basic database implements the Default Table and the Operational Table as linear arrays. The identifier of a parameter is the index in the array at which the parameter is stored. Syntactically, the elements of the table arrays are of char type but the tables can hold elements of any type (the getter and setter operations defined in this class will perform the necessary casting operations to convert the raw bytes in the table arrays to the type required by the operation).

The default and operational tables are not defined by this class. This class loads the tables using methods setDefaultTable and setOperationalTable.

The configuration procedure for an instance of this class is as follows:

  1. Load the default table (method setDefaultTable)
  2. Load the operational table (method setOperationalTable)
  3. Set the length of the table (method setTableLength)
  4. Reset the component instance (method reset)
This class is designed for efficiency. It does not perform any legality checks on the access to the database. It therefore assumes that the client components is using correct parameter identifiers.

The getter and setter methods are implemented to be fast and efficient but this makes them vulnerable to alignement problems on some processors. For instance, the setter methods for integer-valued parameters is implemened as follows:<code> void DC_BasicDatabase::setParameter(TD_DatabaseId parId, int newValue) { *( (int*)(pOperationalTable+parId) ) = newValue; } On some processors, the assignment will fail if location (pOperationalTable+parId) does not correspond to a longword (4 bytes) boundary. There is no check to ensure that this is the case and it is the responsibility of the user to ensure that the setter method is called with the correct parameter values. The same applies to other setter and getter methods. A more robust (but possibly slower) implementation might use the memcpy library function to transfer the values of the data between the database locations and the method variables.

Author:
Alessandro Pasetti (P&P Software GmbH)
Version:
1.0

Definition at line 57 of file DC_BasicDatabase.h.

Public Member Functions

 DC_BasicDatabase (void)
 Instantiate a basic database component.

virtual void reset (void)
 Copy the default table array onto the operational table array.

void setTableLength (TD_DatabaseId length)
 Set the length of the default and operational table in number of bytes.

TD_DatabaseId getTableLength (void)
 Get the length of the default and operational table in number of bytes.

void setDefaultTable (char *pDefTable)
 Load the default table.

void setOperationalTable (char *pOperTable)
 Load the operational table.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

virtual bool isObjectConfigured (void)
 Perform a class-specific configuration check on a basic database object: verify that the default and operational tables have been loaded, that method reset has been called, and that the table length is greater than zero.


Constructor & Destructor Documentation

DC_BasicDatabase::DC_BasicDatabase void   ) 
 

Instantiate a basic database component.

The default and operational table arrays are initialized to illegal values to signify that the component is not yet configured. values. The class identifier is set.

Definition at line 17 of file DC_BasicDatabase.cpp.


Member Function Documentation

bool DC_BasicDatabase::getParameterBool TD_DatabaseId  parId  )  [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

Implements ParameterDatabase.

Definition at line 136 of file DC_BasicDatabase.cpp.

char DC_BasicDatabase::getParameterChar TD_DatabaseId  parId  )  [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

Implements ParameterDatabase.

Definition at line 131 of file DC_BasicDatabase.cpp.

double DC_BasicDatabase::getParameterDouble TD_DatabaseId  parId  )  [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

Implements ParameterDatabase.

Definition at line 146 of file DC_BasicDatabase.cpp.

float DC_BasicDatabase::getParameterFloat TD_DatabaseId  parId  )  [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

Implements ParameterDatabase.

Definition at line 141 of file DC_BasicDatabase.cpp.

int DC_BasicDatabase::getParameterInt TD_DatabaseId  parId  )  [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

Implements ParameterDatabase.

Definition at line 111 of file DC_BasicDatabase.cpp.

bool * DC_BasicDatabase::getParameterPointerBool TD_DatabaseId  parId  )  [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.

Returns:
the parameter pointer
Parameters:
parId the parameter identifier

Implements ParameterDatabase.

Definition at line 183 of file DC_BasicDatabase.cpp.

char * DC_BasicDatabase::getParameterPointerChar TD_DatabaseId  parId  )  [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.

Returns:
the parameter pointer
Parameters:
parId the parameter identifier

Implements ParameterDatabase.

Definition at line 178 of file DC_BasicDatabase.cpp.

double * DC_BasicDatabase::getParameterPointerDouble TD_DatabaseId  parId  )  [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.

Returns:
the parameter pointer
Parameters:
parId the parameter identifier

Implements ParameterDatabase.

Definition at line 193 of file DC_BasicDatabase.cpp.

float * DC_BasicDatabase::getParameterPointerFloat TD_DatabaseId  parId  )  [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.

Returns:
the parameter pointer
Parameters:
parId the parameter identifier

Implements ParameterDatabase.

Definition at line 188 of file DC_BasicDatabase.cpp.

int * DC_BasicDatabase::getParameterPointerInt TD_DatabaseId  parId  )  [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.

Returns:
the parameter pointer
Parameters:
parId the parameter identifier

Implements ParameterDatabase.

Definition at line 158 of file DC_BasicDatabase.cpp.

short * DC_BasicDatabase::getParameterPointerShort TD_DatabaseId  parId  )  [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.

Returns:
the parameter pointer
Parameters:
parId the parameter identifier

Implements ParameterDatabase.

Definition at line 168 of file DC_BasicDatabase.cpp.

unsigned char * DC_BasicDatabase::getParameterPointerUnsignedChar TD_DatabaseId  parId  )  [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.

Returns:
the parameter pointer
Parameters:
parId the parameter identifier

Implements ParameterDatabase.

Definition at line 173 of file DC_BasicDatabase.cpp.

unsigned int * DC_BasicDatabase::getParameterPointerUnsignedInt TD_DatabaseId  parId  )  [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.

Returns:
the parameter pointer
Parameters:
parId the parameter identifier

Implements ParameterDatabase.

Definition at line 153 of file DC_BasicDatabase.cpp.

unsigned short * DC_BasicDatabase::getParameterPointerUnsignedShort TD_DatabaseId  parId  )  [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.

Returns:
the parameter pointer
Parameters:
parId the parameter identifier

Implements ParameterDatabase.

Definition at line 163 of file DC_BasicDatabase.cpp.

short DC_BasicDatabase::getParameterShort TD_DatabaseId  parId  )  [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

Implements ParameterDatabase.

Definition at line 121 of file DC_BasicDatabase.cpp.

unsigned char DC_BasicDatabase::getParameterUnsignedChar TD_DatabaseId  parId  )  [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

Implements ParameterDatabase.

Definition at line 126 of file DC_BasicDatabase.cpp.

unsigned int DC_BasicDatabase::getParameterUnsignedInt TD_DatabaseId  parId  )  [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

Implements ParameterDatabase.

Definition at line 106 of file DC_BasicDatabase.cpp.

unsigned short DC_BasicDatabase::getParameterUnsignedShort TD_DatabaseId  parId  )  [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

Implements ParameterDatabase.

Definition at line 116 of file DC_BasicDatabase.cpp.

TD_DatabaseId DC_BasicDatabase::getTableLength void   ) 
 

Get the length of the default and operational table in number of bytes.

See also:
setTableLength
Returns:
the number of char elements in the default and in the operational table

Definition at line 38 of file DC_BasicDatabase.cpp.

bool DC_BasicDatabase::isObjectConfigured void   )  [virtual]
 

Perform a class-specific configuration check on a basic database object: verify that the default and operational tables have been loaded, that method reset has been called, and that the table length is greater than zero.

See also:
reset
Returns:
true if the database object is configured, false otherwise

Reimplemented from CC_RootObject.

Definition at line 52 of file DC_BasicDatabase.cpp.

void DC_BasicDatabase::setDefaultTable char *  pDefTable  ) 
 

Load the default table.

This method assumes that the default table has been defined and initialized by the caller. The method does not perform any action on the table. It simply loads its address and will use it for accessing the table entries.

This is an initialization method.

Parameters:
pDefTable the starting address of the default table

Definition at line 42 of file DC_BasicDatabase.cpp.

void DC_BasicDatabase::setOperationalTable char *  pOperTable  ) 
 

Load the operational table.

This method assumes that the operational table has been defined and initialized by the caller. The method does not perform any action on the table. It simply loads its address and will use it for accessing the table entries.

This is an initialization method.

Parameters:
pOperTable the starting address of the default table

Definition at line 47 of file DC_BasicDatabase.cpp.

void DC_BasicDatabase::setParameter TD_DatabaseId  parId,
double  newValue
[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

Implements ParameterDatabase.

Definition at line 99 of file DC_BasicDatabase.cpp.

void DC_BasicDatabase::setParameter TD_DatabaseId  parId,
float  newValue
[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

Implements ParameterDatabase.

Definition at line 94 of file DC_BasicDatabase.cpp.

void DC_BasicDatabase::setParameter TD_DatabaseId  parId,
unsigned char  newValue
[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

Implements ParameterDatabase.

Definition at line 89 of file DC_BasicDatabase.cpp.

void DC_BasicDatabase::setParameter TD_DatabaseId  parId,
char  newValue
[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

Implements ParameterDatabase.

Definition at line 84 of file DC_BasicDatabase.cpp.

void DC_BasicDatabase::setParameter TD_DatabaseId  parId,
bool  newValue
[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

Implements ParameterDatabase.

Definition at line 79 of file DC_BasicDatabase.cpp.

void DC_BasicDatabase::setParameter TD_DatabaseId  parId,
short  newValue
[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

Implements ParameterDatabase.

Definition at line 74 of file DC_BasicDatabase.cpp.

void DC_BasicDatabase::setParameter TD_DatabaseId  parId,
unsigned short  newValue
[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

Implements ParameterDatabase.

Definition at line 69 of file DC_BasicDatabase.cpp.

void DC_BasicDatabase::setParameter TD_DatabaseId  parId,
int  newValue
[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

Implements ParameterDatabase.

Definition at line 64 of file DC_BasicDatabase.cpp.

void DC_BasicDatabase::setParameter TD_DatabaseId  parId,
unsigned int  newValue
[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

Implements ParameterDatabase.

Definition at line 59 of file DC_BasicDatabase.cpp.

void DC_BasicDatabase::setTableLength TD_DatabaseId  length  ) 
 

Set the length of the default and operational table in number of bytes.

Only non-negative values of the length are legal.

This is an initialization method.

Parameters:
length the number of char elements in the default and in the operational table

Definition at line 33 of file DC_BasicDatabase.cpp.


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