template<typename T> struct Signature
Signatures provide a uniform means of accessing the Class object and the static type of that class of any reflected type, dynamic (Dynamic) or not.
Since it is a templated struct, it must be specialized for every static type it reflects (this is done in DECLARE_STATIC_REFLECTION), its default implementation covers the dynamic types.
Its main use is for getting the class of a type, which can be done with
Signature<Type>::TheClass()
However, since it is a templated struct, this is somewhat awkward. It is suggested that you use TypeOf instead, which is easier to use inside a template and saves typeing (pun!).
The functions opaque_cast and translucent_cast turn typed pointers into generic (opaque) pointers and back. This loses typeinfo, for a generic way to pass typed data around, see Variant.
Signature | Signatures provide a uniform means of accessing the Class object and the static type of that class of any reflected type, dynamic (Dynamic) or not. |
Types | |
ClassType | This is the public static type of the Class represented by this signature type. |
Functions | |
TheClass | Returns the Class of the type represented by this signature. |
Helper Functions | These functions help automate the common uses of the Signature type. |
Functions | |
TypeOf | Templated function, returns the Class of a reflected type. |
TypeOf (by value) | Returns the Class type of an expression with a reflected type. |
TypeOf (by array value) | Returns a pointer type for an array. |
opaque_cast | Turns a typed pointer (of type Type *) into an opaque pointer (a void *), for use with the class Signature::TheClass. |
translucent_cast | Turns an opaque pointer (of type void *) into a typed pointer of the specified type. |
typedef typename T::ClassType ClassType
This is the public static type of the Class represented by this signature type.
Returns the Class of the type represented by this signature.
These functions help automate the common uses of the Signature type.
Functions | |
TypeOf | Templated function, returns the Class of a reflected type. |
TypeOf (by value) | Returns the Class type of an expression with a reflected type. |
TypeOf (by array value) | Returns a pointer type for an array. |
opaque_cast | Turns a typed pointer (of type Type *) into an opaque pointer (a void *), for use with the class Signature::TheClass. |
translucent_cast | Turns an opaque pointer (of type void *) into a typed pointer of the specified type. |
template<typename T> inline typename Signature<T>::ClassType *TypeOf()
Templated function, returns the Class of a reflected type.
Class *type = TypeOf<int>(); if(TypeOf<MyObject>()->Derives<Persistent>()) ...
template<typename T> inline typename Signature<T>::ClassType *TypeOf( const T & )
Returns the Class type of an expression with a reflected type.
template<typename T> inline void *opaque_cast( T * value )
Turns a typed pointer (of type Type *) into an opaque pointer (a void *), for use with the class Signature::TheClass. There are const and non-const versions of this function.
template<typename Type> inline Type translucent_cast( void * value )
Turns an opaque pointer (of type void *) into a typed pointer of the specified type. There are const and non-const versions of this function.
Implemented by Class::TranslucentCast.
Paired with opaque_cast.
Signatures provide a uniform means of accessing the Class object and the static type of that class of any reflected type, dynamic (Dynamic) or not.
template<typename T> struct Signature
class ReflectExport( reflect ) Class : public ObjectType
This class defines the core interface for all runtime type identification (RTTI) in reflect.
class ReflectExport( reflect ) Dynamic
This is the public static type of the Class represented by this signature type.
typedef typename T::ClassType ClassType
Templated function, returns the Class of a reflected type.
template<typename T> inline typename Signature<T>::ClassType *TypeOf()
Returns the Class type of an expression with a reflected type.
template<typename T> inline typename Signature<T>::ClassType *TypeOf( const T & )
Returns a pointer type for an array.
template<typename T, unsigned size> inline typename Signature<T>::ClassType *TypeOf( const T (&)[size] )
Turns a typed pointer (of type Type *) into an opaque pointer (a void *), for use with the class Signature::TheClass.
template<typename T> inline void *opaque_cast( T * value )
Turns an opaque pointer (of type void *) into a typed pointer of the specified type.
template<typename Type> inline Type translucent_cast( void * value )
Variants represent objects of any reflected type.
class ReflectExport( reflect ) Variant
Casts a type represented by this Class to a void *, used by Serialize.
template<typename T> static void *OpaqueCast( T * ptr )
Casts a void * from OpaqueCast (template/static) back to a T *.
template<typename T> static T *TranslucentCast( void * ptr )