-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSingleton.hpp
More file actions
48 lines (38 loc) · 1 KB
/
Copy pathSingleton.hpp
File metadata and controls
48 lines (38 loc) · 1 KB
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
40
41
42
43
44
45
46
47
48
/*
Copyright (C) 2019 Blue Mountains GmbH
This program is free software: you can redistribute it and/or modify it under the terms of the Onset
Open Source License as published by Blue Mountains GmbH.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the Onset Open Source License for more details.
You should have received a copy of the Onset Open Source License along with this program. If not,
see https://bluemountains.io/Onset_OpenSourceSoftware_License.txt
*/
#pragma once
template<class T>
class Singleton
{
protected:
static T *m_Instance;
public:
Singleton()
{ }
virtual ~Singleton()
{ }
inline static T *Get()
{
if (m_Instance == nullptr)
m_Instance = new T;
return m_Instance;
}
inline static void Destroy()
{
if (m_Instance != nullptr)
{
delete m_Instance;
m_Instance = nullptr;
}
}
};
template <class T>
T* Singleton<T>::m_Instance = nullptr;