[aspectc-user] Joinpoint Context information when monitoring class instances

Bill Sousan blsousan at yahoo.com
Mon Sep 25 03:29:19 CEST 2006


Hi,

    I am trying to make a "canned" aspect for tracking
the number instances for a given class.  However, I
would like this canned aspect to work on a group of
classes thus it needs specific context information per
aspect instanciation.  Basically just a counter for
tracking the number of instances.

I copied some code from one of your research papers
and it seems to work.  My problem is that I also want
to printout which class it is presently called from.
(i.e. the joinpoint class)  I used the following code:



aspect Instances 
{
    pointcut virtual pClasses () = 0;
    advice pClasses () :
        class Counter 
    {
        static int counter;
        public:
            Counter () 
            {
                counter++;
		// Want to print out which class this joinpoint is
attached to		
                printf( "CONST %s Instance Count:
%d\n" , JoinPoint::signature( ) , counter ) ;
            }
            ~Counter ()
            {
                counter--;
		// Want to print out which class this joinpoint is
attached to	
                printf( "DEST %s Instance Count: %d\n"
, JoinPoint::signature( ) , counter ) ;
            }
    } __counter;
};


advice Instances::pClasses () :
    int Instances::Counter::counter = 0;

aspect MonitorAllInstances : public Instances 
{
    pointcut pClasses () = classes ("%"); // Want to
track all classes
};



>>> However, I get the following errors when I compile
it after running AC:  

examples/Action/Action.ah: In constructor
`CB2::Counter::Counter()':
examples/Action/Action.ah:385: error: `JoinPoint' has
not been declared
examples/Action/Action.ah:385: error: `signature'
undeclared (first use this function)
examples/Action/Action.ah:385: error: (Each undeclared
identifier is reported only once for each function it
appears in.)
examples/Action/Action.ah: In destructor
`CB2::Counter::~Counter()':
examples/Action/Action.ah:390: error: `JoinPoint' has
not been declared
examples/Action/Action.ah:390: error: `signature'
undeclared (first use this function)
examples/Action/Action.ah: In constructor
`Cbclass::Counter::Counter()':
examples/Action/Action.ah:385: error: `JoinPoint' has
not been declared
examples/Action/Action.ah:385: error: `signature'
undeclared (first use this function)
examples/Action/Action.ah: In destructor
`Cbclass::Counter::~Counter()':
examples/Action/Action.ah:390: error: `JoinPoint' has
not been declared
examples/Action/Action.ah:390: error: `signature'
undeclared (first use this function)
make: *** [action] Error 1


>>> I have two classes as you can tell, which are CB2
and Cbclass.

I can't seem to figure out how to get it to accept the
JoinPoint and signature() ?


Thanks,
Bill

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



More information about the aspectc-user mailing list