diff options
author | chai <chaifix@163.com> | 2018-07-23 18:57:50 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2018-07-23 18:57:50 +0800 |
commit | 128b6dd3e3a803e475ec03493ee26e6b20d7e42b (patch) | |
tree | 2dece2011db239c7ebee2786c9978e5636ea4947 /src/libjin/common | |
parent | a4c51a4ac6dc263c3ea2cd49afbd3fbad9ccea17 (diff) |
update
Signed-off-by: chai <chaifix@163.com>
Diffstat (limited to 'src/libjin/common')
-rw-r--r-- | src/libjin/common/singleton.h | 6 | ||||
-rw-r--r-- | src/libjin/common/subsystem.h | 6 |
2 files changed, 10 insertions, 2 deletions
diff --git a/src/libjin/common/singleton.h b/src/libjin/common/singleton.h index e6326b2..a6c7d6d 100644 --- a/src/libjin/common/singleton.h +++ b/src/libjin/common/singleton.h @@ -21,7 +21,7 @@ namespace jin protected: Singleton() {}; virtual ~Singleton() {}; - private: + private: Singleton(const Singleton&); Singleton& operator = (const Singleton&); @@ -29,6 +29,10 @@ namespace jin }; template<class T> T* Singleton<T>::_instance = nullptr; + +#define SINGLETON(T) \ + friend Singleton<T> + } #endif
\ No newline at end of file diff --git a/src/libjin/common/subsystem.h b/src/libjin/common/subsystem.h index 55b0f0d..90e8570 100644 --- a/src/libjin/common/subsystem.h +++ b/src/libjin/common/subsystem.h @@ -16,7 +16,7 @@ namespace jin void init(const SettingBase* setting) { - CallOnce(initSystem(setting)); + CALLONCE(initSystem(setting)); } void quit() @@ -26,11 +26,15 @@ namespace jin } protected: + Subsystem() {}; virtual ~Subsystem() {}; + SINGLETON(System); + virtual bool initSystem(const Setting* setting) = 0; virtual void quitSystem() = 0; + }; } |