Go to the documentation of this file.
13#ifndef ML_RUNTIME_SUB_CLASS_H
14#define ML_RUNTIME_SUB_CLASS_H
32#define ML_BASE_IS_A(base,type) ((base && base->getTypeId()) ? base->getTypeId()->isDerivedFrom(type::getClassTypeId()) : false)
42#define ML_INTERNAL_CLASS_HEADER_CREATECB(EXP_SYM) \
46 EXP_SYM static void* createCB(); \
49#define ML_INTERNAL_CLASS_HEADER_EXPORTED(className, EXP_SYM, ML_INTERNAL_VIRTUAL, ML_INTERNAL_OVERRIDE) \
59 EXP_SYM static void initClass(const char* classPrefix=nullptr, \
60 const char* nameReplacement=nullptr);\
63 EXP_SYM static void destroyClass(); \
66 EXP_SYM static const RuntimeType* getClassTypeId(); \
69 EXP_SYM ML_INTERNAL_VIRTUAL const RuntimeType* getTypeId() const ML_INTERNAL_OVERRIDE; \
75 EXP_SYM ML_INTERNAL_VIRTUAL const char* getTypeIdName() const ML_INTERNAL_OVERRIDE; \
80 static const RuntimeType* _classType;
90#define ML_CLASS_HEADER_EXPORTED(className, EXP_SYM) \
91 ML_INTERNAL_CLASS_HEADER_EXPORTED(className, EXP_SYM, ML_EMPTY_PARAM, override) \
92 ML_INTERNAL_CLASS_HEADER_CREATECB(EXP_SYM)
98#define ML_CLASS_HEADER(className) \
99 ML_INTERNAL_CLASS_HEADER_EXPORTED(className, ML_EMPTY_PARAM, ML_EMPTY_PARAM, override) \
100 ML_INTERNAL_CLASS_HEADER_CREATECB(ML_EMPTY_PARAM)
102#define ML_ROOT_CLASS_HEADER(className) \
103 ML_INTERNAL_CLASS_HEADER_EXPORTED(className, ML_EMPTY_PARAM, virtual, ML_EMPTY_PARAM) \
104 ML_INTERNAL_CLASS_HEADER_CREATECB(ML_EMPTY_PARAM)
106#define ML_INTERNAL_CLASS_SOURCE(className,parentName,createCB) \
112const RuntimeType* className::_classType = nullptr; \
122void className::initClass(const char* classPrefix, \
123 const char* nameReplacement) \
125 _classType = Runtime::initType(_classType, \
133void className::destroyClass() \
135 Runtime::destroyType(#className); \
139const RuntimeType* className::getClassTypeId() \
145const RuntimeType* className::getTypeId() const \
154const char* className::getTypeIdName() const \
156 return Runtime::_getCheckedTypeIdName(_classType, #className); \
159#define ML_INTERNAL_CLASS_CREATECB(className) \
161void* className::createCB() \
163 return new className(); \
174#define ML_CLASS_SOURCE(className,parentName) \
175 ML_INTERNAL_CLASS_SOURCE(className,parentName, className::createCB) \
176 ML_INTERNAL_CLASS_CREATECB(className)
184#define ML_ROOT_CLASS_SOURCE(className) \
185 ML_CLASS_SOURCE(className,)
194#define ML_ABSTRACT_CLASS_HEADER_EXPORTED(className, EXP_SYM) \
195 ML_INTERNAL_CLASS_HEADER_EXPORTED(className, EXP_SYM, ML_EMPTY_PARAM, override)
202#define ML_ABSTRACT_CLASS_HEADER(className) \
203 ML_INTERNAL_CLASS_HEADER_EXPORTED(className, ML_EMPTY_PARAM, ML_EMPTY_PARAM, override)
205#define ML_ABSTRACT_ROOT_CLASS_HEADER(className) \
206 ML_INTERNAL_CLASS_HEADER_EXPORTED(className, ML_EMPTY_PARAM, virtual , ML_EMPTY_PARAM)
215#define ML_ABSTRACT_CLASS_SOURCE(className,parentName) \
216 ML_INTERNAL_CLASS_SOURCE(className,parentName, nullptr) \
224#define ML_ABSTRACT_ROOT_CLASS_SOURCE(className) \
225 ML_ABSTRACT_CLASS_SOURCE(className,)
235#define ML_MODULE_CLASS_HEADER(className) \
237 ML_CLASS_HEADER(className) \
240 private: className(const className&); \
243 private: className& operator=(const className&); \
254#define ML_MODULE_CLASS_SOURCE(className, parentName) \
256 ML_CLASS_SOURCE(className, parentName)
265#define ML_ABSTRACT_MODULE_CLASS_HEADER(className) \
267 ML_ABSTRACT_CLASS_HEADER(className) \
270 private: className(const className&); \
273 private: className& operator=(const className&); \
284#define ML_ABSTRACT_MODULE_CLASS_SOURCE(className, parentName) \
286 ML_ABSTRACT_CLASS_SOURCE(className, parentName)
294#define ML_MODULE_CLASS_SOURCE_EXT(className, parentName, superClassConstructs) \
296 ML_CLASS_SOURCE(className, parentName)
304#define ML_ABSTRACT_MODULE_CLASS_SOURCE_EXT(className, parentName, superClassConstructs) \
306 ML_ABSTRACT_CLASS_SOURCE(className, parentName)