summaryrefslogtreecommitdiff
path: root/libadhocutil/globalStatic.impl.h
blob: ba12da8f11ec140989349d2f2a19471c79ef7339 (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
#ifndef ADHOCUTIL_GLOBALSTATIC_IMPL_H
#define ADHOCUTIL_GLOBALSTATIC_IMPL_H

#include "globalStatic.h" // IWYU pragma: export

namespace AdHoc {
	template<typename Object>
	Object *
	GlobalStatic<Object>::get()
	{
		return instance();
	}

	template<typename Object>
	void
	GlobalStatic<Object>::createObject()
	{
		instance() = new Object();
	}

	template<typename Object>
	void
	GlobalStatic<Object>::deleteObject()
	{
		delete instance();
		instance() = nullptr;
	}

	template<typename Object>
	typename GlobalStatic<Object>::Ptr &
	GlobalStatic<Object>::instance()
	{
		static Ptr _instance;
		return _instance;
	}
}

#endif