class ReflectExport( reflect ) Type : public Dynamic
Type | |
Functions | |
Type | Constructs a class. |
~Type | Destructs this class and unlinks it from the class hierarchy. |
Parent | Gets the parent (base class) of this Type. |
SetParent | Sets the parent (base class) of this Type. |
Derives | Checks if this class represents a subclass of another. |
Derives (template) | Checks if this class represents a subclass of another. |
Child | The first subclass of this class or NULL if there are no subclasses. |
Sibling | The next sibling of this class, or itself if there are no siblings. |
LoadTypes | Initializes all types which have been static initialized. |
UnloadTypes | Reverses the effect of Type::LoadTypes. |
AnyRootType | Retrieves a root (any root) of the type hierarchy. |
FindType | Retrieves a type by name. |
FindType(char*) | Retrieves a type by name. |
SetName | Sets the name of the type and calls RegisterName to it in a global map. |
Name | The registered name of this type. |
NextTypeToLoad | The next type in a NULL terminated chain of types to load in Type::LoadTypes. |
FirstTypeToLoad | The first class in a NULL terminated chain of classes to load in the next Type::LoadTypes. |
Serialize | Serialize defines how objects represented by this type are serialized. |
OpaqueCast | Casts a type represented by this Type to a void *, used by Serialize. |
TranslucentCast | Casts a void * from OpaqueCast back to a Type. |
SetBasicOperations | Sets the factory function for this class. |
Size | The size of the object represented by this class. |
Alignment | The minimum required alignment of the object represented by this class. |
Construct | Constructs an instance of this type. |
Destruct | Destructs an instance of this type. |
Abstract | Checks if the class is Abstract. |
RegisterConversion | Registers a cast from type from to this type. |
CanConvertFrom | Checks if a cast from the specified type exists. |
CanConvertFrom (template) | Checks if a cast from the specified type exists. |
ConvertValue | Uses conversions registered with RegisterConversion. |
template<typename T> bool Derives() const
Checks if this class represents a subclass of another.
Template version of Derives.
Type *Child() const
The first subclass of this class or NULL if there are no subclasses.
The Sibling method can be used to iterate over the other subclasses.
Type *Sibling() const
The next sibling of this class, or itself if there are no siblings. Siblings are linked in a ring, so be careful when iterating over them. The folling idiom can be used to iterator over the subclasses of clazz:
if(Type *child = clazz->Child()) do { // PROCESS child } while((child = child->Sibling()) != clazz->Child());
static void UnloadTypes( Type * )
Reverses the effect of Type::LoadTypes.
Note: this hasn’t been tested much, it is probable that doing this is unsafe.
Type *NextTypeToLoad() const
The next type in a NULL terminated chain of types to load in Type::LoadTypes. The type chain is preserved after Type::LoadTypes.
static Type *FirstTypeToLoad()
The first class in a NULL terminated chain of classes to load in the next Type::LoadTypes. After Type::LoadTypes is called this will be NULL.
virtual void Serialize( const void * in, void * out, Reflector & reflector ) const
Serialize defines how objects represented by this type are serialized. The void * arguments must be converted from typed pointers the by the static template function Type::OpaqueCast, subtypes may hide the default implementation.
template<typename Type> static void *OpaqueCast( Type * ptr )
Casts a type represented by this Type to a void *, used by Serialize. (there are const and non-const versions of this function)
template<typename T> static T *TranslucentCast( void * ptr )
Casts a void * from OpaqueCast back to a Type. (there are const and non-const versions of this function)
void *Construct( void * ) const
Constructs an instance of this type. The pointer provided should be at least Size bytes and aligned to Alignment.
data | an aligned pointer to at least Alignment bytes of memory. |
An OpaqueCast of the object (if it’s not Abstract)
void *Destruct( void * ) const
Destructs an instance of this type. The pointer should be returned from Construct, or an opaque_cast of a pointer to data of this type.
data | the result of a previous Construct, or the OpaqueCast of an object represented by this class. |
The void pointer that would be passed to Construct originally. This would be an allocation pointer, not an opaque pointer.
bool Abstract() const
Checks if the class is Abstract.
true | if the class has no size. |
virtual bool ConvertValue( void * opaque, const void * source, const Type * from ) const
Uses conversions registered with RegisterConversion.
true | if a conversion from from is found. |
class ReflectExport( reflect ) Type : public Dynamic
Constructs a class.
Type( void (*init_cb)() = 0 )
Destructs this class and unlinks it from the class hierarchy.
~Type()
Gets the parent (base class) of this Type.
Type *Parent() const
Sets the parent (base class) of this Type.
void SetParent( Type * parent )
Checks if this class represents a subclass of another.
bool DerivesType( const Type * other ) const
Checks if this class represents a subclass of another.
template<typename T> bool Derives() const
The first subclass of this class or NULL if there are no subclasses.
Type *Child() const
The next sibling of this class, or itself if there are no siblings.
Type *Sibling() const
Initializes all types which have been static initialized.
static Type *LoadTypes()
Reverses the effect of Type::LoadTypes.
static void UnloadTypes( Type * )
Retrieves a root (any root) of the type hierarchy.
static Type *AnyRootType()
Retrieves a type by name.
static Type *FindType( string::FoundSharedString )
Retrieves a type by name.
static Type *FindType( const char * )
Sets the name of the type and calls RegisterName to it in a global map.
void SetName( const char * name )
The registered name of this type.
const char *Name() const
The next type in a NULL terminated chain of types to load in Type::LoadTypes.
Type *NextTypeToLoad() const
The first class in a NULL terminated chain of classes to load in the next Type::LoadTypes.
static Type *FirstTypeToLoad()
Serialize defines how objects represented by this type are serialized.
virtual void Serialize( const void * in, void * out, Reflector & reflector ) const
Casts a type represented by this Type to a void *, used by Serialize.
template<typename Type> static void *OpaqueCast( Type * ptr )
Casts a void * from OpaqueCast back to a Type.
template<typename T> static T *TranslucentCast( void * ptr )
Sets the factory function for this class.
void SetBasicOperations( unsigned size, unsigned alignment, void * (*construct)(void *), void * (*destruct)(void *) )
The size of the object represented by this class.
unsigned Size() const
The minimum required alignment of the object represented by this class.
unsigned Alignment() const
Constructs an instance of this type.
void *Construct( void * ) const
Destructs an instance of this type.
void *Destruct( void * ) const
Checks if the class is Abstract.
bool Abstract() const
Registers a cast from type from to this type.
void RegisterConversion( const Type * from, void (*)(void *, const void *) )
Checks if a cast from the specified type exists.
virtual bool CanConvertFrom( const Type * from ) const
Checks if a cast from the specified type exists.
template<typename T> bool CanConvertFrom() const
Uses conversions registered with RegisterConversion.
virtual bool ConvertValue( void * opaque, const void * source, const Type * from ) const
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
Template base class for description helpers, used in reflection definitions.
template<typename T> class Type::DescriptionHelper