MEL
Microthread & Execution library
mel::core::Singleton< T, isAbstract, useSmartPtr, ThreadingPolicy > Class Template Reference

#include <Singleton.h>

Inheritance diagram for mel::core::Singleton< T, isAbstract, useSmartPtr, ThreadingPolicy >:

Static Public Member Functions

static void deleteSingleton ()
 

Friends

class Singleton_Middle< T, ThreadingPolicy, useSmartPtr, isAbstract >
 

Detailed Description

template<class T, bool isAbstract = true, bool useSmartPtr = true, template< class > class ThreadingPolicy = ::mel::core::Singleton_Singlethread_Policy>
class mel::core::Singleton< T, isAbstract, useSmartPtr, ThreadingPolicy >

template class for singleton classes use: class A : public Singleton Singletons can be Abstract or concrete. In abstract singleton (default behaviour), you provide your own creation funcion son Singletong can be inherited.Although, abstract singleton is neccesary when you need to customize singleton creation (passing arguments to constructor). If singleton is declared as non-abstract, default constructor is called on first getSingleton call. Singleton must be deleted when no more needed using deleteSingleton function. When deleteSingleton is used it check for No more references to object (if using SmartPtr, of course) and throw an Exception if there are more references. If you don't like this behaviour you must overwrite deleteSingleton and do your own work. You can use SmartPtr for internal singleton. For that purpose use third parameter and put true. Example: class A: public Singleton<A,isAbstract,true> In that case, you can safety use SmartPtr's to singletons, but when you do deleteSingleton all other references to object should be removed.


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