aboutsummaryrefslogtreecommitdiff
path: root/src/libjin/common/subsystem.h
blob: 8a4ecf6421f934c3ec4ad763a63768ef8d573bd3 (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.h"
#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)
        {
            static bool success = initSystem(setting);
            return success;
        }

        void quit()
        {
            CALLONCE(quitSystem());
            destroy();
        }

    protected:

        Subsystem() {};
        virtual ~Subsystem() {};

        SINGLETON(System);

        virtual onlyonce bool initSystem(const Setting* setting) = 0;
        virtual onlyonce void quitSystem() = 0;

    };

} // jin

#endif