![]() |
http://www.sim.no http://www.coin3d.org |
00001 /**************************************************************************\ 00002 * 00003 * This file is part of the Coin 3D visualization library. 00004 * Copyright (C) 1998-2005 by Systems in Motion. All rights reserved. 00005 * 00006 * This library is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License 00008 * ("GPL") version 2 as published by the Free Software Foundation. 00009 * See the file LICENSE.GPL at the root directory of this source 00010 * distribution for additional information about the GNU GPL. 00011 * 00012 * For using Coin with software that can not be combined with the GNU 00013 * GPL, and for taking advantage of the additional benefits of our 00014 * support services, please contact Systems in Motion about acquiring 00015 * a Coin Professional Edition License. 00016 * 00017 * See <URL:http://www.coin3d.org/> for more information. 00018 * 00019 * Systems in Motion, Postboks 1283, Pirsenteret, 7462 Trondheim, NORWAY. 00020 * <URL:http://www.sim.no/>. 00021 * 00022 \**************************************************************************/ 00023 00024 #ifndef SOQTOBJECT_H 00025 #define SOQTOBJECT_H 00026 00027 #include <assert.h> 00028 00029 #include <Inventor/SbBasic.h> 00030 #include <Inventor/SbString.h> 00031 #include <Inventor/SoType.h> 00032 00033 #include <Inventor/Qt/SoQtBasic.h> 00034 00035 // ************************************************************************* 00036 00037 class SOQT_DLL_API SoQtObject { 00038 static SoType classTypeId; 00039 00040 public: 00041 static void initClass(void); 00042 static SoType getClassTypeId(void); 00043 virtual SoType getTypeId(void) const = 0; 00044 SbBool isOfType(SoType type) const; 00045 00046 static void init(void); 00047 00048 }; // SoQtObject 00049 00050 // ************************************************************************* 00051 00052 // For a discussion about this #define, see Coin's SbBasic.h. 00053 00054 #define SOQT_SUN_CC_4_0_SOTYPE_INIT_BUG 0 /* assume compiler is ok for now */ 00055 00056 #if SOQT_SUN_CC_4_0_SOTYPE_INIT_BUG 00057 #define SOQT_STATIC_SOTYPE_INIT 00058 #else 00059 #define SOQT_STATIC_SOTYPE_INIT = SoType::badType() 00060 #endif 00061 00062 // ************************************************************************* 00063 00064 // The getTypeId() method should be abstract for abstract objects, but doing 00065 // that would cause custom components derived from abstract components to 00066 // have to include the typed object header / source, which could be a 00067 // problem if the custom component wasn't written for Coin in the first 00068 // place. 00069 00070 #define SOQT_OBJECT_ABSTRACT_HEADER(classname, parentname) \ 00071 public: \ 00072 static void initClass(void); \ 00073 static SoType getClassTypeId(void); \ 00074 virtual SoType getTypeId(void) const /* = 0 (see comment above) */; \ 00075 private: \ 00076 typedef parentname inherited; \ 00077 static SoType classTypeId 00078 00079 #define SOQT_OBJECT_HEADER(classname, parentname) \ 00080 public: \ 00081 static void initClass(void); \ 00082 static SoType getClassTypeId(void); \ 00083 virtual SoType getTypeId(void) const; \ 00084 static void * createInstance(void); \ 00085 private: \ 00086 typedef parentname inherited; \ 00087 static SoType classTypeId 00088 00089 #define SOQT_OBJECT_ABSTRACT_SOURCE(classname) \ 00090 void classname::initClass(void) { \ 00091 assert(classname::classTypeId == SoType::badType()); \ 00092 classname::classTypeId = \ 00093 SoType::createType(inherited::getClassTypeId(), \ 00094 SO__QUOTE(classname)); \ 00095 } \ 00096 SoType classname::getClassTypeId(void) { \ 00097 return classname::classTypeId; \ 00098 } \ 00099 SoType classname::getTypeId(void) const { \ 00100 return classname::classTypeId; \ 00101 } \ 00102 SoType classname::classTypeId SOQT_STATIC_SOTYPE_INIT 00103 00104 #define SOQT_OBJECT_SOURCE(classname) \ 00105 void classname::initClass(void) { \ 00106 assert(classname::classTypeId == SoType::badType()); \ 00107 classname::classTypeId = \ 00108 SoType::createType(inherited::getClassTypeId(), \ 00109 SO__QUOTE(classname), \ 00110 classname::createInstance); \ 00111 } \ 00112 SoType classname::getClassTypeId(void) { \ 00113 return classname::classTypeId; \ 00114 } \ 00115 SoType classname::getTypeId(void) const { \ 00116 return classname::classTypeId; \ 00117 } \ 00118 void * classname::createInstance(void) { \ 00119 assert(classname::classTypeId != SoType::badType()); \ 00120 return (void *) new classname; \ 00121 } \ 00122 SoType classname::classTypeId SOQT_STATIC_SOTYPE_INIT 00123 00124 // ************************************************************************* 00125 00126 #endif // ! SOQTOBJECT_H
Copyright © 1998-2005 by Systems in Motion AS. All rights reserved.
Generated on Mon Mar 27 00:38:51 2006 for SoQt by Doxygen. 1.4.6