BaseClass.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef BASE_BASECLASS_H
00025 #define BASE_BASECLASS_H
00026
00027 #include "Type.h"
00028
00029
00030 typedef struct _object PyObject;
00031
00032
00034 #define TYPESYSTEM_HEADER() \
00035 public: \
00036 static Base::Type getClassTypeId(void); \
00037 virtual Base::Type getTypeId(void) const; \
00038 static void init(void);\
00039 static void *create(void);\
00040 private: \
00041 static Base::Type classTypeId
00042
00043
00044
00045
00047 #define TYPESYSTEM_SOURCE_P(_class_) \
00048 Base::Type _class_::getClassTypeId(void) { return _class_::classTypeId; } \
00049 Base::Type _class_::getTypeId(void) const { return _class_::classTypeId; } \
00050 Base::Type _class_::classTypeId = Base::Type::badType(); \
00051 void * _class_::create(void){\
00052 return new _class_ ();\
00053 }
00054
00056 #define TYPESYSTEM_SOURCE_ABSTRACT_P(_class_) \
00057 Base::Type _class_::getClassTypeId(void) { return _class_::classTypeId; } \
00058 Base::Type _class_::getTypeId(void) const { return _class_::classTypeId; } \
00059 Base::Type _class_::classTypeId = Base::Type::badType(); \
00060 void * _class_::create(void){return 0;}
00061
00062
00064 #define TYPESYSTEM_SOURCE(_class_, _parentclass_) \
00065 TYPESYSTEM_SOURCE_P(_class_);\
00066 void _class_::init(void){\
00067 initSubclass(_class_::classTypeId, #_class_ , #_parentclass_, &(_class_::create) ); \
00068 }
00069
00071 #define TYPESYSTEM_SOURCE_ABSTRACT(_class_, _parentclass_) \
00072 TYPESYSTEM_SOURCE_ABSTRACT_P(_class_);\
00073 void _class_::init(void){\
00074 initSubclass(_class_::classTypeId, #_class_ , #_parentclass_, &(_class_::create) ); \
00075 }
00076
00077 namespace Base
00078 {
00080 class BaseExport BaseClass
00081 {
00082 public:
00083 static Type getClassTypeId(void);
00084 virtual Type getTypeId(void) const;
00085 bool isDerivedFrom(const Type type) const {return getTypeId().isDerivedFrom(type);}
00086
00087 static void init(void);
00088
00089 virtual PyObject *getPyObject(void);
00090 virtual void setPyObject(PyObject *);
00091
00092 static void *create(void){return 0;}
00093 private:
00094 static Type classTypeId;
00095 protected:
00096 static void initSubclass(Base::Type &toInit,const char* ClassName, const char *ParentName, Type::instantiationMethod method=0);
00097
00098 public:
00100 BaseClass();
00102 virtual ~BaseClass();
00103
00104 };
00105
00106
00107
00108
00109
00110 }
00111
00112 #endif // BASE_BASECLASS_H
00113