00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __GB_AttributeDict_h__
00021 #define __GB_AttributeDict_h__
00022
00023 #include "GB_API.h"
00024 #include <UT/UT_LinkList.h>
00025
00026 #include "GB_AttributeDefines.h"
00027
00028 class UT_IStream;
00029 class GB_Attribute;
00030 class GB_AttributeData;
00031 class GB_FloatOffsets;
00032
00033
00034
00035
00036
00037 class GB_API GB_AttributeDict : public UT_LinkList
00038 {
00039 public:
00040
00041 GB_AttributeDict() : UT_LinkList() { myUsedSize = myAllocSize = 0; }
00042 ~GB_AttributeDict();
00043
00044 GB_Attribute *find(const char *name, int s, GB_AttribType t) const;
00045
00046
00047 GB_Attribute *find(const char *name, GB_AttribType t) const;
00048
00049
00050 GB_Attribute *find(const char *name) const;
00051
00052
00053 GB_Attribute *findClone(const GB_Attribute *src) const;
00054
00055 GB_Attribute *getHead(void) const {return (GB_Attribute*)head();}
00056 int getSize(void) const { return myUsedSize; }
00057 int getAlloc(void) const { return myAllocSize; }
00058 int getOffset(const char *name, int size,
00059 GB_AttribType type) const;
00060
00061
00062 int getOffset(const char *name, GB_AttribType type) const;
00063
00064
00065 int getOffset(const GB_Attribute *src) const;
00066
00067 GB_Attribute *grow(const char* name, int oldsize,
00068 unsigned int addedsize, GB_AttribType type,
00069 int &offset);
00070
00071 GB_Attribute *shrink( const char* name, int oldsize,
00072 unsigned int removedsize, GB_AttribType type,
00073 int &offset );
00074
00075 void clearAndDestroy()
00076 {
00077 clear();
00078 myUsedSize = myAllocSize = 0;
00079 }
00080
00081
00082
00083 void useDefaults(GB_AttributeData &d, int alloc=1) const;
00084
00085
00086
00087
00088
00089 GB_Attribute *headFloatOffset(int &o) const;
00090 GB_Attribute *nextFloatOffset(int &o, const GB_Attribute *a) const;
00091
00092 GB_Attribute *headVectorOffset(int &o) const;
00093 GB_Attribute *nextVectorOffset(int &o, const GB_Attribute *a) const;
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108 int getFloatOffsets(GB_FloatOffsets &offsets,
00109 const char *interests[]) const;
00110 int getFloatOffsets(GB_FloatOffsets &offsets,
00111 GB_Attribute *startattrib = 0,
00112 int startidx = -1,
00113 int exceptions = 0, ...) const;
00114
00115 int getVectorOffsets(GB_FloatOffsets &offsets,
00116 GB_Attribute *startattrib = 0,
00117 int startidx = -1) const;
00118
00119
00120
00121 int getPersistentCount(void) const;
00122
00123
00124
00125
00126
00127 virtual void sortAs(const GB_AttributeDict &) = 0;
00128
00129
00130
00131 virtual int isEqual(const GB_AttributeDict &table) const;
00132
00133
00134
00135
00136
00137
00138
00139 int save(ostream &os, const GB_AttributeData &data, int binary,
00140 char attribDelim='(') const;
00141 bool load(UT_IStream &is, GB_AttributeData &data);
00142
00143
00144
00145
00146 int save(ostream &os, const char *label) const;
00147 GB_Attribute *load(UT_IStream &is, int tblSize);
00148
00149
00150
00151 class GB_API AttribXlate {
00152 public:
00153 int srcOff, size;
00154 int idxType;
00155 int idxOffset;
00156 GB_Attribute *atr;
00157 AttribXlate *next;
00158 };
00159 void translateData(const AttribXlate *table, void *input,
00160 void *tmp) const;
00161
00162 protected:
00163
00164
00165
00166
00167 GB_Attribute *append(const char *n, int s,
00168 GB_AttribType type, GB_AttribTypeInfo type_info,
00169 const void *defValue, int *offset);
00170 GB_Attribute *insertBefore(const char *n, int s, GB_AttribType type,
00171 GB_AttribTypeInfo type_info,
00172 const void *defValue, int dup_check,
00173 GB_Attribute *before, int *offset);
00174
00175
00176
00177
00178 GB_Attribute *destroy(const char *name, int size,
00179 GB_AttribType type, int *offset);
00180
00181
00182
00183 GB_Attribute *destroy(const char *name,
00184 GB_AttribType type, int *offset);
00185
00186
00187 void setAlloc(int a) { myAllocSize = a; }
00188
00189
00190
00191
00192 AttribXlate *preSort(const GB_AttributeDict &table, int *totSize);
00193
00194 private:
00195
00196
00197 int saveData(ostream &os, const void *d, int size, int type,
00198 int binary, char leadChar = ' ') const;
00199 int loadData(UT_IStream &is, void *d, int size, int type);
00200
00201
00202 int myUsedSize;
00203 int myAllocSize;
00204 };
00205
00206 #endif