[aspectc-user] FW: QUESTION ABT HOW DO WRITE NAME SPACE ADVICES

Olaf Spinczyk Olaf.Spinczyk at informatik.uni-erlangen.de
Wed Oct 22 09:47:00 CEST 2003


Hello,

Anil Krishna wrote:
> Hi,
> 
> I am trying to use AC++ for some test programs and I am having problem 
> writing
> 
> the following advice.
> 
> Consider the following program : (please ignore the syntax)
> 
> Class A {
>     Public:
>          Int var;
>          Void display();
> };
> 
> void A::display()
> {
> cout << " var : " << var << endl;
> }
> 
> int main()
> {
>   A a;
> a.var = 10;  // this is my point cut .
> a.display();
>     return 0;
> }
> 
> In the above program, within an aspect I am trying to write an advice 
> which prints out the signature of the join point.
> 
> I know I am bad in using this new aspect terminology.
> 
> In lay man words, in the main function after "a.var = 10'" or on any 
> access to A::var , I would like an advice to be executed
> 
> Which prints some value retrieved from the JoinPoint.
> 
> Please could you give me as what is the syntax of this advice. (esp for 
> name point cuts)

The 'set' and 'get' pointcut functions are intended to be used for this 
kind of crosscutting. However, even though already documented in the 
language reference manual, set and get are not implemented by the 
compiler, yet.

This question is asked quite frequently. We will increase the priority 
of this task to provide set and get as soon as possible.

> I could not clearly understand the use of Introductions from the document.

Just in a few words: Introductions can be used to insert attributes or 
member functions into sets of classes. For example:

aspect Introducer {
public:
   pointcut theExtendedClasses () = "ClassA"||"ClassB"||derived("XY");
   advice theExtendedClasses () : int anAttribute;
   advice theExtendedClasses () : void aMemberFunction () { /* ... */ }
};

Yours,

Olaf




More information about the aspectc-user mailing list