Elm
2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
|
This module provides information for type at run-time. It may be used for very different purposes as: More...
Classes | |
class | VoidType |
class | Enumerable |
class | Serializable |
class | Type |
class | ParamType |
class | TemplateType |
class | InstanceType |
class | Tuple |
class | AbstractClass |
class | TemplateClass |
class | InstanceClass |
class | ObjectType |
class | Class< T, B, I > |
class | Enum |
Macros | |
#define | IS_CLASS_EXTEND(name, base) ELM_IS_CLASS_EXTEND(name, base) |
#define | IS_CLASS(name) ELM_IS_CLASS(name) |
#define | CLASS_EXTEND(name, base) ELM_CLASS_EXTEND(name, base) |
#define | CLASS(name) ELM_CLASS(name) |
#define | END_CLASS ELM_END_CLASS |
#define | IMPLEMENT(name) ELM_IMPLEMENT(name) |
#define | DECLARE_ENUM(name) ELM_DECLARE_ENUM(name) |
#define | DEFINE_ENUM(type, desc) ELM_DEFINE_ENUM (type, desc) |
#define | BEGIN_ENUM(type) ELM_BEGIN_ENUM(type) |
#define | END_ENUM ELM_END_ENUM |
Functions | |
template<class T > | |
const rtti::Type & | type_of (void) |
Variables | |
const Type & | int8_type = single<IntType<t::int8> >() |
const Type & | uint8_type = single<IntType<t::uint8> >() |
const Type & | int16_type = single<IntType<t::int16> >() |
const Type & | uint16_type = single<IntType<t::uint16> >() |
const Type & | int32_type = single<IntType<t::int32> >() |
const Type & | uint32_type = single<IntType<t::uint32> >() |
const Type & | int64_type = single<IntType<t::int64> >() |
const Type & | uint64_type = single<IntType<t::uint64> >() |
const Type & | float_type = single<FloatType<float> >() |
const Type & | double_type = single<FloatType<double> >() |
const Type & | long_double_type = single<FloatType<long double> >() |
const Type & | bool_type = single<BoolType>() |
const Type & | string_type = single<StringType>() |
const Type & | void_type = single<VoidType>() |
const Type & | cstring_type = single<CStringType>() |
This module provides information for type at run-time. It may be used for very different purposes as:
For each type, it can provide a Type descriptor that includes:
This module provides several specializations for the different possible types:
Additionally, you can use the type_of<T>() function to get the RTTI type instance representing a type.
Basically, it is as easy as declaring a global variable for the class and linking it to the type_of<T>() function:
To avoid the ugly line, you can declare type instance as a static member of the class (the elm::type_of() function will find it automatically):
Another possibility is to use the integrated macros of RTTI system:
If your class is extending another RTTI class, you will use instead:
And that's it.
Providing RTTI for enumration provides several benefits:
In the header file, you have to declare your enumeration following by a call to macro DECLARE_ENUM:
Then you have to create in the source the instance of type representing the enumeration followed by a call to macro DEFINE_ENUM:
#define BEGIN_ENUM | ( | type | ) | ELM_BEGIN_ENUM(type) |
#include <include/elm/rtti/Enum.h>
Build the type instance representing an enumeration type. Must be followed by the declaration of values of the type and aliases as in Enum::make and ended by END_ENUM.
type | Enumeration type itself. |
#define CLASS | ( | name | ) | ELM_CLASS(name) |
#include <include/elm/rtti/Class.h>
All-in-one declaration macro for a class recorded in RTTI. It substitutes to the class
keyword and the class definition must be ended by END_CLASS.
name | Name of the class. |
#define CLASS_EXTEND | ( | name, | |
base | |||
) | ELM_CLASS_EXTEND(name, base) |
#include <include/elm/rtti/Class.h>
All-in-one declaration macro for a class recorded in RTTI. It substitutes to the class
keyword and the class definition must be ended by END_CLASS.
name | Name of the class. |
base | Base class. |
#define DECLARE_ENUM | ( | name | ) | ELM_DECLARE_ENUM(name) |
#include <include/elm/rtti/Enum.h>
Declare an enumeration as supported by RTTI. Must be put just after the enumeration declaration in the header file.
name | Enumeration type name. |
#define DEFINE_ENUM | ( | type, | |
desc | |||
) | ELM_DEFINE_ENUM (type, desc) |
#include <include/elm/rtti/Enum.h>
Define the instance of type for an enumeration type. Must be put in a source file.
type | The enumeration type. |
desc | The instance of type describing the enumeration type. |
#define END_CLASS ELM_END_CLASS |
#include <include/elm/rtti/Class.h>
Ends the declaration of a RTTI class declared by CLASS or CLASS_EXTEND.
#define END_ENUM ELM_END_ENUM |
#include <include/elm/rtti/Enum.h>
End the definition of the type instance of an enumeration type. Must follow a BEGIN_ENUM.
#define IMPLEMENT | ( | name | ) | ELM_IMPLEMENT(name) |
#include <include/elm/rtti/Class.h>
Provide the implementation of a RTTI class. Must be put in the source file of the class.
name | Name of the class. |
#define IS_CLASS | ( | name | ) | ELM_IS_CLASS(name) |
#include <include/elm/rtti/Class.h>
Generate the content of a class to record it in the RTTI database.
name | Name of the class. |
#define IS_CLASS_EXTEND | ( | name, | |
base | |||
) | ELM_IS_CLASS_EXTEND(name, base) |
#include <include/elm/rtti/Class.h>
Generate the content of a class to record it in the RTTI database.
name | Name of the class. |
base | Base of the class. |
|
inline |
#include <include/elm/rtti/type_of.h>
Get the instance type corresponding to the given type. Retrieve automatically the type for scalar and pointer or for any specialization of type_of(). For class types, look for the static __type
member.
T | Type an instance is looked for. |
References _type< T >::_().
const Type & cstring_type = single<CStringType>() |
#include <include/elm/rtti/type_of.h>
Type for double-precision floating-point real.
Referenced by _type< T >::_().
#include <include/elm/rtti/type_of.h>
Type for single-precision floating-point real.
Referenced by _type< T >::_().
#include <include/elm/rtti/type_of.h>
Type for signed 16-bit integer.
Referenced by _type< T >::_().
#include <include/elm/rtti/type_of.h>
Type for signed 32-bit integer.
Referenced by _type< T >::_().
#include <include/elm/rtti/type_of.h>
Type for signed 64-bit integer.
Referenced by _type< T >::_().
#include <include/elm/rtti/type_of.h>
Type for quadruple-precision floating-point real.
Referenced by _type< T >::_().
const Type & string_type = single<StringType>() |
#include <include/elm/rtti/type_of.h>
Type for unsigned 8-bit integer.
Referenced by _type< T >::_().
#include <include/elm/rtti/type_of.h>
Type for unsigned 32-bit integer.
Referenced by _type< T >::_().
#include <include/elm/rtti/type_of.h>
Type for unsigned 64-bit integer.
Referenced by _type< T >::_().
#include <include/elm/rtti/type_of.h>
Type for unsigned 8-bit integer.
Referenced by _type< T >::_().
#include <include/elm/rtti/type_of.h>
Void type representation.
Referenced by _type< T >::_(), AbstractClass::downCast(), and AbstractClass::upCast().