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