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