00001 #ifndef MERT_SINGLETON_H_
00002 #define MERT_SINGLETON_H_
00003
00004 #include <cstdlib>
00005
00006 namespace MosesTuning
00007 {
00008
00009
00010
00011
00012 template <typename T>
00013 class Singleton
00014 {
00015 public:
00016 static T* GetInstance() {
00017 if (m_instance == NULL) {
00018 m_instance = new T;
00019 }
00020 return m_instance;
00021 }
00022
00023 static void Delete() {
00024 delete m_instance;
00025 m_instance = NULL;
00026 }
00027
00028 private:
00029 Singleton();
00030 static T* m_instance;
00031 };
00032
00033 template <typename T>
00034 T* Singleton<T>::m_instance = NULL;
00035
00036 }
00037
00038 #endif // MERT_SINGLETON_H_