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

Main Page | Modules | Class Hierarchy | Class List | File List | Class Members

SoQtObject.h

00001 /**************************************************************************\
00002  *
00003  *  This file is part of the Coin 3D visualization library.
00004  *  Copyright (C) 1998-2004 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, Teknobyen, Abels Gate 5, 7030 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 // The getTypeId() method should be abstract for abstract objects, but doing
00053 // that would cause custom components derived from abstract components to
00054 // have to include the typed object header / source, which could be a
00055 // problem if the custom component wasn't written for Coin in the first
00056 // place.
00057 
00058 #define SOQT_OBJECT_ABSTRACT_HEADER(classname, parentname) \
00059 public: \
00060   static void initClass(void); \
00061   static SoType getClassTypeId(void); \
00062   virtual SoType getTypeId(void) const /* = 0 (see comment above) */; \
00063 private: \
00064   typedef parentname inherited; \
00065   static SoType classTypeId
00066 
00067 #define SOQT_OBJECT_HEADER(classname, parentname) \
00068 public: \
00069   static void initClass(void); \
00070   static SoType getClassTypeId(void); \
00071   virtual SoType getTypeId(void) const; \
00072   static void * createInstance(void); \
00073 private: \
00074   typedef parentname inherited; \
00075   static SoType classTypeId
00076 
00077 #define SOQT_OBJECT_ABSTRACT_SOURCE(classname) \
00078 void classname::initClass(void) { \
00079   assert(classname::classTypeId == SoType::badType()); \
00080   classname::classTypeId = \
00081     SoType::createType(inherited::getClassTypeId(), \
00082                         SO__QUOTE(classname)); \
00083 } \
00084 SoType classname::getClassTypeId(void) { \
00085   return classname::classTypeId; \
00086 } \
00087 SoType classname::getTypeId(void) const { \
00088   return classname::classTypeId; \
00089 } \
00090 SoType classname::classTypeId
00091 
00092 #define SOQT_OBJECT_SOURCE(classname) \
00093 void classname::initClass(void) { \
00094   assert(classname::classTypeId == SoType::badType()); \
00095   classname::classTypeId = \
00096     SoType::createType(inherited::getClassTypeId(), \
00097                         SO__QUOTE(classname), \
00098                         classname::createInstance); \
00099 } \
00100 SoType classname::getClassTypeId(void) { \
00101   return classname::classTypeId; \
00102 } \
00103 SoType classname::getTypeId(void) const { \
00104   return classname::classTypeId; \
00105 } \
00106 void * classname::createInstance(void) { \
00107   assert(classname::classTypeId != SoType::badType()); \
00108   return (void *) new classname; \
00109 } \
00110 SoType classname::classTypeId
00111 
00112 // *************************************************************************
00113 
00114 #endif // ! SOQTOBJECT_H

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

Generated on Tue Oct 12 06:37:09 2004 for SoQt by Doxygen. 1.3.9