13 #ifndef __UT_SUBSYSTEM_H__
14 #define __UT_SUBSYSTEM_H__
18 #define UT_ENABLE_SUBSYSTEMS
25 #include <type_traits>
48 template <
typename SubSystemT>
52 std::is_base_of_v<UT_ISubSystem, SubSystemT>
53 && std::is_default_constructible_v<SubSystemT>);
54 return registerSubSystem_(std::addressof(subsys));
61 virtual void initialize_() = 0;
63 virtual void shutdown_() = 0;
65 friend class ut_SubSystemRegistry;
70 #define UT_SUBSYSTEM_CLASS(sub_type) \
72 static constexpr Type subsystem_type = UT_ISubSystem::Type::sub_type; \
73 Type type() const override \
75 return subsystem_type; \
79 static bool theIsRegistered;
81 #define UT_SUBSYSTEM_IMPL_INNER(cls) \
82 static SYS_StaticInit<cls> theSubSystem; \
83 static void cls##Init() \
85 UT_ISubSystem::registerSubSystem<cls>(*theSubSystem); \
87 static void cls##CleanUp() \
91 #define UT_SUBSYSTEM_IMPL(cls) \
92 namespace cls_Namespace \
94 UT_SUBSYSTEM_IMPL_INNER(cls) \
95 SYSimplementStaticInit(cls); \
98 #define UT_SUBSYSTEM_DECLARE(api, cls) \
99 namespace cls_Namespace \
101 SYSdeclareStaticInit(api, cls) \
124 namespace UT_SubSystemImpl
131 template <
typename T>
135 static_assert(std::is_base_of_v<T, UT_ISubSystem>());
141 #endif // __UT_SUBSYSTEM_H__
The subsystem to initialize and cleanup UT.
virtual void shutdown_()=0
Shutdown this subsystem.
UT_API void UTsubSystemShutdown()
#define UT_NON_COPYABLE(CLASS)
Define deleted copy constructor and assignment operator inside a class.
#define UT_SUBSYSTEM_CLASS(sub_type)
static bool registerSubSystem(SubSystemT &subsys)
#define UT_SUBSYSTEM_DECLARE(api, cls)
SYSdeclareStaticObject(UT_API, theRegistry)
virtual void initialize_()=0
Initialize this subsystem.
UT_API void UTsubSystemInitialize()
Initialize all subsystems.
UT_API UT_ISubSystem * utGetSubSystem(UT_SubSystem::Type t)