![Logo](../../logo.png) |
Elm
2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
|
21 #ifndef ELM_RTTI_CLASS_H_
22 #define ELM_RTTI_CLASS_H_
24 #include <elm/data/List.h>
25 #include <elm/data/Vector.h>
26 #include <elm/dyndata/Collection.h>
27 #include <elm/util/Variant.h>
35 template <
class T>
struct _type<dyndata::AbstractIter<T> >
36 {
static inline const Type&
_(
void) {
return *
static_cast<const Type *
>(
nullptr); } };
91 template <
class C,
class O>
93 typedef typename C::t t;
95 typedef const C& (O::*
fun_t)(
void)
const;
98 const O *o =
static_cast<const O *
>(args[0].asPointer());
105 template <
class T,
class I,
class O>
111 const O *o =
static_cast<const O *
>(args[0].asPointer());
123 template <
class T,
class T1>
131 template <
class T,
class T1,
class T2>
152 template <
class T,
class T1>
163 template <
class T,
class T1,
class T2>
175 template <
class T,
class C>
187 template <
class T,
class C>
199 template <
class T,
class C,
class T1>
212 template <
class T,
class C,
class T1>
224 template <
class T,
class C,
class T1,
class T2>
inline Variant __call_method2(T (C::*f)(T1, T2), C *o, T1 a1, T2 a2) {
return Variant((o->*f)(a1, a2)); }
225 template <
class T,
class C,
class T1,
class T2>
238 template <
class T,
class C,
class T1,
class T2>
241 typedef T (C::*
fun_t)(T1, T2)
const;
276 template <
class C,
class O>
inline make&
coll(
cstring name,
const C& (O::*f)(
void)
const)
299 virtual void free(
void *obj)
const = 0;
301 virtual bool isClass(
void)
const;
303 virtual void *
upCast(
void *ptr)
const;
304 virtual void *
downCast(
void *ptr)
const;
310 inline const void *
upCast(
const void *ptr)
const {
return upCast(
const_cast<void *
>(ptr)); }
311 inline const void *
downCast(
const void *ptr)
const {
return downCast(
const_cast<void *
>(ptr)); }
328 int count(
void)
const override;
340 template <
class T>
inline instantiate&
add(
void) { _params.add(&type_of<T>());
return *
this; }
358 static inline T *
_(
void) {
return nullptr; }
363 static inline T *
_(
void) {
return new T; }
364 static inline void _free(
void *
p) {
delete static_cast<T*
>(
p); }
367 template <
class T,
class B =
void,
template <
class _ >
class I = inst>
373 void free(
void *obj)
const override { I<T>::_free(obj); }
374 void *
upCast(
void *ptr)
const override {
return static_cast<B *
>(
static_cast<T *
>(ptr)); }
375 void *
downCast(
void *ptr)
const override {
return static_cast<T *
>(
static_cast<B *
>(ptr)); }
387 #define ELM_IS_CLASS_EXTEND(name, base) \
389 typedef base __base; \
390 static elm::rtti::Class<name, base> __type; \
391 const elm::rtti::Type& getType(void) const override; \
394 #define ELM_CLASS_EXTEND(name, base) \
395 class name: public base { \
396 ELM_IS_CLASS_EXTEND(name, base)
398 #define ELM_IS_CLASS(name) \
400 typedef void __base; \
401 static elm::rtti::Class<name, void> __type; \
402 const elm::rtti::Type& getType(void) const override; \
405 #define ELM_CLASS(name) \
406 class name: public elm::rtti::Object { \
409 #define ELM_END_CLASS };
411 #define ELM_IMPLEMENT(name) \
412 elm::rtti::Class<name, typename name::__base> name::__type(#name); \
413 const elm::rtti::Type& name::getType(void) const { return __type; }
415 #ifndef ELM_NO_SHORTCUT
416 # define IS_CLASS_EXTEND(name, base) ELM_IS_CLASS_EXTEND(name, base)
417 # define CLASS_EXTEND(name, base) ELM_CLASS_EXTEND(name, base)
418 # define IS_CLASS(name) ELM_IS_CLASS(name)
419 # define CLASS(name) ELM_CLASS(name)
420 # define END_CLASS ELM_END_CLASS
421 # define IMPLEMENT(name) ELM_IMPLEMENT(name)
virtual const Tuple * toTuple() const
Definition: rtti.cpp:958
Variant __call_static0(void(*f)(void))
Definition: Class.h:139
Variant call(const Vector< Variant > &args) const override
Definition: Class.h:156
Variant __call_method0_const(void(C::*f)(void) const, const C *o)
Definition: Class.h:185
string name(void) const
Definition: Type.h:91
void * downCast(void *ptr) const override
Definition: Class.h:375
void * upCast(void *ptr, const AbstractClass &cls) const
Definition: Class.h:377
Method2Const(cstring name, fun_t f)
Definition: Class.h:242
virtual void * upCast(void *ptr) const
Definition: rtti.cpp:937
@ CONSTRUCTOR
Definition: Class.h:55
Printable< T, M > p(const T &data, const M &man)
Definition: Output.h:302
Method0(cstring name, fun_t f)
Definition: Class.h:179
Iterator(cstring name)
Definition: Class.h:85
virtual ~Operation(void)
Definition: rtti.cpp:1377
instantiate(const TemplateClass &temp)
Definition: Class.h:339
Static2(cstring name, T(*f)(T1, T2))
Definition: Class.h:166
T(C::* fun_t)(T1, T2)
Definition: Class.h:228
static void _free(void *p)
Definition: Class.h:364
make & op(cstring name, T(*f)(void))
Definition: Class.h:264
const void * downCast(const void *ptr, const AbstractClass &cls) const
Definition: Class.h:313
make & extend(void)
Definition: Class.h:255
Method1Const(cstring name, fun_t f)
Definition: Class.h:216
@ NONE
Definition: Class.h:54
@ ITER
Definition: Class.h:58
const void * downCast(const void *ptr) const
Definition: Class.h:311
void add(const Parameter ¶m)
Definition: rtti.cpp:1405
cstring name(void) const
Definition: Class.h:66
const InstanceType * asInstance(void) const override
Definition: rtti.cpp:1052
make & add(Operation *op)
Definition: Class.h:258
make & extend(const Type &base)
Definition: Class.h:257
static T * _(void)
Definition: Class.h:358
kind_t kind(void) const
Definition: Class.h:65
T(C::* fun_t)(void)
Definition: Class.h:178
Static0(cstring name, T(*f)(void))
Definition: Class.h:144
Definition: Collection.h:30
IntFormat base(int base, IntFormat fmt)
Definition: Output.h:256
T(C::* fun_t)(T1, T2) const
Definition: Class.h:241
Parameter(void)
Definition: Class.h:41
Variant call(const Vector< Variant > &args) const override
Definition: Class.h:136
make & op(cstring name, T(C::*f)(T1))
Definition: Class.h:269
Constructor1(cstring name)
Definition: Class.h:126
virtual Variant call(const Vector< Variant > &args) const
Definition: rtti.cpp:1399
const TemplateType * asTemplate(void) const override
Definition: rtti.cpp:1023
Variant call(const Vector< Variant > &args) const override
Definition: Class.h:180
virtual const AbstractClass & asClass(void) const
Definition: rtti.cpp:927
make & op(cstring name, T(C::*f)(T1, T2))
Definition: Class.h:270
CollectionIterator(cstring name, fun_t fun)
Definition: Class.h:96
IntFormat pointer(const void *p)
Definition: io_Output.cpp:871
const List< Operation * > & operations(void) const
Definition: Class.h:315
make & iter(cstring name)
Definition: Class.h:278
make & coll(cstring name, const C &(O::*f)(void) const)
Definition: Class.h:276
cstring name(void) const
Definition: Class.h:44
virtual void * downCast(void *ptr) const
Definition: rtti.cpp:947
Constructor2(cstring name)
Definition: Class.h:134
instantiate & add(void)
Definition: Class.h:340
make & op(cstring name, T(C::*f)(void) const)
Definition: Class.h:272
const List< const Type * > params(void) const
Definition: Class.h:316
Method0Const(cstring name, fun_t f)
Definition: Class.h:191
const typedef C &(O::* fun_t)(void) const
Definition: Class.h:95
Constructor0(cstring name)
Definition: Class.h:119
make & op(cstring name, T(C::*f)(T1) const)
Definition: Class.h:273
Variant __call_method1(void(C::*f)(T1), C *o, T1 a1)
Definition: Class.h:197
void free(void *obj) const override
Definition: Class.h:373
Variant call(const Vector< Variant > &args) const override
Definition: Class.h:168
const Type & void_type
Definition: type_of.h:45
Parameter(const Type &type)
Definition: Class.h:42
Variant __call_method0(void(C::*f)(void), C *o)
Definition: Class.h:173
Method2(cstring name, fun_t f)
Definition: Class.h:229
const List< Parameter > & parameters(void) const
Definition: Class.h:68
Variant call(const Vector< Variant > &args) const override
Definition: Class.h:231
const rtti::Type & type_of(void)
Definition: type_of.h:77
AutoStringStartup & _
Definition: debug_CrashHandler.cpp:232
virtual void free(void *obj) const =0
Parameter(cstring name, const Type &type)
Definition: Class.h:43
Class(const make &m)
Definition: Class.h:371
make & op(cstring name, T(C::*f)(T1, T2) const)
Definition: Class.h:274
Variant __call_static2(void(*f)(T1, T2), T1 a1, T2 a2)
Definition: Class.h:161
const Type & type(void) const
Definition: Class.h:45
Method1(cstring name, fun_t f)
Definition: Class.h:203
const void * upCast(const void *ptr) const
Definition: Class.h:310
TemplateClass(int count, make &make)
Definition: rtti.cpp:1018
void * upCast(void *ptr) const override
Definition: Class.h:374
virtual void * instantiate(void) const =0
void * downCast(void *ptr, const AbstractClass &cls) const
Definition: Class.h:378
T(C::* fun_t)(T1) const
Definition: Class.h:215
@ METHOD
Definition: Class.h:56
Variant call(const Vector< Variant > &args) const override
Definition: Class.h:97
const void * upCast(const void *ptr, const AbstractClass &cls) const
Definition: Class.h:312
make & construct(cstring name)
Definition: Class.h:261
const void * downCast(const void *ptr, const AbstractClass &cls) const
Definition: Class.h:382
Variant __call_method1_const(void(C::*f)(T1) const, const C *o, T1 a1)
Definition: Class.h:210
make & op(cstring name, T(*f)(T1))
Definition: Class.h:265
virtual bool isClass(void) const
Definition: rtti.cpp:921
Variant __call_static1(void(*f)(T1), T1 a1)
Definition: Class.h:150
Variant __call_method2_const(void(C::*f)(T1, T2) const, const C *o, T1 a1, T2 a2)
Definition: Class.h:236
Operation(kind_t kind, cstring name, const Type &rtype=void_type)
Definition: rtti.cpp:1365
const void * downCast(const void *ptr) const
Definition: Class.h:380
Static1(cstring name, T(*f)(T1))
Definition: Class.h:155
make & construct(cstring name)
Definition: Class.h:262
const AbstractClass & base(void) const
Definition: Class.h:297
Class(CString name, const AbstractClass &base=type_of< B >().asClass())
Definition: Class.h:370
make & op(cstring name, T(C::*f)(void))
Definition: Class.h:268
bool baseOf(const AbstractClass *clazz)
Definition: rtti.cpp:910
const void * upCast(const void *ptr) const
Definition: Class.h:379
Variant call(const Vector< Variant > &args) const override
Definition: Class.h:110
Variant call(const Vector< Variant > &args) const override
Definition: Class.h:145
const List< const Type * > params(void) const override
Definition: rtti.cpp:1064
Variant call(const Vector< Variant > &args) const override
Definition: Class.h:192
kind_t
Definition: Class.h:53
AbstractClass(CString name, const AbstractClass &base)
Definition: rtti.cpp:863
Variant call(const Vector< Variant > &args) const override
Definition: Class.h:218
static T * _(void)
Definition: Class.h:363
Variant call(const Vector< Variant > &args) const override
Definition: Class.h:120
Variant call(const Vector< Variant > &args) const override
Definition: Class.h:244
IterIterator(cstring name)
Definition: Class.h:109
make & op(cstring name, T(*f)(T1, T2))
Definition: Class.h:266
const Type & templ(void) const override
Definition: rtti.cpp:1058
make(cstring name)
Definition: Class.h:254
int count(void) const override
Definition: rtti.cpp:1029
Variant call(const Vector< Variant > &args) const override
Definition: Class.h:128
@ STATIC
Definition: Class.h:57
Variant call(const Vector< Variant > &args) const override
Definition: Class.h:205
T(C::* fun_t)(void) const
Definition: Class.h:190
const Type & returnType(void) const
Definition: Class.h:67
static void _free(void *p)
Definition: Class.h:359
T(C::* fun_t)(T1)
Definition: Class.h:202
Variant __call_method2(void(C::*f)(T1, T2), C *o, T1 a1, T2 a2)
Definition: Class.h:223
InstanceClass(const make &m, const instantiate &i)
Definition: rtti.cpp:1046
make & construct(cstring name)
Definition: Class.h:260
make & extend(const AbstractClass &base)
Definition: Class.h:256
const void * upCast(const void *ptr, const AbstractClass &cls) const
Definition: Class.h:381
const Type & itemType(void) const
Definition: Class.h:86
static const Type & _(void)
Definition: Class.h:36
void * instantiate(void) const override
Definition: Class.h:372