00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __GB_GroupList_h__
00021 #define __GB_GroupList_h__
00022
00023 #include "GB_API.h"
00024 #include <UT/UT_LinkList.h>
00025 #include <UT/UT_SymbolTable.h>
00026 #include "GB_ElementList.h"
00027
00028 class UT_BitArray;
00029 class GB_ElementTree;
00030 class GB_Group;
00031 class GB_PointList;
00032 class GB_PrimList;
00033 class UT_IStream;
00034
00035 class GB_API GB_GroupList : public UT_LinkList
00036 {
00037 public:
00038 GB_GroupList(GB_ElementList &list);
00039 virtual ~GB_GroupList();
00040
00041 int isEmpty() const { return head() ? 0 : 1; }
00042 int getPersistentCount() const;
00043
00044 GB_Group *find(const char *name) const;
00045 GB_Group *head() const;
00046 GB_Group *tail() const;
00047
00048 GB_Element *element(int num) const
00049 { return (num >= 0 && num < (int)myElements.entries()) ?
00050 myElements((unsigned)num) : 0;
00051 }
00052
00053 int numOrdered() const { return myOrdered; }
00054 void numOrdered(int n) { myOrdered = n; }
00055
00056 int getAllocSize() const { return myAllocSize; }
00057
00058
00059 void copyDefinition(const GB_GroupList &src);
00060
00061 protected:
00062 virtual GB_Group *groupSpecies(const char *name, int internal) const=0;
00063
00064 private:
00065 friend class GB_Detail;
00066
00067 GB_Group *newGroup(const char *name, int internal);
00068 void destroy(GB_Group *group);
00069 void destroy(const char *name) { destroy(find(name)); }
00070 void clear();
00071
00072 void findAvailable(unsigned &offset, unsigned &mask);
00073 void resizeElements(int oldSize, int newSize);
00074
00075 int myAllocSize;
00076 unsigned *myAvailable;
00077 GB_ElementList &myElements;
00078 UT_SymbolTable myHashtable;
00079 int myOrdered;
00080
00081
00082
00083
00084
00085 friend class GB_Group;
00086
00087 void rename(const char *name, GB_Group &g);
00088
00089
00090 unsigned entries(const GB_Group &grp);
00091 unsigned entriesMix(const GB_Group &grp);
00092 int isEmpty(const GB_Group &grp);
00093 int isEmptyMix(const GB_Group &grp);
00094
00095 void clearEntries(GB_Group &grp);
00096 void clearAllEntries();
00097 void setEntries(GB_Group &grp);
00098 void toggleEntries(GB_Group &grp);
00099
00100
00101
00102 void orEqual (GB_Group &dst, const GB_Group &g);
00103 void andEqual (GB_Group &dst, const GB_Group &g);
00104 void minusEqual (GB_Group &dst, const GB_Group &g);
00105 void xorEqual (GB_Group &dst, const GB_Group &g);
00106 void assignEqual(GB_Group &dst, const GB_Group &g);
00107
00108 int save(const GB_Group &src, ostream &os, int bin) const;
00109 bool load(GB_Group &src, UT_IStream &is);
00110
00111 int save(ostream &os, int binary) const;
00112 bool load(UT_IStream &is, int howMany);
00113
00114 int saveTree(ostream &os, int binary,
00115 GB_ElementTree *tree) const;
00116 bool loadTree(UT_IStream &is, GB_ElementTree *tree);
00117
00118 void saveToBitArray(const GB_Group &, UT_BitArray &) const;
00119 void loadFromBitArray(GB_Group &, UT_BitArray &);
00120 };
00121
00122 class GB_API GB_PointGroupList : public GB_GroupList
00123 {
00124 public:
00125 GB_PointGroupList(GB_ElementList &list);
00126 virtual ~GB_PointGroupList();
00127
00128 protected:
00129 virtual GB_Group *groupSpecies(const char *name, int internal) const;
00130 };
00131
00132 class GB_API GB_PrimGroupList : public GB_GroupList
00133 {
00134 public:
00135 GB_PrimGroupList(GB_ElementList &list);
00136 virtual ~GB_PrimGroupList();
00137
00138 protected:
00139 virtual GB_Group *groupSpecies(const char *name, int internal) const;
00140 };
00141
00142 #endif