Boost logo

Boost :

From: Yakov Bachmutsky (yakov_at_[hidden])
Date: 2002-11-20 06:42:47


Hi,

I've posted a proposal of a singleton library (among others) maybe a month
ago and as far as I remember it was ignored so I post it again with its name
as the subject, hoping this will help, and some explanations:

1. I use singleton<class T> to have a singleton instance of a class in my
apps.
The obvious advantage in developement of large apps is that u don't have to
remember the name of the 1 instance u create like g_myObj but only the
class's name and thus always use it like this:
  singleton<myclass> p->method();

2. In addition I use a singleton manager to have all singleton objects
started at app start:
  singleton_manager::startup()

3. to use that I "register" classes to use the singleton class and manager
class using a macro:
  REGISTER_SINGLETON(myclass)

4. classes can inherit the singleton class to get more specific behaviour
like two stage construction.
Every such inhariting class must have its own registration macro.

5. In addition to all the above I suggest few more little thingies to
support other singleton patterns, mostly in the form of macroes. There's
also an article on this topic:
http://www.beginthread.com/Article/yakov/Singleton Techniques/

Any interest ?
Yakov



Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk