aboutsummaryrefslogtreecommitdiff
path: root/src/libjin/Common/je_subsystem.hpp
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2018-10-19 08:36:44 +0800
committerchai <chaifix@163.com>2018-10-19 08:36:44 +0800
commit7d5f055547e70fa93ee9ac944e62f8d657b9dc55 (patch)
tree081782a1541854db4b8eb69c4b43081f52711286 /src/libjin/Common/je_subsystem.hpp
parent02dd1f38008594048f0e28bad01e7c6d18844198 (diff)
*修改文件名
Diffstat (limited to 'src/libjin/Common/je_subsystem.hpp')
-rw-r--r--src/libjin/Common/je_subsystem.hpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/libjin/Common/je_subsystem.hpp b/src/libjin/Common/je_subsystem.hpp
new file mode 100644
index 0000000..2875058
--- /dev/null
+++ b/src/libjin/Common/je_subsystem.hpp
@@ -0,0 +1,44 @@
+#ifndef __LIBJIN_COMMON_SUBSYSTEM_H
+#define __LIBJIN_COMMON_SUBSYSTEM_H
+
+#include "../utils/je_macros.h"
+
+#include "je_singleton.hpp"
+
+namespace jin
+{
+
+ template<class System>
+ class Subsystem : public Singleton<System>
+ {
+ public:
+ struct Setting {};
+ typedef Setting SettingBase;
+
+ bool init(const SettingBase* setting = nullptr)
+ {
+ static bool success = initSystem(setting);
+ return success;
+ }
+
+ void quit()
+ {
+ /*call only once*/
+ static char __dummy__ = (quitSystem(), 1);
+ Singleton<System>::destroy();
+ }
+
+ protected:
+ singleton(System);
+
+ Subsystem() {};
+ virtual ~Subsystem() {};
+
+ /*onlyonce*/ virtual bool initSystem(const Setting* setting) = 0;
+ /*onlyonce*/ virtual void quitSystem() = 0;
+
+ };
+
+} // namespace jin
+
+#endif \ No newline at end of file