00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050 #ifndef _SO_ELEMENT
00051 #define _SO_ELEMENT
00052
00053 #include <Inventor/SbPImpl.h>
00054 #include <Inventor/SoType.h>
00055 #include <Inventor/SoTypedObject.h>
00056 #include <Inventor/misc/SoState.h>
00057 #include <Inventor/errors/SoDebugError.h>
00058 #include <assert.h>
00059
00060 class SoNotList;
00061
00062
00063 #ifndef HIDDEN_FROM_DOC
00064
00065 #define SO_ELEMENT_MAX_KEY 512
00066 #endif
00067
00068 SO_PIMPL_PUBLIC_DECLARATION(SoGLCacheList)
00069
00070
00102 SoEXTENDER_Documented class SoElement: public SoTypedObject {
00103
00104 public:
00105
00110 virtual void push(SoState *state);
00111
00116 virtual void pop(SoState *state, const SoElement *prevTopElement);
00117
00121 virtual void print(FILE *fp) const;
00122
00126 static SoType getClassTypeId();
00127
00131 virtual SoType getTypeId() const { return typeId; }
00132
00133 private:
00134
00140 virtual void commonInit();
00141
00146 virtual void init(SoState *state);
00147
00153 virtual SbBool matches(const SoElement* elt) const = 0;
00154
00159 virtual SoElement* copyMatchInfo() const = 0;
00160
00164 SoElement* getNextInStack() const { return nextInStack; }
00165
00166 private:
00167 typedef uint16_t SoElementKeyType;
00168
00169 static SoElementKeyType createElementKey();
00170
00174 virtual SoElementKeyType getElementKey() const
00175 {
00176 return badElementKey();
00177 }
00178
00182 static SoElementKeyType badElementKey();
00183
00184
00185 static void initElements();
00186 static void exitElements();
00187
00189 inline bool isTrackingSetterGetterNodes() const
00190 {
00191 return m_trackSetterGetterNodes;
00192 }
00193
00194 virtual int getClassStackIndexInternal() const = 0;
00195
00196
00197 static void initClass();
00198 static void exitClass();
00199
00200
00201 static int maxElementKey() { return s_nextElementKey; }
00202
00203
00204 static int getNumStackIndices();
00205
00206
00207 static SoType getIdFromStackIndex(int stackIndex);
00208
00209
00210 inline int getStackIndex() const { return stackIndex; }
00211
00212
00213 void setStackIndex(int index) { stackIndex = index; }
00214
00215
00216 void setDepth(int dpth) { depth = dpth; }
00217 void setNext(SoElement *nxt) { next = nxt; }
00218 void setNextInStack(SoElement *nxt) { nextInStack = nxt; }
00219 void setNextFree(SoElement *nxt) { nextFree = nxt; }
00220
00221
00222 int getDepth() const { return depth; }
00223 SoElement* getNext() const { return next; }
00224
00225 static const SoElement* getStackElement(SoState *state, const SoType& type, int stackIndex);
00226
00234 static const SoElement* getConstElement(SoState *state, const SoType& type, int stackIndex);
00235
00240 template<typename T>
00241 static const T* getConstElement(SoState *state)
00242 {
00243 return static_cast<const T*>(getConstElement(state, T::getClassTypeId(), T::getClassStackIndex()));
00244 }
00245
00246
00247
00248 void setPopPriority(unsigned short priority) {m_popPriority = priority ;}
00249 unsigned short getPopPriority() const { return m_popPriority ; }
00250
00251
00252 virtual ~SoElement();
00253
00254
00255
00256
00257 virtual void dyingReference() {} ;
00258
00264 inline SoType getInstanceTypeId() const
00265 {
00266
00267
00268
00269 assert(typeId!=SoType::badType());
00270 return typeId;
00271 }
00272
00273 #if 1 SoDEPRECATED
00280 static const SoElement* getConstElement(SoState *state, int stackIndex);
00281 SoDEPRECATED
00283 static const SoElement* getStackElement(SoState *state, int stackIndex);
00284
00285 #endif
00287 private:
00288
00289 SoElement();
00290
00296 template<typename T>
00297 static T* getElement(SoState *state)
00298 {
00299 return static_cast<T*>(getElement(state, T::getClassTypeId(), T::getClassStackIndex()));
00300 }
00301
00306 static SoElement* getElement(SoState *state, const SoType& type, int stackIndex);
00307
00308
00309
00310
00311 void capture(SoState *state) const
00312 {
00313 if ( state->isCacheOpen() )
00314 captureThis(state);
00315 }
00316
00317
00318
00319 virtual void captureThis(SoState *state) const;
00320
00321
00322 void setTypeId(SoType id) { typeId = id; }
00323
00324
00325
00326 SoElement* getNextFree() const { return nextFree; }
00327
00328 inline void setPopped(SbBool flag) { m_popped = (flag == TRUE); }
00329 inline SbBool isPopped() const { return m_popped ; }
00330
00335 static int getClassStackIndex();
00336
00342 #if 1 SoDEPRECATED
00345 static SoElement* getElement(SoState *state, int stackIndex);
00346
00347 #endif
00349 SoINTERNAL private:
00350
00351
00352 static int createStackIndex(const SoType& id);
00353
00355 inline void trackSetterGetterNodes(bool flag)
00356 {
00357 m_trackSetterGetterNodes = flag;
00358 }
00359
00360 private:
00365 SoElement* insertAtDepth(SoElement* elt, int depth);
00366
00367 SoElement* replaceElement(SoState* state, SoElement* oldElt, SoElement* newElt);
00368
00369 void updateNextInStackAndFree(SoElement* oldElt, SoElement* newElt);
00370
00371
00372
00373
00374
00375
00376
00377
00378 SoElement *nextInStack;
00379 SoElement *nextFree;
00380 SoElement *next;
00381
00382 static int classStackIndex;
00383
00384
00385 static int nextStackIndex;
00386
00387 static SoTypeList *stackToType;
00388 int stackIndex;
00389 int depth;
00390
00391
00392 static SoType classTypeId;
00393 SoType typeId;
00394
00395
00396
00397 unsigned short m_popPriority ;
00398 bool m_popped ;
00399
00404 bool m_trackSetterGetterNodes;
00405
00406 friend class SoState;
00407 friend class SoCache;
00408 friend class SoBoundingBoxCache;
00409 friend class inventor::impl::SoGLCacheListImpl;
00410 friend class SoGLViewingMatrixElement;
00411
00412
00413 static SoElementKeyType s_nextElementKey;
00414 };
00415
00416 #endif
00417
00418
00419