00001 #ifndef COIN_SOPATH_H
00002 #define COIN_SOPATH_H
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 #include <Inventor/misc/SoBase.h>
00028 #include <Inventor/lists/SbList.h>
00029 #include <Inventor/lists/SoNodeList.h>
00030
00031 #ifndef COIN_INTERNAL
00032
00033 #include <Inventor/SoLists.h>
00034 #endif // !COIN_INTERNAL
00035
00036
00037 class SoWriteAction;
00038 class SoNotList;
00039 class SoInput;
00040 class SoPathList;
00041
00042
00043 class COIN_DLL_API SoPath : public SoBase {
00044 typedef SoBase inherited;
00045
00046 public:
00047 static void initClass(void);
00048
00049 SoPath(const int approxlength = 4);
00050 SoPath(SoNode * const head);
00051 SoPath(const SoPath & rhs);
00052
00053 SoPath & operator=(const SoPath & rhs);
00054
00055 static SoType getClassTypeId(void);
00056 virtual SoType getTypeId(void) const;
00057
00058 void setHead(SoNode * const head);
00059 SoNode * getHead(void) const;
00060 void append(const int childindex);
00061 void append(SoNode * const node);
00062 void append(const SoPath * const frompath);
00063 void push(const int childindex);
00064 void pop(void);
00065 SoNode * getTail(void) const;
00066 SoNode * getNode(const int index) const;
00067 SoNode * getNodeFromTail(const int index) const;
00068 int getIndex(const int index) const;
00069 int getIndexFromTail(const int index) const;
00070 int getLength(void) const;
00071 void truncate(const int length);
00072
00073 int findFork(const SoPath * const path) const;
00074 int findNode(const SoNode * const node) const;
00075
00076 SbBool containsNode(const SoNode * const node) const;
00077 SbBool containsPath(const SoPath * const path) const;
00078 SoPath * copy(const int startfromnodeindex = 0, int numnodes = 0) const;
00079 friend COIN_DLL_API SbBool operator==(const SoPath & lhs, const SoPath & rhs);
00080 friend COIN_DLL_API SbBool operator!=(const SoPath & lhs, const SoPath & rhs);
00081
00082 static SoPath * getByName(const SbName name);
00083 static int getByName(const SbName name, SoPathList & l);
00084
00085 void insertIndex(SoNode * const parent, const int newindex);
00086 void removeIndex(SoNode * const parent, const int oldindex);
00087 void replaceIndex(SoNode * const parent, const int index,
00088 SoNode * const newchild);
00089 SbBool isRelevantNotification(SoNotList * const l) const;
00090
00091 virtual void write(SoWriteAction * action);
00092
00093 protected:
00094 virtual ~SoPath();
00095 void auditPath(const SbBool flag);
00096
00097 private:
00098 static void * createInstance(void);
00099 void append(SoNode * const node, const int index);
00100 int getFullLength(void) const;
00101 void truncate(const int length, const SbBool donotify);
00102 virtual SbBool readInstance(SoInput * in, unsigned short flags);
00103 void setFirstHidden(void);
00104
00105 SoNodeList nodes;
00106 SbList<int> indices;
00107 SbBool isauditing;
00108 int firsthidden;
00109 SbBool firsthiddendirty;
00110 static SoType classTypeId;
00111
00112 friend class SoFullPath;
00113 friend class SoNodeKitPath;
00114 friend class SoAction;
00115 friend class SoTempPath;
00116 };
00117
00119
00120 inline int
00121 SoPath::getFullLength(void) const
00122 {
00123 return this->nodes.getLength();
00124 }
00125
00126 inline void
00127 SoPath::push(const int childindex)
00128 {
00129 this->append(childindex);
00130 }
00131
00132 inline void
00133 SoPath::pop(void)
00134 {
00135 this->truncate(this->getFullLength() - 1);
00136 }
00137
00139
00140
00141 #ifndef COIN_INTERNAL
00142
00143 #include <Inventor/SoFullPath.h>
00144 #include <Inventor/misc/SoLightPath.h>
00145 #endif // COIN_INTERNAL
00146
00147 #endif // !COIN_SOPATH_H