47 #ifndef _MIRA_TYPEDVOIDPTR_H_ 48 #define _MIRA_TYPEDVOIDPTR_H_ 110 template <
typename T>
112 mType(
typeId<T>()), mPtr(ptr) {}
117 bool isNull()
const {
return mPtr==NULL; }
125 template <
typename T>
126 operator T*() {
return cast<T>(); }
132 template <
typename T>
133 operator const T*()
const {
return cast<T>(); }
139 template <
typename T>
141 if(mType!=typeId<T>())
142 MIRA_THROW(XBadCast,
"Cannot cast to type '" << typeName<T>() <<
"'");
144 return static_cast<T*
>(mPtr);
151 template <
typename T>
154 return This->
cast<T>();
180 template <
typename T>
182 mType(
typeId<T>()), mPtr(ptr) {}
187 bool isNull()
const {
return mPtr==NULL; }
195 template <
typename T>
196 operator const T*()
const {
return cast<T>(); }
202 template <
typename T>
204 if(mType!=typeId<T>())
205 MIRA_THROW(XBadCast,
"Cannot cast to type '" << typeName<T>() <<
"'");
207 return static_cast<const T*
>(mPtr);
TypeId typeId()
Generates unique IDs for different types.
Definition: TypeId.h:94
TypedVoidConstPtr()
Creates nullptr.
Definition: TypedVoidPtr.h:177
TypedVoidPtr()
Creates nullptr.
Definition: TypedVoidPtr.h:107
TypedVoidPtr(T *ptr)
Creates a typed void pointer from the given pointer.
Definition: TypedVoidPtr.h:111
specialize cv::DataType for our ImgPixel and inherit from cv::DataType<Vec>
Definition: IOService.h:67
bool isNull() const
Return if underlying pointer is NULL.
Definition: TypedVoidPtr.h:117
Same as TypedVoidPtr but const.
Definition: TypedVoidPtr.h:171
Get compiler and platform independent typenames.
#define MIRA_THROW(ex, msg)
Macro for throwing an exception.
Definition: Exception.h:82
Class that allows to maintain type-safety when passing void pointers.
Definition: TypedVoidPtr.h:101
Commonly used exception classes.
T * cast()
Safely casts the object pointer that is stored to T*.
Definition: TypedVoidPtr.h:140
int TypeId
The type of the integral TypeId, that can be retrieved by typeId<T>()
Definition: TypeId.h:64
const T * cast() const
Safely casts the object pointer that is stored to const T*.
Definition: TypedVoidPtr.h:203
bool isNull() const
Return if underlying pointer is NULL.
Definition: TypedVoidPtr.h:187
TypedVoidConstPtr(const T *ptr)
Creates a typed void pointer from the given pointer.
Definition: TypedVoidPtr.h:181
Provides method for generating a unique id for any type.
const T * cast() const
Safely casts the object pointer that is stored to const T*.
Definition: TypedVoidPtr.h:152