Get only one object of a class?
Martin Klaffenboeck <[email protected]> Sat, 29 Oct 2005 22:09:43 +0200
| Newsgroups | gmane.comp.gnome.devtools.gob.general |
|---|---|
| Message-ID | <1130616584.12108.9.camel@localhost> |
--=-1WscU82MR7N6ivDGZKwn
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable
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 {
public=20
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,
Martin
--=-1WscU82MR7N6ivDGZKwn
Content-Type: application/pgp-signature; name=signature.asc
Content-Description: Dies ist ein digital signierter Nachrichtenteil
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
iD8DBQBDY9cHX9Pgnt9mM0MRAhZRAJ44TOiL/MZEv62t04k51WltYF/7YwCfS2Vu
1omYZ1mYQE/bIIKvfCo6JBU=
=81OS
-----END PGP SIGNATURE-----
--=-1WscU82MR7N6ivDGZKwn--
--
to unsubscribe:
send mail to [email protected] with "unsubscribe gob-list" in the subject