roviz  0.7
Code Documentation of roviz
startup_helper_templates.h
1 #ifndef STARTUP_HELPER_TEMPLATES
2 #define STARTUP_HELPER_TEMPLATES
3 
4 namespace internal
5 {
6 typedef void (*VoidFnPtr)();
7 
8 //Template to get a pointer to the init() function (static) of class T.
9 template<class T, class EN = void> struct GetInitFnPtr {
10  //Fallback for the case when T has no init function
11  static constexpr const VoidFnPtr value = nullptr;
12 };
13 template<class T> struct GetInitFnPtr<T, decltype(void(T::init()))> {
14  //Specialization for the case when T has indeed a init() function
15  static constexpr const VoidFnPtr value = &T::init;
16 };
17 
18 //Template to get a pointer to the deinit() function (static) of class T.
19 template<class T, class EN = void> struct GetDeinitFnPtr {
20  //Fallback for the case when T has no deinit function
21  static constexpr const VoidFnPtr value = nullptr;
22 };
23 template<class T> struct GetDeinitFnPtr<T, decltype(void(T::deinit()))> {
24  //Specialization for the case when T has indeed a deinit() function
25  static constexpr const VoidFnPtr value = &T::deinit;
26 };
27 
28 //Helper to check whether or not class T has a staticMetaObject (qt)
29 template<class T, class EN = void> struct HasMetaObject : std::false_type {
30  //Specialization for the case when T has no staticMetaObject
31 };
32 
33 template<class T> struct HasMetaObject<T,
34  typename std::enable_if<std::is_same<const QMetaObject, decltype(T::staticMetaObject)>::value>::type> : std::true_type {
35  //Specialization for the case when T has indeed staticMetaObject
36  // using is_same to compare the type of staticMetaObject to QMetaObject. If theres no such member => SFINAE
37  };
38 }
39 
40 #endif // STARTUP_HELPER_TEMPLATES
41 
Definition: startup_helper_templates.h:4
Definition: startup_helper_templates.h:19
Definition: startup_helper_templates.h:29
Definition: startup_helper_templates.h:9