[aspectc-user] AspectC++ and singletons?
daniel.lohmann at informatik.uni-erlangen.de
Thu Nov 22 09:48:30 CET 2007
Olaf Spinczyk schrieb:
> Hi Mike,
> at the moment AspectC++ does not support the interception of
> constructor calls on the client side. The 'construction' advice is
> something like 'execution' advice for the constructor. When the
> constructor is executed, the memory for the object has already been
> allocated. Therefore, this language feature doesn't help you.
Just an idea: Memory allocation on the heap could be influenced by
introducing a class-level operator new into the class that always
returns the address of the one-and-only singleton. However, after an
allocation the constructor is executed anyway. This means that we had a
situation where an object is constructed multiple times at the same
memory location. It might be possible to catch this situation in the
constructor body, the the constructors of base classes and class-type
member variables have already been executed by this time.
Another thing is that all this does not help for static or automatic
instantiations of the class, as operator new is not involved in these cases.
More information about the aspectc-user