xmscore  1.0
xms::SharedSingleton< T > Class Template Reference

Singleton which can share the same instance with other singletons. More...

#include <Singleton.h>

Public Types

typedef boost::shared_ptr< T > Ptr
 Instance pointer.
 

Static Public Member Functions

static Ptr Instance (Ptr a_new=Ptr(), bool a_delete=false)
 Get a singleton instance. More...
 
static void Delete ()
 Delete the current instance.
 

Detailed Description

template<typename T>
class xms::SharedSingleton< T >

Singleton which can share the same instance with other singletons.

This allows a derived instance to be accessed as either the derived type or or as the base type. A utility may need to access the instance only as a base type, not knowing anything about the derived type, while the calling code may need to access functionality in the derived type. Create this for the base type and for 1 or more derived types, initializing each to the same instance shared pointer of the most derived type. Then access that instance through any singleton that has the appropriate type.

Definition at line 82 of file Singleton.h.

Member Function Documentation

◆ Instance()

template<typename T >
static Ptr xms::SharedSingleton< T >::Instance ( Ptr  a_new = Ptr(),
bool  a_delete = false 
)
inlinestatic

Get a singleton instance.

Parameters
a_newA new pointer to use as the instance when called the first time or just after the instance has been deleted.
a_deleteIf true delete the current instance and RETURN AN INVALID INSTANCE.
Returns
A boost::shared_ptr with the instance.

Definition at line 94 of file Singleton.h.


The documentation for this class was generated from the following file: