Wouldn't it be more appropriate to describe Ogre's Singleton implementation? It differs significantly. tanis 04:39, 11 Jan 2005 (MST)

That would be a good idea, I have no information on that unfortunately so someone else would have to do it (in the wiki spirit
) ) bana 19:32, 11 Jan 2005 (MST)
I've added a section about it. tanis 23
06, 11 Jan 2005 (MST)

The assert fails because sm_Singleton is still 0;

Should it be like this or is there a better solution?

  MyManager* MyManager::getSingletonPtr(void)
    if( !ms_Singleton )
      ms_Singleton = new MyManager();
    return ms_Singleton;

No, not better, just different. As I wrote in the article: Ogre's approach wants to make the construction explicit. Two main advantages. First it allows to use constructors with arguments. Second it coerces you to think about when and where it is initialized. Without explicit construction you sooner or later don't know anymore which singleton is initialized when. tanis 22:41, 16 Mar 2005 (CET)

There's also another problem with "normal" singleton implementations. The order of initialization for the singletons can't be properly controlled (it is undefined), and the singletons can't be dynamically created / destroyed / recreated. The implementation Ogre uses is taken from Game Programming Gems I, and is originally written by Scott Bilas (think so at least). This implemtation is used in other places as well, an example being Gabber. Mangetsu 16:00, 8 November 2005 (CST)