Files
eepp/src/system/singleton.hpp
spartanj f8703cd568 Added Vertex Buffer support ( cVertexBuffer base class (interface), cVertexBufferOGL fallback if gpu doesn't support VBO's, cVertexBufferVBO uses ARB Vertex Buffer Object ).
Added a Memory Manager to trace memory leaks.
Fixed some memory leaks detected with the new memory manager.
Added an allocator for STL ( to use it with the custom allocation seted in the memory manager ).
Fixed Makefiles ( i wroke them ).
2010-09-03 02:53:14 -03:00

44 lines
912 B
C++
Executable File

#ifndef EE_SYSTEMSINGLETON_H
#define EE_SYSTEMSINGLETON_H
#include "../base.hpp"
namespace EE { namespace System {
/** @brief Template class for only one instance classes. */
template<typename T>
class tSingleton {
static T* ms_singleton;
public:
/** Get the singleton pointer */
static T* CreateSingleton() {
if (ms_singleton == 0)
ms_singleton = eeNew( T, () );
return ms_singleton;
}
/** Get the singleton pointer (without instance verification) */
static T* ExistsSingleton() {
return ms_singleton;
}
/** Get the singleton pointer */
static T* instance() {
return CreateSingleton();
}
/** Destroy the singleton instance */
static void DestroySingleton() {
if( ms_singleton != 0 ) {
eeDelete( ms_singleton );
ms_singleton = 0;
}
}
};
template <typename T> T* tSingleton <T>::ms_singleton = 0;
}}
#endif