Loading...
Searching...
No Matches
Go to the documentation of this file.
2#ifndef CORE_POSIXSINGLETON_H
3#define CORE_POSIXSINGLETON_H
25#define __DeclareSingleton(type) \
27 static ThreadLocal type * Singleton; \
28 static type * Instance() { n_assert(0 != Singleton); return Singleton; }; \
29 static bool HasInstance() { return 0 != Singleton; }; \
32#define __DeclareInterfaceSingleton(type) \
34 static type * Singleton; \
35 static type * Instance() { n_assert(0 != Singleton); return Singleton; }; \
36 static bool HasInstance() { return 0 != Singleton; }; \
39#define __ImplementSingleton(type) \
40 ThreadLocal type * type::Singleton = 0;
42#define __ImplementInterfaceSingleton(type) \
43 type * type::Singleton = 0;
45#define __ConstructSingleton \
46 n_assert(0 == Singleton); Singleton = this;
48#define __ConstructInterfaceSingleton \
49 n_assert(0 == Singleton); Singleton = this;
51#define __DestructSingleton \
52 n_assert(Singleton); Singleton = 0;
54#define __DestructInterfaceSingleton \
55 n_assert(Singleton); Singleton = 0;