Elm  2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
AbstractClass Class Referenceabstract

#include <elm/rtti/Class.h>

+ Inheritance diagram for AbstractClass:

Public Member Functions

 AbstractClass (CString name, const AbstractClass &base)
 
 AbstractClass (const make &m)
 
 AbstractClass (const make &m, const AbstractClass &base)
 
const AbstractClassbase (void) const
 
virtual voidinstantiate (void) const =0
 
virtual void free (void *obj) const =0
 
bool baseOf (const AbstractClass *clazz)
 
virtual bool isClass (void) const
 
virtual const AbstractClassasClass (void) const
 
virtual voidupCast (void *ptr) const
 
virtual voiddownCast (void *ptr) const
 
virtual const TupletoTuple () const
 
voidupCast (void *ptr, const AbstractClass &cls) const
 
voiddownCast (void *ptr, const AbstractClass &cls) const
 
const voidupCast (const void *ptr) const
 
const voiddownCast (const void *ptr) const
 
const voidupCast (const void *ptr, const AbstractClass &cls) const
 
const voiddownCast (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 PointerTypepointer (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 PointerTypeasPtr (void) const
 
virtual bool isEnum (void) const
 
virtual const EnumerableasEnum (void) const
 
virtual bool isSerial (void) const
 
virtual const SerializableasSerial (void) const
 
virtual const TemplateTypeasTemplate (void) const
 
virtual const InstanceTypeasInstance (void) const
 
virtual const ParamTypeasParam (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 Typeget (string name)
 
static TypeIter types (void)
 
- Static Public Attributes inherited from Type
static const Typeparam0
 
static const Typeparam1
 
static const Typeparam2
 
static const Typeparam3
 

Detailed Description

Abstract class to represent classes in RTTI. It is mainly used for serialization / deserialization.

Constructor & Destructor Documentation

◆ AbstractClass() [1/3]

AbstractClass ( CString  name,
const AbstractClass base 
)

Build the abstract class.

Parameters
nameClass named (fully qualified).
baseBase class (default none).

◆ AbstractClass() [2/3]

AbstractClass ( const make m)

Build a class using the maker.

Parameters
mMaker to use.

◆ AbstractClass() [3/3]

AbstractClass ( const make m,
const AbstractClass base 
)

Build a class using the maker.

Parameters
mMaker to use.
baseBase class.

Member Function Documentation

◆ asClass()

const AbstractClass & asClass ( void  ) const
virtual

Get the class description corresponding to this type. If the type is not a class, an assertion failure is raised.

Returns
Corresponding class instance.

Reimplemented from Type.

Referenced by make::extend().

◆ base()

AbstractClass * base ( void  ) const
inline

Get the parent class.

Returns
Parent class.

Referenced by AbstractClass::baseOf(), AbstractClass::downCast(), and AbstractClass::upCast().

◆ baseOf()

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.

Parameters
clazzClass to test.
Returns
True if this class is a base class, false else.

References AbstractClass::base().

◆ downCast() [1/4]

const void* downCast ( const void ptr) const
inline

◆ downCast() [2/4]

const void* downCast ( const void ptr,
const AbstractClass cls 
) const
inline

◆ downCast() [3/4]

void * downCast ( void ptr) const
virtual

Cast a pointer from the base type to the current type. Default implementation is the identity.

Parameters
ptrPointer to the base type.
Returns
Pointer to the current type.

Reimplemented in Class< T, B, I >.

Referenced by Class< T, B, I >::downCast().

◆ downCast() [4/4]

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.

Parameters
ptrPointer to the current type.
clsChild class of the current class, to cast to.
Returns
Pointer to class cls.

References Vector< T, E, A >::add(), AbstractClass::base(), Vector< T, E, A >::count(), and elm::rtti::void_type.

◆ free()

void free ( void obj) const
pure virtual

Free an object corresponding to the current class.

Parameters
objObject to free.

Implemented in ObjectClass, VoidType, Class< T, B, I >, Class< T, B >, and AbstractTuple< T >.

◆ instantiate()

void * instantiate ( void  ) const
pure virtual

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.

Returns
Allocated instance of class.

Implemented in ObjectClass, VoidType, Class< T, B, I >, AbstractTuple< T >, and Class< T, B >.

◆ isClass()

bool isClass ( void  ) const
virtual

Test if the type is a class. Default implementation return false.

Returns
True if the type is a class, false else.

Reimplemented from Type.

◆ operations()

const List<Operation *>& operations ( void  ) const
inline

◆ params()

const List<const Type *> params ( void  ) const
inline

◆ toTuple()

const Tuple * toTuple ( ) const
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.

Returns
Value class interface, or null.

Reimplemented in AbstractTuple< T >.

◆ upCast() [1/4]

const void* upCast ( const void ptr) const
inline

◆ upCast() [2/4]

const void* upCast ( const void ptr,
const AbstractClass cls 
) const
inline

◆ upCast() [3/4]

void * upCast ( void ptr) const
virtual

Cast a pointer from the current to the base type of this type. Default implementation is the identity.

Parameters
ptrPointer to the current type.
Returns
Pointer to the base type.

Reimplemented in Class< T, B, I >.

Referenced by AbstractClass::upCast(), and Class< T, B, I >::upCast().

◆ upCast() [4/4]

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.

Parameters
ptrCurrent class pointer.
clsBase class of the current class, to cast to.
Returns
cls class pointer.

References AbstractClass::base(), AbstractClass::upCast(), and elm::rtti::void_type.


The documentation for this class was generated from the following files: