CarPreCondition Aspect
[CarExample Group]

This aspect is defined in file: ../../AspectXLib/car/Car/aspects/CarPre.ax

Aspect Description

The base code does not perform any range checks on the values of parameters being passed to methods (for instance, there is no check that object pointers are not NULL). We want to modify this base code to do two things:
  1. to perform validity checks on the parameters passed to a method
  2. to execute a recovery action in case the parameters are found to be invalid.
A "recovery action" in our context is an instance of a class derived from class RecoveryAction. The recovery action should be a plug-in component for the class where the parameter valildity check is performed.
Author:
I. Birrer, O. Rohlik
See also:
CarBeginEnd
CarPostCondition
CarSynchronizeWindows

Pointcuts

functioncheckedMethods
  Points to all methods which ranges should be checked
classcheckedMethodsClasses
  Points to all classes that have methods which ranges should be checked

Advices

addaddRecoverySupportMethodDeclaration
 Adds a method setRecoveryAction() to the classes that supports recovery
addaddRecoverySupportFieldDeclaration
 Adds a declaration of field variable recoveryAction to classes that support recovery
addaddRecoverySupportDefinition
 Adds definition of method setRecoveryAction() to units (files) that contain definition of class that that have methods which ranges should be checked
begincheckedMethods
 Adds code that validates the precondition
addaddIncludeDecl
 Adds #include "RecoveryAction
addaddIncludeDef
 Adds #include "RecoveryAction

Pointcut Documentation

function checkedMethods (source)
Points to all methods which ranges should be checked. These methods are setPower and setLoadLevel.
class checkedMethodsClasses (source)
Points to all classes that have methods which ranges should be checked. These classes are Engine and Battery.

Advice Documentation

add addRecoverySupportMethodDeclaration (source)

Triplet: class add declaration

Adds a method setRecoveryAction() to the classes that supports recovery.

Refers to global pointcut: class checkedMethodsClasses

add addRecoverySupportFieldDeclaration (source)

Triplet: class add declaration

Adds a declaration of field variable recoveryAction to classes that support recovery.

Refers to global pointcut: class checkedMethodsClasses

add addRecoverySupportDefinition (source)

Triplet: unit add definition

Adds definition of method setRecoveryAction() to units (files) that contain definition of class that that have methods which ranges should be checked.

Local Pointcut: unit (source)

begin checkedMethods (source)

Triplet: function begin codeFragment

Adds code that validates the precondition. It checks the value of the first parameter. It it is less than 10 the recovery action is performed.

Refers to global pointcut: function checkedMethods

add addIncludeDecl (source)

Triplet: unit add include

Adds #include "RecoveryAction.h" to all units where classes with functions returning pointers are defined.

Local Pointcut: unit (source)

add addIncludeDef (source)

Triplet: unit add include

Adds #include "RecoveryAction.h" to all units where functions returning pointer are defined.

Local Pointcut: unit (source)