BaseClass.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (c) Riegel         <juergen.riegel@web.de>                  *
00003  *                                                                         *
00004  *   This file is part of the FreeCAD CAx development system.              *
00005  *                                                                         *
00006  *   This library is free software; you can redistribute it and/or         *
00007  *   modify it under the terms of the GNU Library General Public           *
00008  *   License as published by the Free Software Foundation; either          *
00009  *   version 2 of the License, or (at your option) any later version.      *
00010  *                                                                         *
00011  *   This library  is distributed in the hope that it will be useful,      *
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00014  *   GNU Library General Public License for more details.                  *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU Library General Public     *
00017  *   License along with this library; see the file COPYING.LIB. If not,    *
00018  *   write to the Free Software Foundation, Inc., 59 Temple Place,         *
00019  *   Suite 330, Boston, MA  02111-1307, USA                                *
00020  *                                                                         *
00021  ***************************************************************************/
00022 
00023 
00024 #ifndef BASE_BASECLASS_H
00025 #define BASE_BASECLASS_H
00026 
00027 #include "Type.h"
00028 
00029 // Python stuff
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 } //namespace Base
00111 
00112 #endif // BASE_BASECLASS_H
00113 

Generated on Wed Nov 23 18:59:57 2011 for FreeCAD by  doxygen 1.6.1