Nebula
Toggle main menu visibility
Loading...
Searching...
No Matches
posixsingleton.h
Go to the documentation of this file.
1
#pragma once
2
#ifndef CORE_POSIXSINGLETON_H
3
#define CORE_POSIXSINGLETON_H
4
//------------------------------------------------------------------------------
22
#include "
core/types.h
"
23
24
//------------------------------------------------------------------------------
25
#define __DeclareSingleton(type) \
26
public: \
27
static ThreadLocal type * Singleton; \
28
static type * Instance() { n_assert(0 != Singleton); return Singleton; }; \
29
static bool HasInstance() { return 0 != Singleton; }; \
30
private:
31
32
#define __DeclareInterfaceSingleton(type) \
33
public: \
34
static type * Singleton; \
35
static type * Instance() { n_assert(0 != Singleton); return Singleton; }; \
36
static bool HasInstance() { return 0 != Singleton; }; \
37
private:
38
39
#define __ImplementSingleton(type) \
40
ThreadLocal type * type::Singleton = 0;
41
42
#define __ImplementInterfaceSingleton(type) \
43
type * type::Singleton = 0;
44
45
#define __ConstructSingleton \
46
n_assert(0 == Singleton); Singleton = this;
47
48
#define __ConstructInterfaceSingleton \
49
n_assert(0 == Singleton); Singleton = this;
50
51
#define __DestructSingleton \
52
n_assert(Singleton); Singleton = 0;
53
54
#define __DestructInterfaceSingleton \
55
n_assert(Singleton); Singleton = 0;
56
//------------------------------------------------------------------------------
57
#endif
58
types.h
code
foundation
core
posix
posixsingleton.h
Generated on
for Nebula. Dark theme by
Tilen Majerle
. All rights reserved.