17 #ifndef CYBER_COMMON_MACROS_H_ 18 #define CYBER_COMMON_MACROS_H_ 23 #include <type_traits> 44 #undef DISALLOW_COPY_AND_ASSIGN 46 #define UNUSED(param) (void)param 48 #define DISALLOW_COPY_AND_ASSIGN(classname) \ 49 classname(const classname &) = delete; \ 50 classname &operator=(const classname &) = delete; 52 #define DECLARE_SINGLETON(classname) \ 54 static classname *Instance(bool create_if_needed = true) { \ 55 static classname *instance = nullptr; \ 56 if (!instance && create_if_needed) { \ 57 static std::once_flag flag; \ 58 std::call_once(flag, \ 59 [&] { instance = new (std::nothrow) classname(); }); \ 64 static void CleanUp() { \ 65 auto instance = Instance(false); \ 66 if (instance != nullptr) { \ 67 CallShutdown(instance); \ 73 DISALLOW_COPY_AND_ASSIGN(classname) 75 #endif // CYBER_COMMON_MACROS_H_ #define DEFINE_TYPE_TRAIT(name, func)
Definition: macros.h:33
std::enable_if< HasShutdown< T >::value >::type CallShutdown(T *instance)
Definition: macros.h:31
apollo::cyber::base::std value