Get only one object of a class?

From: Martin Klaffenboeck <>
Date: Sat, 29 Oct 2005 22:09:43 +0200

Hi there!

Is it possible to get only one object of a class while running my app?

I now use (only the basics pasted:

class Gnotex:Support from G:Object {
        GnotexSupport *
        new (void) {
                return (GnotexSupport *) GET_NEW;

Now I want to have if someone calls gnotex_support_new more than once,
that the second time I get a pointer to the first instance of my object.

I want to do this, because it is only a class which handles many other
things, and it needs a very long time to initialize (parsing many files,
like some apps load their plugins).

Can I simply add a static variable inside the new function which is set
to null the first time and gets set to the GnotexSupport pointer
afterwards and if it is not null to return the so stored pointer?

Or is that not possible in that context?

Thanks for your ideas,

Received on Sat Oct 29 2005 - 20:08:21 CDT

This archive was generated by hypermail 2.2.0 : Sun Apr 17 2011 - 21:05:02 CDT