0

This may be a dumb question, but I couldn't find the answer after searching for hours.

Using AspectC++, we can define pointcuts, which represent something that, once matched, is intercepted. For instance, I can do

pointcut pc() = call("% Base::%(...)");

so that any advice that uses the pointcut pc will intercept any call to some method of class Base. This works even if, later, a subclass Sub of Base is created: pc will intercept calls to methods of Sub as well. Now, what I want is to intercept methods only of Sub, that is, methods of Sub which are not present in Base. How can we make pc() intercept any method of any subclass of Base that is eventually created, but not methods of Base itself?

Eduardo Bezerra
  • 1,923
  • 1
  • 17
  • 32
  • Why do you need to make that distinction? Public base class methods are normally treated as functionally equal to the derived class methods. There is no practical difference, in other words. Can you make the base class members `protected`? – Robert Harvey Mar 04 '13 at 17:35
  • Because I do not want methods of the base class to be intercepted, but only those that are eventually added by the developer in their subclass. Is that possible? – Eduardo Bezerra Mar 04 '13 at 17:36
  • OK, but how do you get around the problem that (by virtue of inheritance) public base class methods are functionally identical to derived class methods? How do you tell them apart? – Robert Harvey Mar 04 '13 at 17:38
  • Good point, so I just tested now and, using aspectc++, I could simply define the pointcut as `call("% Sub::%(...)")` and somehow it tells inherited methods apart from non-inherited ones. The question is: how to make that work for any subclass? – Eduardo Bezerra Mar 04 '13 at 17:43

0 Answers0