OpenLexocad  28.0
base_singleton.h
Go to the documentation of this file.
1 
8 #pragma once
9 #error "This is shit, do not include pls";
10 
11 //----------------------------------------------------------------------------
12 // DECLARATIONs
13 //----------------------------------------------------------------------------
14 
25 #define DECLARE_SINGLETON(CLASSNAME) \
26 \
27 public: \
28  static CLASSNAME* instance(); \
29  static void destroy(); \
30 \
31 protected: \
32  CLASSNAME(); \
33  ~CLASSNAME(); \
34 \
35 private: \
36  static CLASSNAME* _instance;
37 
38 
39 
54 #define DEFINE_SINGLETON(CLASSNAME) \
55  CLASSNAME* CLASSNAME::_instance = nullptr; \
56 \
57  CLASSNAME* CLASSNAME::instance() \
58  { \
59  if (!_instance) \
60  { \
61  _instance = new CLASSNAME; \
62  } \
63  return _instance; \
64  } \
65 \
66  void CLASSNAME::destroy() \
67  { \
68  delete _instance; \
69  _instance = nullptr; \
70  }