mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-05-29 09:36:29 +03:00
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 ).
44 lines
912 B
C++
Executable File
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
|