[aspectc-user] Singleton pattern

Panu Bloigu panu.bloigu at mbnet.fi
Wed Jan 10 09:33:25 CET 2007


Hello.

>        advice singletonize():
>                public: static That *Instance() {

First off, the introduction syntax you are using is deprecated. I think you
should write that like this instead:

advice singletonize(): slice class
{
// What ever code you want to introduce to the target class.
};

Secondly, the type That is a member of class JoinPoint, so you should use
JoinPoint::That to access it. However, the class JoinPoint doesn't seem to
be visible inside of an introduction advice, or atleast this is what I
observed after a quick testing. I would too like to know how one can access
the type of the surrounding class/struct from inside of an introduction
advice. Maybe other people on the list will help on this.

> private: static int _count; /** Second problem: how
> initialize an
> introduced static
> member */> protected:

I find this as an interesting quiestion. Because you can't initialize a
static data member inside of the class, you can't also use *any* advice type
to do that. I would like to know the answer to this too.


Panu.





More information about the aspectc-user mailing list