<
aspect xmlns:cpp="
http://www.sdml.info/srcML/cpp"
xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsl="
http://www.w3.org/1999/XSL/Transform"
xmlns="
http://control.ee.ethz.ch/XWeaver/AspectX"
xmlns:src="
http://www.sdml.info/srcML/src"
xsi:schemaLocation="
http://control.ee.ethz.ch/XWeaver/AspectX ../../../../src/xsd/aspectX.xsd"
name="
GetParameter">
<
description>
Inserts function calls that replaces member variables where the value of the variable is not updated.
One of fours sample aspect programs that modifies the component to access all its parameters from
a <
i>
parameter database</
i>
.
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 <
a href="
http://www.pnp-software.com/ObsFramework/doc/ParameterDatabase.html">
Parameter
Database Design Pattern</
a>
).
<
p />
The
<
a href="
http://www.pnp-software.com/ObsFramework/doc/doxygen/html/classDC__BasicDatabase.html">
<
code>
DC_BasicDatabase</
code></
a>
is used as a component that stores the parameter data of target class.
The <
code>
DC_BasicDatabase</
code>
class extends the abstract class
<
a href="
http://www.pnp-software.com/ObsFramework/doc/doxygen/html/classParameterDatabase.html">
<
code>
ParameterDatabase</
code></
a>
.
Both classes are defined and implemented in
<
a href="
http://www.pnp-software.com/ObsFramework/">
OBS Framework</
a>
.
<
p />
These aspect programs replace all three member variables in class <
code>
SampleClass</
code>
by respective method calls <
code>
setParameter()</
code>
and <
code>
getParameterXXX()</
code>
of class
<
code>
DC_BasicDatabase</
code>
. String <
code>
XXX</
code>
stands for data type of member variable being replaced.
In this example it is assumed that member variable names starts with underline (<
code>
_ </
code>
)
character.
For each member variable there is as <
i>
parameter identifier</
i>
woven in the base code.
Parameter identifier is a constant in the form <
code>
PDxxx</
code>
where
"xxx" is member variable name in upper case. Parameter identifiers are used
to uniquely identify the parameters stored in the parameter database.
Methods <
code>
getParameterXXX()</
code>
takes the <
i>
parameter identifiers</
i>
as their parameters.
Methods <
code>
setParameter()</
code>
have two parameters. The first one is
the <
i>
parameter identifier</
i>
, the second one is the new value of the parameter
that is to be stored in the database.
<
p />
<
i>
This aspect</
i>
contains two advices. They replace member
variables with <
code>
pDB->getParameterInt()</
code>
or <
code>
pDB->getParameterInt()</
code>
method calls.
This aspect program uses pointcuts defined in file <
code>
PointcutLibrary.xml</
code>
.
<
author>
A. Pasetti, O. Rohlik</
author>
<
see>
PointcutLibrary</
see>
<
see>
BaseParameter</
see>
<
see>
SetParameter</
see>
</
description>
<
include href="
PointcutLibrary.ax" />
<
pointcut name="
targetIntNameGetter"
type="
src:name" />
<
pointcut name="
targetFloatNameGetter"
type="
src:name" />
<
advice name="
targetIntNameGetter"
type="
replace">
<
description>
Replace <
i>
integer</
i>
member variable with the <
code>
pDB->getParameterInt()</
code>
method call.
Only those member variable occurrences are replaced where the value of the variable <
i>
is not</
i>
changed. Other cases, where the value <
i>
is</
i>
changed, are covered by advice
<
code>
targetIntExprSetter</
code>
.
<
p />
For example member variable <
code>
_width</
code>
is replaced with
<
code>
pDB->getParameterInt(DB_WIDTH)</
code>
where the substring
<
code>
_WIDTH</
code>
is automatically generated from the
variable name.
</
description>
<
pointcutRef ref="
targetIntNameGetter"
aspect="
PointcutLibrary"
type="
src:name" />
<
codeModifier type="
codeFragment">
<
xsl>
pDB->getParameterInt(PD<
xsl:
value-of select="
upper-case(current())" />
)</
xsl>
</
codeModifier>
</
advice>
<
advice name="
targetFloatNameGetter"
type="
replace">
<
description>
Replace <
i>
float</
i>
member variable with the <
code>
pDB->getParameterFloat()</
code>
method call.
Only those member variable occurrences are replaced where the value of the variable <
i>
is not</
i>
changed. Other cases, where the value <
i>
is</
i>
changed, are covered by advice
<
code>
targetFloatExprSetter</
code>
.
<
p />
For example member variable <
code>
_flt</
code>
is replaced with
<
code>
pDB->getParameterFloat(DB_FLT)</
code>
where the substring
<
code>
_FLT</
code>
is automatically generated from the
variable name.
</
description>
<
pointcutRef ref="
targetFloatNameGetter"
aspect="
PointcutLibrary"
type="
src:name" />
<
codeModifier type="
codeFragment">
<
xsl>
pDB->getParameterFloat(PD<
xsl:
value-of select="
upper-case(current())" />
)</
xsl>
</
codeModifier>
</
advice>
</
aspect>
v