FUtils/FUSingleton.h File Reference

This file contains macros to easily implement singletons. More...

Go to the source code of this file.

Defines

#define DECLARE_SINGLETON_CLASS(className)
 Declares a singleton.
#define DECLARE_SINGLETON_CLASS_WITH_ARGS(className, createArgs)
 Declares a singleton.
#define DECLARE_SINGLETON_CLASS_WITH_ARGS2(className, createArgs1, createArgs2)
 Declares a singleton.
#define IMPLEMENT_SINGLETON(className)
 Implements the singleton.
#define IMPLEMENT_SINGLETON_WITH_ARGS(className, createArg1)
 Implements the singleton.
#define IMPLEMENT_SINGLETON_WITH_ARGS2(className, createArg1, createArg2)
 Implements the singleton.
#define IMPLEMENT_CREATE_SINGLETON(className)
 Implements the construction of a singleton.
#define IMPLEMENT_CREATE_SINGLETON_WITH_ARGS(className, createArg1)
 Implements the construction of a singleton.
#define IMPLEMENT_CREATE_SINGLETON_WITH_ARGS2(className, createArg1, createArg2)
 Implements the construction of a singleton.
#define IMPLEMENT_DESTROY_SINGLETON(className)
 Implements the destruction of a singleton.


Detailed Description

This file contains macros to easily implement singletons.

A singleton is a class which has only one object of this class. The advantage of a singleton over a static class is that the application controls when and how the singleton is created and destroyed. The disadvantage of a singleton is that you have one extra memory lookup to do.


Define Documentation

#define DECLARE_SINGLETON_CLASS className   ) 
 

Value:

private: \
    static className* m_pSingleton; \
public: \
    static bool CreateSingleton(); \
    static void DestroySingleton(); \
    friend className* Get##className();
Declares a singleton.

Use this macros within the class declaration.

Parameters:
className The name of the class.

#define DECLARE_SINGLETON_CLASS_WITH_ARGS className,
createArgs   ) 
 

Value:

private: \
    static className* m_pSingleton; \
public: \
    static bool CreateSingleton(createArgs); \
    static void DestroySingleton(); \
    friend className* Get##className();
Declares a singleton.

Use this macros within the class declaration.

Parameters:
className The name of the class.
createArgs An argument for the constructor of the singleton.

#define DECLARE_SINGLETON_CLASS_WITH_ARGS2 className,
createArgs1,
createArgs2   ) 
 

Value:

private: \
    static className* m_pSingleton; \
public: \
    static bool CreateSingleton(createArgs1, createArgs2); \
    static void DestroySingleton(); \
    friend className* Get##className();
Declares a singleton.

Use this macros within the class declaration.

Parameters:
className The name of the class.
createArgs1 A first argument for the constructor of the singleton.
createArgs2 A second argument for the constructor of the singleton.

#define IMPLEMENT_CREATE_SINGLETON className   ) 
 

Value:

className* className::m_pSingleton; \
    className* Get##className() { return className::m_pSingleton; } \
    bool className::CreateSingleton() { \
        m_pSingleton = new className(); \
        return true; }
Implements the construction of a singleton.

Use this macros within the class implementation.

Parameters:
className The name of the class.

#define IMPLEMENT_CREATE_SINGLETON_WITH_ARGS className,
createArg1   ) 
 

Value:

className* className::m_pSingleton; \
    className* Get##className() { return className::m_pSingleton; } \
    bool className::CreateSingleton(createArg1 argument1) { \
        m_pSingleton = new className(argument1); }
Implements the construction of a singleton.

Use this macros within the class implementation.

Parameters:
className The name of the class.
createArg1 The argument for the constructor of the singleton.

#define IMPLEMENT_CREATE_SINGLETON_WITH_ARGS2 className,
createArg1,
createArg2   ) 
 

Value:

className* className::m_pSingleton; \
    className* Get##className() { return className::m_pSingleton; } \
    bool className::CreateSingleton(createArg1 argument1, createArg2 argument2) { \
        m_pSingleton = new className(argument1, argument2); }
Implements the construction of a singleton.

Use this macros within the class implementation.

Parameters:
className The name of the class.
createArg1 A first argument for the constructor of the singleton.
createArg2 A second argument for the constructor of the singleton.

#define IMPLEMENT_DESTROY_SINGLETON className   ) 
 

Value:

void className::DestroySingleton() \
    { SAFE_DELETE(m_pSingleton); }
Implements the destruction of a singleton.

Use this macros within the class implementation.

Parameters:
className The name of the class.

#define IMPLEMENT_SINGLETON className   ) 
 

Value:

Implements the singleton.

Use this macros within the class implementation.

Parameters:
className The name of the class.

#define IMPLEMENT_SINGLETON_WITH_ARGS className,
createArg1   ) 
 

Value:

Implements the singleton.

Use this macros within the class implementation.

Parameters:
className The name of the class.
createArg1 The argument for the constructor of the singleton.

#define IMPLEMENT_SINGLETON_WITH_ARGS2 className,
createArg1,
createArg2   ) 
 

Value:

IMPLEMENT_CREATE_SINGLETON_WITH_ARGS2(className, createArg1, createArg2) \
    IMPLEMENT_DESTROY_SINGLETON(className)
Implements the singleton.

Use this macros within the class implementation.

Parameters:
className The name of the class.
createArg1 A first argument for the constructor of the singleton.
createArg2 A second argument for the constructor of the singleton.


Generated on Fri May 12 16:44:40 2006 for FCollada by  doxygen 1.4.6-NO