00001
00002
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
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 #ifndef __GB_Attribute_h__
00044 #define __GB_Attribute_h__
00045
00046 #include "GB_API.h"
00047 #include <UT/UT_LinkList.h>
00048
00049 #include "GB_AttributeDefines.h"
00050 #include "GB_AttributeDict.h"
00051 #include "GB_AttributeElem.h"
00052 #include "GB_AttributeTable.h"
00053
00054 class UT_IStream;
00055
00056
00057 class GB_API GB_Attribute : public UT_LinkNode
00058 {
00059 public:
00060 GB_Attribute(const char *n, int s, GB_AttribType t, const void *def);
00061 GB_Attribute(const char *n, int s, GB_AttribType t, GB_AttribTypeInfo f,
00062 const void *def);
00063 ~GB_Attribute();
00064
00065 void initialize(const char *n, int s, GB_AttribType t, GB_AttribTypeInfo f,
00066 const void *def);
00067 void setDefault( const void *def );
00068
00069
00070 const char *getName() const { return myName; }
00071
00072
00073
00074
00075
00076
00077
00078 int getSize() const { return mySize; }
00079 int getAllocSize() const
00080 { return alignSizeWithWord(mySize); }
00081
00082
00083
00084 GB_AttribType getType() const { return myType; }
00085
00086 GB_AttribTypeInfo getTypeInfo() const { return myTypeInfo; }
00087
00088 const void *getDefault() const { return myDefValue; }
00089
00090
00091
00092 void rename(const char *newname);
00093
00094
00095 void setType(GB_AttribType t) { myType = t; }
00096
00097 void setTypeInfo(GB_AttribTypeInfo t) { myTypeInfo = t; }
00098
00099
00100
00101 int saveIndexValues(ostream &os, int binary) const;
00102 bool loadIndexValues(UT_IStream &is);
00103
00104
00105
00106
00107 int addIndex(const char *label);
00108
00109 void renameIndex(int idx, const char *label);
00110
00111
00112
00113 int destroyIndex(const char *label)
00114 {
00115 return destroyIndex(getIndex(label));
00116 }
00117
00118
00119
00120 int destroyIndex(int index);
00121
00122
00123 void clearIndex(void);
00124
00125 void removeRedundantIndex(void);
00126
00127 int getIndexSize(void) const { return myIndexSize; }
00128
00129
00130 int getIndex(const char *label) const;
00131
00132 const char *getIndex(int idx) const
00133 {
00134 return (idx < myIndexSize && idx >= 0) ?
00135 myIndexArray[idx] : 0;
00136 }
00137
00138
00139 int mergeIndex(const GB_Attribute *atr);
00140
00141
00142
00143 int mergeIndexByAppending(const GB_Attribute *atr);
00144
00145
00146 static inline int alignSizeWithWord(int size)
00147 {
00148 if ((size & (GB_ATTRIB_ALIGN_SIZE-1)) != 0)
00149 size += GB_ATTRIB_ALIGN_SIZE -
00150 (size & (GB_ATTRIB_ALIGN_SIZE-1));
00151 return size;
00152 }
00153
00154 protected:
00155 friend class GB_AttributeDict;
00156
00157 private:
00158 void grow(unsigned int addedsize);
00159 void shrink( unsigned int removedsize );
00160
00161 char *myName;
00162 int mySize;
00163 GB_AttribType myType;
00164 GB_AttribTypeInfo myTypeInfo;
00165 void *myDefValue;
00166 char **myIndexArray;
00167 int myIndexSize;
00168 };
00169
00170 #endif