../../AspectXLib/ParameterDatabase/ParameterDatabase/aspects/SetParameter.ax
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 two advices. They replace member
variables with pDB->setParameter()
method call.
This aspect program uses pointcuts defined in file PointcutLibrary.xml
.
(PointcutLibrary.ax)
Pointcuts | |
expr | targetIntExprSetter |
expr | targetFloatExprSetter |
Advices | |
replace | targetIntExprSetter |
Replace integer member variable with the pDB->setParameter() method call | |
replace | targetFloatExprSetter |
Replace float member variable with the pDB->setParameter() method call |
Triplet: expr replace codeFragment
pDB->setParameter()
method call.
Only those member variable occurrences are replaced where the value of the variable is
changed. Other cases, where the value is not changed, are covered by advice
targetIntNameGetter
.
For example consider the assignment to member variable _width
. The expression
_width = 2 * iRadius
is replaced by
pDB->setParameter(PD_WIDTH, 2 * iRadius);
. The substring
_WIDTH
is automatically generated from the
variable name. The second parameter (i.e. 2 * iRadius
)
is extracted from expr
srcML element as substring after the equal sign
(=
).
This advice assumes that assignments are not used in conditions
(e.g. if (foo = 1) foo = 0;
) since the
setParameter()
method does not have any return value.
Refers to global pointcut: expr targetIntExprSetter (PointcutLibrary)
Triplet: expr replace codeFragment
pDB->setParameter()
method call.
Only those member variable occurrences are replaced where the value of the variable is
changed. Other cases, where the value is not changed, are covered by advice
targetFloatNameGetter
.
For example consider the assignment to member variable _flt
. The expression
_flt = 3.14f * fRadius
is replaced by
pDB->setParameter(PD_FLT, 3.14f * fRadius);
. The substring
_FLT
is automatically generated from the
variable name. The second parameter (i.e. 3.14f * fRadius
)
is extracted from expr
srcML element as substring after the equal sign
(=
).
This advice assumes that assignments are not used in conditions
(e.g. if (foo = 1.0) foo = 0.0f;
) since the
setParameter()
method does not have any return value.
Refers to global pointcut: expr targetFloatExprSetter (PointcutLibrary)