00001 /********************************************************************** 00002 * File: attrList.H 00003 * 00004 * Designer: Willie Glover 00005 * 00006 * Description: attrList defines a list of attributes. It is used 00007 * by legoRegion, opEdges, and legoOp. The attrList 00008 * can contain attribute pointers (lc, live, and ms) 00009 * or it can contain non-ptr attributes (bb_id, freq, 00010 * etc.). 00011 * 00012 * 12/4/94 WAH: Added copy constructor. 00013 * 9/5/97 WAH: Switched to enums in globals.H. 00014 * 1/9/98 WAH: Fixed SetTableName to handle NULL. 00015 * 1/27/98 WAH: Fixed destructor to delete tableName and intList. 00016 * 00017 **********************************************************************/ 00018 #ifndef ATTRLIST_H 00019 #define ATTRLIST_H 00020 00021 //class attrs; 00022 //class intList; 00023 #include "globals.H" 00024 #include "attr.H" 00025 class attrList { 00026 attrs *attrPtr; // pointer into attr dictionary 00027 // this pointer is NULL unless attr is lc, 00028 // live, or ms. Non-ptr attributes are not 00029 // listed in the attribute dictionary 00030 enum attrTypes attrType; // attribute type 00031 intList *attrValPtr; // attribute value (for freq and bb_id) 00032 char* tableName; // attribute value for tblname 00033 int attrId; // idx into the attr dictionary (for ptr types) 00034 int valid; // 0 = invalid, 1 = valid (needed for all types) 00035 attrList *nextListPtr; // this is pointer to next entry in this region's 00036 // attrlist 00037 00038 public: 00039 attrList(void) 00040 { 00041 // fprintf(stderr,"Creating ATTRLIST %p\n", this); 00042 attrPtr = NULL; 00043 attrType = ATTR_UNDEF; 00044 attrValPtr = NULL; 00045 tableName = NULL; 00046 attrId = 0; 00047 valid = 0; 00048 nextListPtr = NULL; 00049 } 00050 attrList(const attrList &orig) // copies all but attrs pointers 00051 { 00052 // fprintf(stderr,"Creating ATTRLIST %p\n", this); 00053 attrPtr = orig.attrPtr; // don't duplicate (dictionary) 00054 attrType = orig.attrType; 00055 if (orig.attrValPtr != NULL) 00056 attrValPtr = new intList (*(orig.attrValPtr)); 00057 else 00058 attrValPtr = NULL; 00059 if (orig.tableName != NULL) 00060 { 00061 tableName = new char [strlen (orig.tableName) + 1]; 00062 strcpy (tableName, orig.tableName); 00063 } // end if 00064 else 00065 tableName = NULL; 00066 attrId = 0; // will be changed anyway 00067 valid = orig.valid; 00068 if (orig.nextListPtr != NULL) 00069 nextListPtr = new attrList (*(orig.nextListPtr)); 00070 else 00071 nextListPtr = NULL; 00072 } 00073 ~attrList(void) 00074 { 00075 delete attrValPtr; 00076 delete[] tableName; 00077 00078 attrList* tmpAttrListPtr; 00079 while (nextListPtr != NULL) { 00080 tmpAttrListPtr = nextListPtr; 00081 nextListPtr = tmpAttrListPtr->GetNextListPtr(); 00082 tmpAttrListPtr->SetNextListPtr (NULL); 00083 delete tmpAttrListPtr; 00084 } 00085 // fprintf(stderr,"Deleting ATTRLIST %p\n",this); 00086 } 00087 00088 /********************************************************** 00089 * Get attr pointer 00090 *********************************************************/ 00091 attrs *GetAttrPtr(void) { return attrPtr; } 00092 00093 /*--------------------------------------------------------- 00094 * Get attribute type 00095 *-------------------------------------------------------*/ 00096 enum attrTypes GetAttrType(void) { return attrType; } 00097 00098 /*--------------------------------------------------------- 00099 * Get pointer to value of freq attribute or bb_id attribute. 00100 * Undefined for other attributes. 00101 *-------------------------------------------------------*/ 00102 intList *GetAttrValPtr(void) { return attrValPtr; } 00103 00104 /*--------------------------------------------------------- 00105 * Get tableName. required for attr tblname. 00106 *-------------------------------------------------------*/ 00107 char *GetTableName(void) { return tableName; } 00108 00109 /********************************************************** 00110 * Get attr ID 00111 *********************************************************/ 00112 int GetAttrId(void) { return attrId; } 00113 00114 /********************************************************** 00115 * Get valid field 00116 *********************************************************/ 00117 int GetValid(void) { return valid; } 00118 00119 /********************************************************** 00120 * Get nextListPtr (pointer to next attrList entry) 00121 *********************************************************/ 00122 attrList *GetNextListPtr(void) { return nextListPtr; } 00123 00124 /********************************************************** 00125 * Update attrs pointer 00126 *********************************************************/ 00127 void SetAttrPtr(attrs* newAttrPtr) { attrPtr = newAttrPtr; } 00128 00129 /*--------------------------------------------------------- 00130 * Update attribute type 00131 *-------------------------------------------------------*/ 00132 void SetAttrType(enum attrTypes newType) {attrType = newType; } 00133 00134 /*--------------------------------------------------------------- 00135 * Update pointer to value of freq attribute or bb_id attribute. 00136 *--------------------------------------------------------------*/ 00137 void SetAttrValPtr(intList *newValPtr) {attrValPtr = newValPtr; } 00138 00139 /*--------------------------------------------------------------- 00140 * Update tableName. 00141 *--------------------------------------------------------------*/ 00142 void SetTableName(char* newTableName) 00143 { 00144 delete[] tableName; 00145 if (newTableName != NULL) 00146 { 00147 tableName = new char[strlen(newTableName)+1]; 00148 strcpy(tableName,newTableName); 00149 } // end if 00150 else tableName = NULL; 00151 } 00152 00153 /********************************************************** 00154 * Update attr ID 00155 *********************************************************/ 00156 void SetAttrId(int newAttrId) { attrId = newAttrId; } 00157 00158 /********************************************************** 00159 * Update valid 00160 *********************************************************/ 00161 void SetValid(int newValid) { valid = newValid; } 00162 00163 /********************************************************** 00164 * Update nextListPtr (pointer to next attrList entry) 00165 *********************************************************/ 00166 void SetNextListPtr(attrList* newNext) { nextListPtr = newNext; } 00167 00168 // --------------------------------------------------------------------------- 00169 00170 }; 00171 00172 #endif // ATTRLIST_H
1.3.2