Coin Logo http://www.sim.no
http://www.coin3d.org

SoQtObject.h

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

Copyright © 1998-2005 by Systems in Motion AS. All rights reserved.

Generated on Sun Oct 24 2010 13:18:00 for SoQt by Doxygen. 1.7.1