13 #ifndef __UT_SUBSYSTEM_H__
14 #define __UT_SUBSYSTEM_H__
18 #define UT_ENABLE_SUBSYSTEMS
25 #include <type_traits>
52 template <
typename SubSystemT>
56 std::is_base_of_v<UT_ISubSystem, SubSystemT>
57 && std::is_default_constructible_v<SubSystemT>);
58 return registerSubSystem_(std::addressof(subsys));
65 virtual void initialize_() = 0;
67 virtual void shutdown_() = 0;
69 friend class ut_SubSystemRegistry;
74 #define UT_SUBSYSTEM_CLASS(sub_type) \
76 static constexpr Type subsystem_type = UT_ISubSystem::Type::sub_type; \
77 Type type() const override \
79 return subsystem_type; \
83 static bool theIsRegistered;
85 #define UT_SUBSYSTEM_IMPL_INNER(cls) \
86 static SYS_StaticInit<cls> theSubSystem; \
87 static void cls##Init() \
89 UT_ISubSystem::registerSubSystem<cls>(*theSubSystem); \
91 static void cls##CleanUp() \
95 #define UT_SUBSYSTEM_IMPL(cls) \
96 namespace cls_Namespace \
98 UT_SUBSYSTEM_IMPL_INNER(cls) \
99 SYSimplementStaticInit(cls); \
102 #define UT_SUBSYSTEM_DECLARE(api, cls) \
103 namespace cls_Namespace \
105 SYSdeclareStaticInit(api, cls) \
122 friend class ut_SubSystemAccessor;
140 namespace UT_SubSystemImpl
147 template <
typename T>
151 static_assert(std::is_base_of_v<UT_ISubSystem, T>);
157 #endif // __UT_SUBSYSTEM_H__
The subsystem to initialize and cleanup UT.
virtual void shutdown_()=0
Shutdown this subsystem.
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
UT_API void UTsubSystemShutdown()
#define UT_NON_COPYABLE(CLASS)
Define deleted copy constructor and assignment operator inside a class.
UT_API UT_ThreadIOPool & UThoudiniIOPool()
#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)