00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef COIN_SOELEMENT_H
00021 #define COIN_SOELEMENT_H
00022
00023 #include <Inventor/SbBasic.h>
00024 #include <Inventor/SoType.h>
00025 #include <Inventor/misc/SoState.h>
00026 #include <stdio.h>
00027
00028 class SoNode;
00029
00030 class COIN_DLL_API SoElement {
00031 public:
00032 static void initClass(void);
00033
00034 static SoType getClassTypeId(void);
00035 static int getClassStackIndex(void);
00036 const SoType getTypeId(void) const;
00037 int getStackIndex(void) const;
00038
00039 virtual void init(SoState * state);
00040
00041 virtual void push(SoState * state);
00042 virtual void pop(SoState * state, const SoElement * prevTopElement);
00043
00044 virtual SbBool isLazy(void) const;
00045 virtual void lazyEvaluate(void) const;
00046
00047 virtual SbBool matches(const SoElement * element) const = 0;
00048 virtual SoElement * copyMatchInfo(void) const = 0;
00049
00050 static void initElements(void);
00051
00052 static int getNumStackIndices(void);
00053 static SoType getIdFromStackIndex(const int stackIndex);
00054
00055 void setDepth(const int depth);
00056
00057 int getDepth(void) const;
00058
00059 virtual void print(FILE * file = stdout) const;
00060 virtual ~SoElement();
00061
00062 protected:
00063 SoElement(void);
00064 static int classStackIndex;
00065
00066 static SoElement * getElement(SoState * const state, const int stackIndex);
00067 static const SoElement * getConstElement(SoState * const state,
00068 const int stackIndex);
00069
00070 void capture(SoState * const state) const;
00071 virtual void captureThis(SoState * state) const;
00072
00073 void setTypeId(const SoType typeId);
00074 void setStackIndex(const int index);
00075
00076 SoType typeId;
00077 int stackIndex;
00078
00079 static int createStackIndex(const SoType id);
00080 static SoTypeList * stackToType;
00081
00082 int depth;
00083
00084 SoElement * getNextInStack(void) const;
00085 SoElement * getNextFree(void) const;
00086
00087 private:
00088
00089 static SoType classTypeId;
00090
00091 friend class SoState;
00092 static void cleanup(void);
00093 SoElement * nextup;
00094 SoElement * nextdown;
00095 };
00096
00097
00098
00099 inline SoElement *
00100 SoElement::getElement(SoState * const state,
00101 const int stackIndex)
00102 {
00103 return state->getElement(stackIndex);
00104 }
00105
00106 #endif // !COIN_SOELEMENT_H