| 
    HDK
    
   | 
 
#include <singleton.h>
Public Member Functions | |
| template<> | |
| void | DeleteInstance ()=delete | 
Static Public Member Functions | |
| static T & | GetInstance () | 
| static bool | CurrentlyExists () | 
| static void | SetInstanceConstructed (T &instance) | 
| static void | DeleteInstance () | 
Manage a single instance of an object (see
Typical Use for a canonical example).
Definition at line 105 of file singleton.h.
      
  | 
  inlinestatic | 
Return whether or not the single object of type T is currently in existence.
This call tests whether or not the singleton currently exists.
Definition at line 138 of file singleton.h.
      
  | 
  inlinestatic | 
Destroy the sole instance object of type T, if it exists.
A singleton can be destroyed by a call to DeleteInstance. This call is threadsafe in the sense that competing simultaneous calls will not result in double deletion; however, it is up to the user to ensure that the instance is not being used in one thread during an attempt to delete the instance from another thread. After being destroyed, a call to GetInstance() will create a new instance. 
Definition at line 106 of file instantiateSingleton.h.
      
  | 
  delete | 
      
  | 
  inlinestatic | 
Return a reference to an object of type T, creating it if necessary.
When GetInstance() is called for the first time, it creates an object of type T, and returns a reference to it. The type in question must have a default constructor (i.e. a constructor taking no arguments).
Subsequent calls to GetInstance() return a reference to the same object. This call is threadsafe; simultaneous attempts to create an object result in only one object being created; locking beyond this (for example, letting only one thread at a time call a member function) are the responsibility of the class author. 
Definition at line 120 of file singleton.h.
      
  | 
  inlinestatic | 
Indicate that the sole instance object has already been created.
This function is public, but can only be called usefully from within the class T itself. This function is used to allow the constructor of T to indicate that the sole instance of T has been created, and that future calls to GetInstance() can immediately return instance.
The need for this function occurs when the constructor of T generates a call chain that leads to calling TfSingleton<T>::GetInstance(). Until the constructor for T has finished, however, TfSingleton<T>::GetInstance() is unable to return a value. Calling SetInstanceConstructed() allows future calls to TfSingleton<T>::GetInstance() to return before T's constructor has finished.
Be sure that T has been constructed (enough) before calling this function. Calling this function anyplace but within the call chain of T's constructor will generate a fatal coding error. 
Definition at line 51 of file instantiateSingleton.h.