Elm
2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
|
#include <elm/rtti/Class.h>
Public Member Functions | |
AbstractClass (CString name, const AbstractClass &base) | |
AbstractClass (const make &m) | |
AbstractClass (const make &m, const AbstractClass &base) | |
const AbstractClass & | base (void) const |
virtual void * | instantiate (void) const =0 |
virtual void | free (void *obj) const =0 |
bool | baseOf (const AbstractClass *clazz) |
virtual bool | isClass (void) const |
virtual const AbstractClass & | asClass (void) const |
virtual void * | upCast (void *ptr) const |
virtual void * | downCast (void *ptr) const |
virtual const Tuple * | toTuple () const |
void * | upCast (void *ptr, const AbstractClass &cls) const |
void * | downCast (void *ptr, const AbstractClass &cls) const |
const void * | upCast (const void *ptr) const |
const void * | downCast (const void *ptr) const |
const void * | upCast (const void *ptr, const AbstractClass &cls) const |
const void * | downCast (const void *ptr, const AbstractClass &cls) const |
const List< Operation * > & | operations (void) const |
const List< const Type * > | params (void) const |
Public Member Functions inherited from Type | |
Type (string name="") | |
virtual | ~Type (void) |
string | name (void) const |
const PointerType & | pointer (void) const |
virtual bool | canCast (const Type *t) const |
virtual bool | isVoid (void) const |
virtual bool | isBool (void) const |
virtual bool | isInt (void) const |
virtual bool | isFloat (void) const |
virtual bool | isPtr (void) const |
virtual const PointerType & | asPtr (void) const |
virtual bool | isEnum (void) const |
virtual const Enumerable & | asEnum (void) const |
virtual bool | isSerial (void) const |
virtual const Serializable & | asSerial (void) const |
virtual const TemplateType * | asTemplate (void) const |
virtual const InstanceType * | asInstance (void) const |
virtual const ParamType * | asParam (void) const |
void | initialize (void) |
bool | operator== (const Type &t) const |
bool | operator!= (const Type &t) const |
Additional Inherited Members | |
Public Types inherited from Type | |
typedef HashMap< string, const Type * >::Iter | TypeIter |
Static Public Member Functions inherited from Type | |
static const Type * | get (string name) |
static TypeIter | types (void) |
Static Public Attributes inherited from Type | |
static const Type & | param0 |
static const Type & | param1 |
static const Type & | param2 |
static const Type & | param3 |
Abstract class to represent classes in RTTI. It is mainly used for serialization / deserialization.
AbstractClass | ( | CString | name, |
const AbstractClass & | base | ||
) |
Build the abstract class.
name | Class named (fully qualified). |
base | Base class (default none). |
AbstractClass | ( | const make & | m | ) |
Build a class using the maker.
m | Maker to use. |
AbstractClass | ( | const make & | m, |
const AbstractClass & | base | ||
) |
Build a class using the maker.
m | Maker to use. |
base | Base class. |
|
virtual |
Get the class description corresponding to this type. If the type is not a class, an assertion failure is raised.
Reimplemented from Type.
Referenced by make::extend().
|
inline |
Get the parent class.
Referenced by AbstractClass::baseOf(), AbstractClass::downCast(), and AbstractClass::upCast().
bool baseOf | ( | const AbstractClass * | clazz | ) |
Test if the current class is base class of the given one. Notice that this class is a base class of clazz even if this class equals the class clazz.
clazz | Class to test. |
References AbstractClass::base().
References AbstractClass::downCast().
Referenced by AbstractClass::downCast().
|
inline |
References AbstractClass::downCast().
Referenced by AbstractClass::downCast().
Cast a pointer from the base type to the current type. Default implementation is the identity.
ptr | Pointer to the base type. |
Reimplemented in Class< T, B, I >.
Referenced by Class< T, B, I >::downCast().
void * downCast | ( | void * | ptr, |
const AbstractClass & | cls | ||
) | const |
Down cast a pointer in the current type to a pointer in cls type. If the current class is not a base class of the class cls, raises an assertion failure.
ptr | Pointer to the current type. |
cls | Child class of the current class, to cast to. |
References Vector< T, E, A >::add(), AbstractClass::base(), Vector< T, E, A >::count(), and elm::rtti::void_type.
Free an object corresponding to the current class.
obj | Object to free. |
Implemented in ObjectClass, VoidType, Class< T, B, I >, Class< T, B >, and AbstractTuple< T >.
Call this function to get a new allocated fresh object of the corresponding class. This function must be overridden to perform the actual allocation and the class must support constructor without any argument.
Implemented in ObjectClass, VoidType, Class< T, B, I >, AbstractTuple< T >, and Class< T, B >.
|
virtual |
Try to get the value interface of a tuple class. Class that can be considered as tuples are classes which identity (address) is not important. They are used as values as int, float, etc.
Reimplemented in AbstractTuple< T >.
References AbstractClass::upCast().
Referenced by AbstractClass::upCast().
|
inline |
References AbstractClass::upCast().
Referenced by AbstractClass::upCast().
Cast a pointer from the current to the base type of this type. Default implementation is the identity.
ptr | Pointer to the current type. |
Reimplemented in Class< T, B, I >.
Referenced by AbstractClass::upCast(), and Class< T, B, I >::upCast().
void * upCast | ( | void * | ptr, |
const AbstractClass & | cls | ||
) | const |
Convert ptr, pointer to the current type, to a pointer of type cls. Raise an assertion failure if cls is not a base class of the current class.
ptr | Current class pointer. |
cls | Base class of the current class, to cast to. |
References AbstractClass::base(), AbstractClass::upCast(), and elm::rtti::void_type.