BaseParameter Aspect
[ParameterDatabase Group]

This aspect is defined in file: ../../AspectXLib/ParameterDatabase/ParameterDatabase/aspects/BaseParameter.ax

Aspect Description

Inserts code that initializes the parameter database. One of fours sample aspect programs that modifies the component to access all its parameters from a parameter database. This group of aspect programs show an example of how the implementation of selected classes in a certain code base can be modified to change the way in which member variables are handled. In this example, all member variables in the base code are moved to a dedicated object called parameter database (see Parameter Database Design Pattern).

The DC_BasicDatabase is used as a component that stores the parameter data of target class. The DC_BasicDatabase class extends the abstract class ParameterDatabase. Both classes are defined and implemented in OBS Framework.

These aspect programs replace all three member variables in class SampleClass by respective method calls setParameter() and getParameterXXX() of class DC_BasicDatabase. String XXX stands for data type of member variable being replaced. In this example it is assumed that member variable names starts with underline ( _ ) character. For each member variable there is as parameter identifier woven in the base code. Parameter identifier is a constant in the form PDxxx where "xxx" is member variable name in upper case. Parameter identifiers are used to uniquely identify the parameters stored in the parameter database. Methods getParameterXXX() takes the parameter identifiers as their parameters. Methods setParameter() have two parameters. The first one is the parameter identifier, the second one is the new value of the parameter that is to be stored in the database.

This aspect contains advices that adds parameter database variable declaration and initialization code to the base code. It also adds necessary #include preprocessor directives. This aspect program uses pointcuts defined in file PointcutLibrary.xml.
Author:
A. Pasetti, O. Rohlik
See also:
PointcutLibrary
GetParameter
SetParameter
Includes:
PointcutLibrary(PointcutLibrary.ax)

Pointcuts

unittargetClassDeclaration
 
classtargetClass
 

Advices

addaddConstants
  Add constants to the class declaration
addaddIncludesToDeclaration
  Add the #include preprocessor instructions
addaddDatabaseReference
  Add declaration of pointer to parameter database to target class
beginaddDatabaseInicialization
  Add code fragment that initialize the parameter database

Pointcut Documentation

unit targetClassDeclaration (source)
class targetClass (source)

Advice Documentation

add addConstants (source)

Triplet: unit add declaration

Add constants to the class declaration. Constants represent the parameter identifiers of all the entries in parameter database that are used in the target class. The name of every constant is derived from the member variable name and is constructed as PDxxx where "xxx" is member variable name in upper case. For example constant PD_WIDTH is the parameter identifier of the member variable _width.

Refers to global pointcut: unit targetClassDeclaration (PointcutLibrary)

add addIncludesToDeclaration (source)

Triplet: unit add include

Add the #include preprocessor instructions. Declaration of class TD_DatabaseId is needed in order to define parameter identifiers, this data type is defined in header file GeneralInclude/BasicTypes.h. The pointer to parameter database has to be defined in the class definition. Therefore the header file Data/DC_BasicDatabase.h has to be included as well.

Refers to global pointcut: unit targetClassDeclaration (PointcutLibrary)

add addDatabaseReference (source)

Triplet: class add declaration

Add declaration of pointer to parameter database to target class. The pointer is of type DC_BasicDatabase* and is named pDB. It is declared as private.

Refers to global pointcut: class targetClass (PointcutLibrary)

begin addDatabaseInicialization (source)

Triplet: constructor begin codeFragment

Add code fragment that initialize the parameter database. The database has to be initialized before it is first used. The initialization code is discussed in documentation of the TestCaseBasicDatabase_1 class (a part of the OBS Framework). Purpose of the initialization is to:
  1. initialize the data structure to simulate the default table
  2. initialize the data structure to simulate the operational table
  3. instantiate the basic database object (pDB)
  4. set the parameter database length
  5. set the default and operational tables of the parameter database
  6. reset the database

Local Pointcut: constructor (source)