From 128b6dd3e3a803e475ec03493ee26e6b20d7e42b Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 23 Jul 2018 18:57:50 +0800 Subject: update Signed-off-by: chai --- src/libjin/common/singleton.h | 6 +++++- src/libjin/common/subsystem.h | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'src/libjin/common') 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 T* Singleton::_instance = nullptr; + +#define SINGLETON(T) \ + friend Singleton + } #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; + }; } -- cgit v1.1-26-g67d0