[aspectc-user] if(...) in pointcut-expressions

Fabian Scheler fabian.scheler at gmail.com
Thu Jun 23 13:17:24 CEST 2005


Hi,

> This is how I implement it now. I probably should have told also that
> the pointcut and the manipulation of the flag are located in an abstract
> aspect. Thus, the 'user' of the subaspect shouldn't be bothered with
> adding this manually.

ok, maybe a virtual function helps you:

aspect AbstractAspect {
  bool flag;

  pointcut virtual method() = 0;
 
  virtual void myAdviceMethod() = 0;

  advice execution(method()) : after() {
    if(flag) {
      myAdviceMethod();
    }
  }

  advice ... : after() {
    // manipulate flag
  }
};

aspect ConcreteAspect : public AbstractAspect {
  pointcut methods() = "% %::%(...)";
  void myAdviceMethod() {
    // do some stuff here
  }
};

Ciao, Fabian




More information about the aspectc-user mailing list