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/SoType.h>
00054 #include <Inventor/SoTypedObject.h>
00055 #include <Inventor/misc/SoState.h>
00056 #include <Inventor/errors/SoDebugError.h>
00057 #include <assert.h>
00058
00059 class SoNotList;
00060
00091 SoEXTENDER_Documented class SoElement: public SoTypedObject {
00092
00093 public:
00094
00099 virtual void push(SoState *state);
00100
00105 virtual void pop(SoState *state, const SoElement *prevTopElement);
00106
00110 virtual void print(FILE *fp) const;
00111
00115 static SoType getClassTypeId();
00116
00120 virtual SoType getTypeId() const { return typeId; }
00121
00122 private:
00123
00129 virtual void commonInit();
00130
00135 virtual void init(SoState *state);
00136
00142 virtual SbBool matches(const SoElement* elt) const = 0;
00143
00148 virtual SoElement* copyMatchInfo() const = 0;
00149
00153 SoElement* getNextInStack() const { return nextInStack; }
00154
00155 private:
00156
00157 static void initElements();
00158 static void exitElements();
00159
00160 virtual int getClassStackIndexInternal() const = 0;
00161
00162
00163 static void initClass();
00164 static void exitClass();
00165
00166
00167 static int getNumStackIndices();
00168
00169
00170 static SoType getIdFromStackIndex(int stackIndex);
00171
00172
00173 inline int getStackIndex() const { return stackIndex; }
00174
00175
00176 void setStackIndex(int index) { stackIndex = index; }
00177
00178
00179 void setDepth(int dpth) { depth = dpth; }
00180 void setNext(SoElement *nxt) { next = nxt; }
00181 void setNextInStack(SoElement *nxt) { nextInStack = nxt; }
00182 void setNextFree(SoElement *nxt) { nextFree = nxt; }
00183
00184
00185 int getDepth() const { return depth; }
00186 SoElement* getNext() const { return next; }
00187
00188 static const SoElement* getStackElement(SoState *state, SoType type, int stackIndex);
00189
00194 static const SoElement* getConstElement(SoState *state, SoType type, int stackIndex);
00195
00199 template<typename T>
00200 static const T* getConstElement(SoState *state)
00201 {
00202 return static_cast<const T*>(getConstElement(state, T::getClassTypeId(), T::getClassStackIndex()));
00203 }
00204
00205
00206
00207 void setPopPriority(unsigned short priority) {m_popPriority = priority ;}
00208 unsigned short getPopPriority() const { return m_popPriority ; }
00209
00210
00211 virtual ~SoElement();
00212
00213
00214
00215
00216 virtual void dyingReference() {} ;
00217
00223 inline SoType getInstanceTypeId() const
00224 {
00225
00226
00227
00228 assert(typeId!=SoType::badType());
00229 return typeId;
00230 }
00231
00232 #if 1 SoDEPRECATED
00239 static const SoElement* getConstElement(SoState *state, int stackIndex);
00240 SoDEPRECATED
00242 static const SoElement* getStackElement(SoState *state, int stackIndex);
00243
00244 #endif
00246 private:
00247
00248 SoElement();
00249
00255 template<typename T>
00256 static T* getElement(SoState *state)
00257 {
00258 return static_cast<T*>(getElement(state, T::getClassTypeId(), T::getClassStackIndex()));
00259 }
00260
00261 static SoElement* getElement(SoState *state, SoType type, int stackIndex);
00262
00263
00264
00265
00266 void capture(SoState *state) const
00267 { if (state->isCacheOpen()) captureThis(state); }
00268
00269
00270
00271 virtual void captureThis(SoState *state) const;
00272
00273
00274 void setTypeId(SoType id) { typeId = id; }
00275
00276
00277 SoElement* getNextFree() const { return nextFree; }
00278
00279 inline void setPopped(SbBool flag) { m_popped = (flag == TRUE); }
00280 inline SbBool isPopped() const { return m_popped ; }
00281
00286 static int getClassStackIndex();
00287
00293 #if 1 SoDEPRECATED
00296 static SoElement* getElement(SoState *state, int stackIndex);
00297
00298 #endif
00300 SoINTERNAL private:
00301
00302 static int createStackIndex(SoType id);
00303
00308 SoElement* insertAtDepth(SoElement* elt, int depth);
00309 SoElement* replaceElement(SoState* state, SoElement* oldElt, SoElement* newElt);
00310
00311 private:
00312 void updateNextInStackAndFree(SoElement* oldElt, SoElement* newElt);
00313
00314
00315
00316
00317
00318
00319
00320
00321 SoElement *nextInStack;
00322 SoElement *nextFree;
00323 SoElement *next;
00324
00325 static int classStackIndex;
00326
00327
00328 static int nextStackIndex;
00329
00330 static SoTypeList *stackToType;
00331 int stackIndex;
00332 int depth;
00333
00334
00335 static SoType classTypeId;
00336 SoType typeId;
00337
00338
00339
00340 unsigned short m_popPriority ;
00341 bool m_popped ;
00342
00343 friend class SoState;
00344 friend class SoCache;
00345 friend class SoBoundingBoxCache;
00346 friend class SoGLCacheListImpl;
00347 friend class SoGLViewingMatrixElement;
00348 };
00349
00350 #endif
00351
00352
00353