[aspectc-user] reset tjp->that()?
    Daniel Lohmann 
    daniel.lohmann at informatik.uni-erlangen.de
       
    Mon Dec 11 09:23:28 CET 2006
    
    
  
Michael Gong schrieb:
> Hi, Daniel & Yan,
> 
> It brings an interesting question.
> 
> The template works fine for this case.
> 
>> I am afraid what you are trying to achieve is not possible.
>> // Template, works for any class that offers a Release() method
>> template< class T > void Release( T*& _this ) {
>> _this->Release(); // destroy
>> _this = 0; // invalidate
>> }
>>
> 
> But how about I want to do the "invalidation" for method "Release2" ,
> "Release3", or etc ? Using template, you might have :
> 
> template< class T > void Release2( T*& _this ) {
> _this->Release2(); // destroy
> _this = 0; // invalidate
> }
> 
> template< class T > void Release3( T*& _this ) {
> _this->Release3(); // destroy
> _this = 0; // invalidate
> }
> 
> ...
>
> It is typical crosscutting concern, I think.
You mean the pointer invalidation? I guess one could say so.
> Since AOP is targeted to modularize crosscutting concern, can it be used
> for this case ? More specifically, can AspectC++ capture it ?
The AspectC++ *language* is able to express this:
aspect Invalidator {
  advice execution("void Release%<...>(%)") : after() {
	*tjp->arg<0>() = 0;
  }
};
The ac++ *weaver*, however, is currently not able to weave this, as
support for weaving in template code is yet to come.
Daniel
    
    
More information about the aspectc-user
mailing list