blob: 47351717054c0813100cfa3b7a81fa5bff3ce04f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
#ifndef MERT_SINGLETON_H_
#define MERT_SINGLETON_H_
#include <cstdlib>
namespace MosesTuning
{
// thread *un*safe singleton.
// TODO: replace this with thread-safe singleton.
template <typename T>
class Singleton {
public:
static T* GetInstance() {
if (m_instance == NULL) {
m_instance = new T;
}
return m_instance;
}
static void Delete() {
if (m_instance) {
delete m_instance;
m_instance = NULL;
}
}
private:
Singleton();
static T* m_instance;
};
template <typename T>
T* Singleton<T>::m_instance = NULL;
}
#endif // MERT_SINGLETON_H_
|