48 #ifndef _MIRA_VOIDCAST_H_ 49 #define _MIRA_VOIDCAST_H_ 52 #include <type_traits> 55 #include <boost/mpl/eval_if.hpp> 56 #include <boost/mpl/identity.hpp> 61 namespace mira {
namespace serialization {
67 struct VoidUpcastNormal {
69 static void* invoke(T* pointer) {
71 Tc* p =
const_cast<Tc*
>(pointer);
72 return static_cast<void*
>(p);
76 struct VoidDowncastNormal {
78 static T* invoke(
void* pointer) {
79 return static_cast<T*
>(pointer);
87 struct VoidUpcastPolymorphic {
89 static void* invoke(T* pointer) {
91 Tc* p =
const_cast<Tc*
>(pointer);
93 return static_cast<void*
>(obj);
97 struct VoidDowncastPolymorphic {
99 static T* invoke(
void* pointer) {
101 T* p =
dynamic_cast<T*
>(obj);
116 template <
typename T>
120 boost::mpl::eval_if<std::is_base_of<mira::Object, T>,
121 boost::mpl::identity< VoidUpcastPolymorphic >,
123 boost::mpl::identity< VoidUpcastNormal >
126 return type::template invoke<T>(pointer);
134 template <
typename T>
138 boost::mpl::eval_if<std::is_base_of<mira::Object, T>,
139 boost::mpl::identity< VoidDowncastPolymorphic >,
141 boost::mpl::identity< VoidDowncastNormal >
143 return type::template invoke<T>(pointer);
specialize cv::DataType for our ImgPixel and inherit from cv::DataType<Vec>
Definition: IOService.h:67
PropertyHint type(const std::string &t)
Sets the attribute "type" to the specified value.
Definition: PropertyHint.h:295
T * void_downcast(void *pointer)
Safe cast for casting from a void pointer to a derived pointer T* while taking care of polymorphism a...
Definition: VoidCast.h:135
The object class acts as a generic base class for classes which should be used with the classFactory...
Definition: Object.h:144
$Defines object class as base class for classFactory compatible classes$.
void * void_upcast(T *pointer)
Safe cast for casting from a pointer upwards to void* while taking care of polymorphism and multiple ...
Definition: VoidCast.h:117