00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef __GB_ElementTree_h__
00024 #define __GB_ElementTree_h__
00025
00026 #include "GB_API.h"
00027 #include <UT/UT_RefArray.h>
00028 #include <UT/UT_LinkList.h>
00029
00030 class GB_Element;
00031 class GB_Group;
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 class GB_API GB_ElementNode
00042 {
00043 public:
00044 GB_ElementNode(const GB_Element *elem=0, const GB_Element *sec=0)
00045 : myElement(elem), mySecondary(sec) {}
00046
00047 int operator==(const GB_ElementNode &elem) const
00048 { return (myElement == elem.myElement &&
00049 mySecondary == elem.mySecondary); }
00050
00051 const GB_Element *element(void) const
00052 { return myElement; }
00053 void element(const GB_Element *elem)
00054 { myElement = elem; }
00055
00056 const GB_Element *secondary(void) const
00057 { return mySecondary;}
00058 void secondary(const GB_Element *elem)
00059 { mySecondary = elem;}
00060
00061 private:
00062 const GB_Element *myElement;
00063 const GB_Element *mySecondary;
00064 };
00065
00066 class GB_API GB_ElementTree
00067 {
00068 public:
00069 GB_ElementTree(void);
00070 virtual ~GB_ElementTree(void);
00071
00072
00073
00074
00075
00076 unsigned entries();
00077 unsigned mixedEntries();
00078
00079 void add(const GB_Element *);
00080 void addMix(const GB_Element *, const GB_Element *);
00081
00082 int containsMix(const GB_Element *, const GB_Element *);
00083
00084
00085 int remove(const GB_Element *);
00086 int removeMix(const GB_Element *, const GB_Element *);
00087
00088
00089
00090 void remove(int idx);
00091 void removeAll(int idx);
00092
00093
00094
00095
00096
00097
00098 void removeGroup(const GB_Group *grp);
00099
00100 void clear(void);
00101
00102 const GB_Element *prev(const GB_Element *node) const;
00103 int prevMix(const GB_Element *node, const GB_Element *sec,
00104 const GB_Element *&newnode,
00105 const GB_Element *&newsec) const;
00106
00107 const GB_Element *next(const GB_Element *node) const;
00108 int nextMix(const GB_Element *node, const GB_Element *sec,
00109 const GB_Element *&newnode,
00110 const GB_Element *&newsec) const;
00111
00112 const GB_Element *head() const;
00113 int headMix(const GB_Element *&newnode,
00114 const GB_Element *&newsec) const;
00115
00116 const GB_Element *tail() const;
00117 int tailMix(const GB_Element *&newnode,
00118 const GB_Element *&newsec) const;
00119
00120 private:
00121
00122
00123
00124 GB_ElementNode *findList(GB_ElementNode *) const;
00125
00126
00127
00128
00129
00130
00131 void removeList(GB_ElementNode *);
00132
00133
00134
00135
00136
00137 GB_ElementNode *prevList(GB_ElementNode *node) const
00138 { return (node > headList()) ? node - 1 : 0; }
00139
00140 GB_ElementNode *nextList(GB_ElementNode *node) const
00141 { return (node < tailList()) ? node + 1 : 0; }
00142
00143 GB_ElementNode *headList() const
00144 { return myElements.entries()
00145 ? (GB_ElementNode *)&myElements(0)
00146 : 0; }
00147
00148 GB_ElementNode *tailList() const
00149 { return myElements.entries()
00150 ? (GB_ElementNode *)
00151 &myElements(myElements.entries() - 1)
00152 : 0; }
00153
00154
00155 UT_RefArray<GB_ElementNode> myElements;
00156
00157
00158
00159 mutable GB_ElementNode *myLastAccess;
00160
00161
00162
00163 unsigned myMixCount;
00164
00165 friend class GB_GroupList;
00166 };
00167
00168 #endif