[aspectc-user] Aspect C++ question:how to control the output methods?

Krishna Murali-A19032 murali.krishna at motorola.com
Tue Oct 14 15:15:34 CEST 2003


I think you can't track main() in a similar fashion. 

S. Murali Krishna 
Software Technology Group (SofTec) 
Mission Statement : To be the BEST in ALL the roles that I play. 

[Leadership means there is no substitute for excellence, no tolerance of mediocrity and no compromise with integrity.] - Rahul Bajaj



> -----Original Message-----
> From: Michael, G. [mailto:g.michael at TUE.nl]
> Sent: Tuesday, October 14, 2003 6:04 PM
> To: aspectc-user at aspectc.org
> Subject: [aspectc-user] Aspect C++ question:how to control the output
> methods?
> 
> 
> 
> Dear Sir,
> 
> I am doing a project using the AspectC++ system.
> Curently, I am trying to define an aspect that prints the 
> name of the method on the screen at the start and exit of a method.
> Below I include an example of the advice that I have tried.
> However, it yields output only after one of the methods 
> called in my program.
> 
> I seem to remember that there is an example program (maybe in 
> one of the papers on AspectC++) that illustrates this type of 
> functionality.
> 
> Could you please send this example to me and/or tell me how 
> to code such an aspect?
> Kind regards,
> 
> 
>   Gati Michael.
> 
> ---------
> The aspect code looks like this:
> 	#ifndef __mytest_h__
> 	#define __mytest_h__
> 	#include <stdio.h>
> 	aspect mytest {
> 
> 	advice execution((" void %::%()"))&&: before()  
> 	{ printf(" Function ... has been found\n");
> 	    }
> 	advice execution((" void %::%()"))&&: after()  
> 	{printf(" Function ... has been exit\n");
> 	    }
> 	};
> 	#endif // __mytest_h__
> 
> The program code looks like this:
> #include <stdio.h>
> #include <stdlib.h>
> class PBase
>  {
>    public:
>       void abar(int, int) {
>         printf("PBase::abar()\n");
>          cbar(2,5);  }
> 
> void cbar(int, int) {
>         printf("PBase::cbar()\n");
>       }
>  };
> 
> class Test : public PBase {
>   public:
>     void foo() {
>       	printf("Test::foo()\n");
> 	abar(1,2);
> }   void abar(int, int) {
>    printf("Test::abar()\n");
>     }
>     void bbar(int, int) {
>         printf("Test::bbar()\n");}
> };
> class subTest : public Test
>  {
>     void abar(int, int) {
>         printf("subTest::abar()\n");
>     }
>  };
> 
> int main()
>  {
>    subTest test;
>   test.foo();
>   PBase od;
>  od.abar (3, 4);
>  PBase nr;  
>  nr.cbar(4,6);
>   return 0;
>  }
> 
> Here  is the result:
> 
> Function ... has been found
> Test::foo()
> Test::abar()
> Function... has been exit
> PBase::abar()
> PBase::cbar()
> PBase::cbar()
> 
> How can I control the  results such that I get all five 
> prints after each method?
> 
> 
> 
> 
> 
> _______________________________________________
> aspectc-user mailing list
> aspectc-user at aspectc.org
> http://www.aspectc.org/mailman/listinfo/aspectc-user
> 



More information about the aspectc-user mailing list