My Project
CSingleton.h
1 //----------------------------------------------------------------------
2 // Class: CSingleton
3 // Authors: LiXizhi, LiuWeili
4 // company: paraengine.com
5 // Date: 2006.3.17
6 //-----------------------------------------------------------------------
7 #pragma once
8 
9 #include "IParaEngineApp.h"
10 
11 namespace ParaEngine
12 {
13  template <class T >
14  class CSingleton
15  {
16  public:
17  static T & Instance()
18  {
19  static T g_instance;
20  return g_instance;
21  }
22  };
23 
27  template <class T >
29  {
30  public:
31  static T* GetInstance()
32  {
33  static T* g_pSington = 0;
34  if (g_pSington == 0) {
35  g_pSington = new T();
37  }
38  return g_pSington;
39  }
40  };
41 }
static IParaEngineApp * GetApp()
get the application interface.
Definition: Globals.cpp:74
virtual CRefCounted * AddToSingletonReleasePool(CRefCounted *pObject)
we will automatically release singleton object when app stops, in the verse order when object is adde...
Definition: IParaEngineApp.h:428
different physics engine has different winding order.
Definition: EventBinding.h:32
Definition: CSingleton.h:14
app singleton must inherit from CRefCounted.
Definition: CSingleton.h:28