blob: 1374ad1c60143b2792c1ffed0f14caa2c3b2c0a7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
#ifndef __JIN_COMMON_SUBSYSTEM_H
#define __JIN_COMMON_SUBSYSTEM_H
#include "singleton.hpp"
#include "../utils/macros.h"
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()
{
CALLONCE(quitSystem());
Singleton<System>::destroy();
}
protected:
Subsystem() {};
virtual ~Subsystem() {};
SINGLETON(System);
/*onlyonce*/ virtual bool initSystem(const Setting* setting) = 0;
/*onlyonce*/ virtual void quitSystem() = 0;
};
} // jin
#endif
|