../../AspectXLib/ParameterDatabase/ParameterDatabase/aspects/Pointer.axDC_BasicDatabase
is used as a component that stores the parameter data of the target class.
The DC_BasicDatabase class extends the abstract class
ParameterDatabase.
Both classes are defined and implemented in
OBS Framework.
This aspect program replaces all member variables in class SampleClass
by the respective pointers to the the instance of class
DC_BasicDatabase. 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 getParameterPointerXXX() defined in ParameterDatabase class
take the parameter identifiers as their parameters.
The "XXX" stands for parameter type.
This aspect contains advice that
replaces the occurences of member variables in class SampleClass by
pointers that points to the parameter database. Other advices add parameter database variable declaration
and initialization code to the base code. Yet another advice adds necessary #include
preprocessor directives.
This aspect program uses pointcuts defined in file PointcutLibrary.xml. It also
defines two additional pointcuts targetParameterUsage and
targetParameterDeclaration.
(PointcutLibrary.ax)Pointcuts | |
| unit | targetClassDeclaration |
| expr | anySampleClassExpr |
| class | targetClass |
| name | targetParameterUsage |
|
Points to occurrences of member variables used in expression within methods, constructors
and destructors of the target class | |
| name | targetParameterDeclaration |
|
Points to declarations of member variables of the target class | |
Advices | |
| add | addConstants |
|
Add constants to the class declaration | |
| add | addIncludesToDeclaration |
|
Add the #include preprocessor instructions | |
| add | addDatabaseReference |
|
Add declaration of pointer to parameter database to target class | |
| begin | targetFloatVarInitialization |
|
Initialize float* pointers to the parameter database
by value returned by the method pDB->getParameterPointerFloat(PDxxx)
where "xxx" is member variable name in upper case | |
| begin | targetIntVarInitialization |
|
Initialize int* pointers to the parameter database
by value returned by the method pDB->getParameterPointerInt(PDxxx)
where "xxx" is member variable name in upper case | |
| begin | addDatabaseInicialization |
|
Add code fragment that initialize the parameter database | |
| replace | replaceParametersByPointers |
|
Replace occurences of member variables with the dereferences of pointers
to the parameter database | |
| replace | replaceParameterDeclarationsByPointers |
|
Replace declarations of member variables with the declarations of pointers
to the parameter database | |
_ ).
_ ) but does not appear
in the methods, constructors or destructors of the target class.
Triplet: unit add declaration
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)
Triplet: unit add include
#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)
Triplet: class add declaration
DC_BasicDatabase* and is named pDB. It is declared as private.
Refers to global pointcut: class targetClass (PointcutLibrary)
Triplet: constructor begin codeFragment
float* pointers to the parameter database
by value returned by the method pDB->getParameterPointerFloat(PDxxx)
where "xxx" is member variable name in upper case. Note that the parameter of the method
represents the parameter identifier used
to uniquely identify the parameters stored in the parameter database.
For example member variable _flt is initialized to value
returned by the method call
pDB->getParameterPointerFloat(DB_FLT) where the substring
_FLT is automatically generated from the variable name.
It is important to initialize all pointers to the parameter database
defined in the target class. This advice initializes all pointers of type
float*. All float* pointers are accessed using
two construtcs of the XSL language: xsl:for-each and
xsl:value-of. Variable filename defined in the code modifier
contains the name of the current unit (without extension).
The filename is later used to define the path
to the file where the target class is defined. The set of all float member
variable names defined in the target class can be then obtained using (relatively
complicated) XPath expression with doc() function of XSL language:
doc($path)//src:class[src:name=$filename]//src:decl_stmt/src:decl[src:type/src:name='float']/src:name.
Local Pointcut: constructor (source)
Triplet: constructor begin codeFragment
int* pointers to the parameter database
by value returned by the method pDB->getParameterPointerInt(PDxxx)
where "xxx" is member variable name in upper case. Note that the parameter of the method
represents the parameter identifier used
to uniquely identify the parameters stored in the parameter database.
For example member variable _width is initialized to value
returned by the method call
pDB->getParameterPointerInt(DB_WIDTH) where the substring
_WIDTH is automatically generated from the variable name.
It is important to initialize all pointers to the parameter database
defined in the target class. This advice initializes all pointers of type
int*. All int* pointers are accessed using
two construtcs of the XSL language: xsl:for-each and
xsl:value-of. Variable filename defined in the code modifier
contains the name of the current unit (without extension).
The filename is later used to define the path
to the file where the target class is defined. The set of all integer member
variable names defined in the target class can be then obtained using (relatively
complicated) XPath expression with doc() function of XSL language:
doc($path)//src:class[src:name=$filename]//src:decl_stmt/src:decl[src:type/src:name='int']/src:name.
Local Pointcut: constructor (source)
Triplet: constructor begin codeFragment
pDB)Local Pointcut: constructor (source)
Triplet: name replace codeFragment
(*_pXXX) where XXX stands for the name of the variable being replaced.
For example member variable _width is replaced with
(*_p_width).
Refers to global pointcut: name targetParameterUsage
Triplet: name replace codeFragment
*_pXXX where XXX stands for the name of the variable being replaced.
For example the declaration of member variable _width is replaced with
the declaration of *_p_width.
Refers to global pointcut: name targetParameterDeclaration