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

SoQtObject.h
1 #ifndef SOQTOBJECT_H
2 #define SOQTOBJECT_H
3 
4 // src/Inventor/Qt/SoQtObject.h. Generated from SoGuiObject.h.in by configure.
5 
6 /**************************************************************************\
7  *
8  * This file is part of the Coin 3D visualization library.
9  * Copyright (C) by Kongsberg Oil & Gas Technologies.
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * ("GPL") version 2 as published by the Free Software Foundation.
14  * See the file LICENSE.GPL at the root directory of this source
15  * distribution for additional information about the GNU GPL.
16  *
17  * For using Coin with software that can not be combined with the GNU
18  * GPL, and for taking advantage of the additional benefits of our
19  * support services, please contact Kongsberg Oil & Gas Technologies
20  * about acquiring a Coin Professional Edition License.
21  *
22  * See http://www.coin3d.org/ for more information.
23  *
24  * Kongsberg Oil & Gas Technologies, Bygdoy Alle 5, 0257 Oslo, NORWAY.
25  * http://www.sim.no/ sales@sim.no coin-support@coin3d.org
26  *
27 \**************************************************************************/
28 
29 #include <assert.h>
30 
31 #include <Inventor/SbBasic.h>
32 #include <Inventor/SbString.h>
33 #include <Inventor/SoType.h>
34 
35 #include <Inventor/Qt/SoQtBasic.h>
36 
37 // *************************************************************************
38 
39 class SOQT_DLL_API SoQtObject {
40  static SoType classTypeId;
41 
42 public:
43  static void initClass(void);
44  static SoType getClassTypeId(void);
45  virtual SoType getTypeId(void) const = 0;
46  SbBool isOfType(SoType type) const;
47 
48  static void init(void);
49 
50  // FIXME: gcc-4 generates a warning when a class has virtual functions
51  // but no virtual destructor. Currently this warning is suppressed using
52  // the -Wno-non-virtual-dtor option, but this should be addressed for the
53  // next major version... 20060404 kyrah
54 
55 #if (SOQT_MAJOR_VERSION > 1)
56 #error Resolve missing virtual destructor issue for the new major release!
57 #endif
58 
59 }; // SoQtObject
60 
61 // *************************************************************************
62 
63 // For a discussion about this #define, see Coin's SbBasic.h.
64 
65 #define SOQT_SUN_CC_4_0_SOTYPE_INIT_BUG 0 /* assume compiler is ok for now */
66 
67 #if SOQT_SUN_CC_4_0_SOTYPE_INIT_BUG
68 #define SOQT_STATIC_SOTYPE_INIT
69 #else
70 #define SOQT_STATIC_SOTYPE_INIT = SoType::badType()
71 #endif
72 
73 // *************************************************************************
74 
75 // The getTypeId() method should be abstract for abstract objects, but doing
76 // that would cause custom components derived from abstract components to
77 // have to include the typed object header / source, which could be a
78 // problem if the custom component wasn't written for Coin in the first
79 // place.
80 
81 #define SOQT_OBJECT_ABSTRACT_HEADER(classname, parentname) \
82 public: \
83  static void initClass(void); \
84  static SoType getClassTypeId(void); \
85  virtual SoType getTypeId(void) const /* = 0 (see comment above) */; \
86 private: \
87  typedef parentname inherited; \
88  static SoType classTypeId
89 
90 #define SOQT_OBJECT_HEADER(classname, parentname) \
91 public: \
92  static void initClass(void); \
93  static SoType getClassTypeId(void); \
94  virtual SoType getTypeId(void) const; \
95  static void * createInstance(void); \
96 private: \
97  typedef parentname inherited; \
98  static SoType classTypeId
99 
100 #define SOQT_OBJECT_ABSTRACT_SOURCE(classname) \
101 void classname::initClass(void) { \
102  assert(classname::classTypeId == SoType::badType()); \
103  classname::classTypeId = \
104  SoType::createType(inherited::getClassTypeId(), \
105  SO__QUOTE(classname)); \
106 } \
107 SoType classname::getClassTypeId(void) { \
108  return classname::classTypeId; \
109 } \
110 SoType classname::getTypeId(void) const { \
111  return classname::classTypeId; \
112 } \
113 SoType classname::classTypeId SOQT_STATIC_SOTYPE_INIT
114 
115 #define SOQT_OBJECT_SOURCE(classname) \
116 void classname::initClass(void) { \
117  assert(classname::classTypeId == SoType::badType()); \
118  classname::classTypeId = \
119  SoType::createType(inherited::getClassTypeId(), \
120  SO__QUOTE(classname), \
121  classname::createInstance); \
122 } \
123 SoType classname::getClassTypeId(void) { \
124  return classname::classTypeId; \
125 } \
126 SoType classname::getTypeId(void) const { \
127  return classname::classTypeId; \
128 } \
129 void * classname::createInstance(void) { \
130  assert(classname::classTypeId != SoType::badType()); \
131  return (void *) new classname; \
132 } \
133 SoType classname::classTypeId SOQT_STATIC_SOTYPE_INIT
134 
135 // *************************************************************************
136 
137 #endif // ! SOQTOBJECT_H
The SoQtObject class is the common superclass for all SoQt component classes.The purpose of making th...
Definition: SoQtObject.h:39

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

Generated on Fri Jul 3 2015 for SoQt by Doxygen 1.8.9.1.