00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef __GDT_TokenList_h__
00022 #define __GDT_TokenList_h__
00023
00024 #include "GDT_API.h"
00025 #include <fstream.h>
00026 #include <UT/UT_PtrArray.h>
00027 #include <UT/UT_IntArray.h>
00028 #include <GB/GB_Attribute.h>
00029
00030 class GB_BaseGroup;
00031 class GDT_BaseAttribute;
00032 class GEO_Detail;
00033 class UT_String;
00034
00035 class GDT_API GDT_TokenList
00036 {
00037 public:
00038
00039 GDT_TokenList();
00040 GDT_TokenList(const GDT_TokenList &other);
00041 virtual ~GDT_TokenList() = 0;
00042
00043
00044 virtual void applyDeltas(GEO_Detail &gdp, bool inverse=0) const;
00045
00046
00047 virtual void zeroDeltas();
00048
00049 virtual void clearDeltas();
00050
00051 virtual void destroy();
00052
00053
00054
00055
00056
00057
00058 void setAttribDict(const GB_AttributeDict &dict);
00059
00060
00061
00062
00063 void refreshAttribDict(const GB_AttributeDict &dict);
00064
00065
00066
00067
00068 void beginAttributeChange(const GB_AttributeData &data);
00069 void endAttributeChange(const GB_AttributeData &data,
00070 unsigned int index);
00071
00072
00073
00074
00075
00076 void resizeSavedListData(int numelem);
00077 void beginListAttributeChange(const GB_AttributeData &data,
00078 unsigned int index);
00079 void endListAttributeChange(const GB_AttributeData &data,
00080 unsigned int index);
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091 virtual unsigned int getElementCount(const GEO_Detail &gdp) const=0;
00092
00093
00094
00095
00096
00097 virtual void initIterate() const = 0;
00098 virtual GB_AttributeElem *getNextAttributeElement(GEO_Detail &gdp) const=0;
00099 virtual GB_AttributeElem *getAttributeElement(GEO_Detail &gdp,
00100 unsigned int index) const=0;
00101
00102
00103 virtual GB_AttributeDict &getAttributeDict(GEO_Detail &gdp) const=0;
00104
00105
00106
00107
00108
00109
00110
00111
00112 virtual int appendGdpAttribute(GEO_Detail &gdp,
00113 const char *name, int size,
00114 GB_AttribType type,
00115 const void *defvalue) const=0;
00116 virtual int growGdpAttribute(GEO_Detail &gdp,
00117 const char *name, int oldsize,
00118 GB_AttribType type,
00119 unsigned int addedsize) const=0;
00120
00121
00122
00123
00124
00125
00126 virtual bool hasChange() const;
00127
00128
00129
00130
00131
00132 virtual unsigned int entries() const;
00133
00134
00135 virtual int saveAttribs(ostream &os, int binary = 0) const;
00136 virtual bool loadAttribs(UT_IStream &is, uint size);
00137
00138
00139
00140 void renameAttribute(const UT_String &oldname,
00141 const UT_String &newname);
00142
00143 protected:
00144
00145
00146 void mergeAttributeDeltas(const GDT_TokenList &other,
00147 bool inverse = false);
00148
00149
00150
00151
00152 virtual void getAttributeElements(const GEO_Detail &beforegdp,
00153 const GEO_Detail &aftergdp,
00154 unsigned int before_elem_index,
00155 unsigned int after_elem_index,
00156 const GB_AttributeElem *&beforeelem,
00157 const GB_AttributeElem *&afterelem) const=0;
00158
00159
00160
00161 int getAttributeIndex(const UT_String &name,
00162 GB_AttribType type);
00163 int getAttributeIndex(const UT_String &name,
00164 int size,
00165 GB_AttribType type);
00166
00167
00168 unsigned int appendAttribute(const UT_String &name,
00169 int attrib_size,
00170 GB_AttribType type,
00171 const void *defaults,
00172 unsigned int array_size);
00173 unsigned int appendAttribute(const GB_Attribute &attrib,
00174 unsigned int array_size);
00175
00176 GDT_BaseAttribute *attribs(unsigned int i) { return myAttributes(i); }
00177 const GDT_BaseAttribute *attribs(unsigned int i) const
00178 { return myAttributes(i); }
00179 int numAttribs() const { return myAttributes.entries(); }
00180 int getAttributeOffset(unsigned int i)
00181 { return myAttributeOffsets(i); }
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199 private:
00200
00201 int mySavedDataSize;
00202 GB_AttributeData mySavedData;
00203 UT_PtrArray<GB_AttributeData *> mySavedListData;
00204
00205
00206 UT_PtrArray<GDT_BaseAttribute *> myAttributes;
00207 UT_IntArray myAttributeOffsets;
00208 };
00209 #endif