Coin Logo http://www.coin3d.org/
http://www.kongsberg.com/kogt/

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  * Copyright (c) Kongsberg Oil & Gas Technologies AS
00008  * All rights reserved.
00009  * 
00010  * Redistribution and use in source and binary forms, with or without
00011  * modification, are permitted provided that the following conditions are
00012  * met:
00013  * 
00014  * Redistributions of source code must retain the above copyright notice,
00015  * this list of conditions and the following disclaimer.
00016  * 
00017  * Redistributions in binary form must reproduce the above copyright
00018  * notice, this list of conditions and the following disclaimer in the
00019  * documentation and/or other materials provided with the distribution.
00020  * 
00021  * Neither the name of the copyright holder nor the names of its
00022  * contributors may be used to endorse or promote products derived from
00023  * this software without specific prior written permission.
00024  * 
00025  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00026  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00027  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00028  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
00029  * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00030  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00031  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00032  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00033  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00034  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00035  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00036 \**************************************************************************/
00037 
00038 #include <assert.h>
00039 
00040 #include <Inventor/SbBasic.h>
00041 #include <Inventor/SbString.h>
00042 #include <Inventor/SoType.h>
00043 
00044 #include <Inventor/Qt/SoQtBasic.h>
00045 
00046 // *************************************************************************
00047 
00048 class SOQT_DLL_API SoQtObject {
00049   static SoType classTypeId;
00050 
00051 public:
00052   static void initClass(void);
00053   static SoType getClassTypeId(void);
00054   virtual SoType getTypeId(void) const = 0;
00055   SbBool isOfType(SoType type) const;
00056 
00057   static void init(void);
00058 
00059   // FIXME: gcc-4 generates a warning when a class has virtual functions 
00060   // but no virtual destructor. Currently this warning is suppressed using 
00061   // the -Wno-non-virtual-dtor option, but this should be addressed for the
00062   // next major version... 20060404 kyrah
00063 
00064 #if (SOQT_MAJOR_VERSION > 1)
00065 #error Resolve missing virtual destructor issue for the new major release!
00066 #endif
00067 
00068 }; // SoQtObject
00069 
00070 // *************************************************************************
00071 
00072 // For a discussion about this #define, see Coin's SbBasic.h.
00073 
00074 #define SOQT_SUN_CC_4_0_SOTYPE_INIT_BUG 0 /* assume compiler is ok for now */
00075 
00076 #if SOQT_SUN_CC_4_0_SOTYPE_INIT_BUG
00077 #define SOQT_STATIC_SOTYPE_INIT
00078 #else
00079 #define SOQT_STATIC_SOTYPE_INIT = SoType::badType()
00080 #endif
00081 
00082 // *************************************************************************
00083 
00084 // The getTypeId() method should be abstract for abstract objects, but doing
00085 // that would cause custom components derived from abstract components to
00086 // have to include the typed object header / source, which could be a
00087 // problem if the custom component wasn't written for Coin in the first
00088 // place.
00089 
00090 #define SOQT_OBJECT_ABSTRACT_HEADER(classname, parentname) \
00091 public: \
00092   static void initClass(void); \
00093   static SoType getClassTypeId(void); \
00094   virtual SoType getTypeId(void) const /* = 0 (see comment above) */; \
00095 private: \
00096   typedef parentname inherited; \
00097   static SoType classTypeId
00098 
00099 #define SOQT_OBJECT_HEADER(classname, parentname) \
00100 public: \
00101   static void initClass(void); \
00102   static SoType getClassTypeId(void); \
00103   virtual SoType getTypeId(void) const; \
00104   static void * createInstance(void); \
00105 private: \
00106   typedef parentname inherited; \
00107   static SoType classTypeId
00108 
00109 #define SOQT_OBJECT_ABSTRACT_SOURCE(classname) \
00110 void classname::initClass(void) { \
00111   assert(classname::classTypeId == SoType::badType()); \
00112   classname::classTypeId = \
00113     SoType::createType(inherited::getClassTypeId(), \
00114                         SO__QUOTE(classname)); \
00115 } \
00116 SoType classname::getClassTypeId(void) { \
00117   return classname::classTypeId; \
00118 } \
00119 SoType classname::getTypeId(void) const { \
00120   return classname::classTypeId; \
00121 } \
00122 SoType classname::classTypeId SOQT_STATIC_SOTYPE_INIT
00123 
00124 #define SOQT_OBJECT_SOURCE(classname) \
00125 void classname::initClass(void) { \
00126   assert(classname::classTypeId == SoType::badType()); \
00127   classname::classTypeId = \
00128     SoType::createType(inherited::getClassTypeId(), \
00129                         SO__QUOTE(classname), \
00130                         classname::createInstance); \
00131 } \
00132 SoType classname::getClassTypeId(void) { \
00133   return classname::classTypeId; \
00134 } \
00135 SoType classname::getTypeId(void) const { \
00136   return classname::classTypeId; \
00137 } \
00138 void * classname::createInstance(void) { \
00139   assert(classname::classTypeId != SoType::badType()); \
00140   return (void *) new classname; \
00141 } \
00142 SoType classname::classTypeId SOQT_STATIC_SOTYPE_INIT
00143 
00144 // *************************************************************************
00145 
00146 #endif // ! SOQTOBJECT_H

Copyright © by Kongsberg Oil & Gas Technologies. All rights reserved.

Generated on Wed Mar 2 2016 19:40:11 for SoQt by Doxygen 1.7.3.