1 /***********************************************************************/ 2 /* Open Visualization Data Explorer */ 3 /* (C) Copyright IBM Corp. 1989,1999 */ 4 /* ALL RIGHTS RESERVED */ 5 /* This code licensed under the */ 6 /* "IBM PUBLIC LICENSE - Open Visualization Data Explorer" */ 7 /***********************************************************************/ 8 9 #include <dxconfig.h> 10 #include "../base/defines.h" 11 12 13 14 #ifndef _DXType_h 15 #define _DXType_h 16 17 18 #include "Base.h" 19 //#include "List.h" 20 //#include "ListIterator.h" 21 22 23 // 24 // Type type definition: 25 // 26 27 typedef long Type; 28 29 class List; 30 31 // 32 // DXTypeName type definition: 33 // 34 typedef struct _DXTypeName 35 { 36 boolean userDefined; 37 char* name; 38 Type type; 39 40 } DXTypeName; 41 42 43 // 44 // DXType class definition: 45 // 46 class DXType : public Base 47 { 48 private: 49 // 50 // Performs class initialization. 51 // 52 inline void InitializeClass(); 53 54 protected: 55 // 56 // Protected class data: 57 // 58 static List* TypeList; // global type list 59 static boolean DXTypeClassInitialized; // is class initialized? 60 61 // 62 // Protected member data: 63 // 64 Type type; // type value 65 const char* name; // type name 66 67 public: 68 // 69 // Ennumeration of base types plus six user-definable types. 70 // 71 // NOTE: Each type is a bit flag and some times inherit other 72 // types by ORing the bit of the inherited types with 73 // into its bit. 74 // 75 enum 76 { 77 UndefinedType = 0x00000000, // undefined 78 IntegerType = 0x00000001, // integer 79 FlagType = 0x00000003, // flag |= integer 80 ScalarType = 0x00000005, // scalar |= integer 81 VectorType = 0x00000008, // vector 82 TensorType = 0x00000010, // tensor 83 ValueType = 0x0000001d, // value = 84 // integer|scalar|vector|tensor 85 StringType = 0x00000020, // string 86 CameraType = 0x00000040, // camera 87 LightType = 0x00000080, // light 88 89 UserType1 = 0x00000100, // user-defined 90 UserType2 = 0x00000200, // user-defined 91 WhereType = 0x00000400, // WHERE parameter 92 93 FieldType = 0x00000800, // field 94 GeometryFieldType = 0x00001800, // geometry field |= field 95 ColorFieldType = 0x00002800, // color field |= field 96 ScalarFieldType = 0x00004800, // scalar field |= field 97 VectorFieldType = 0x00008800, // vector field |= field 98 DataFieldType = 0x00010800, // data field |= field 99 ImageType = 0x00020800, // image |= field 100 101 SeriesType = 0x00040800, // series |= field 102 FieldSeriesType = 0x000c0800, // field series |= field|series 103 104 GroupType = 0x00100800, // group |= field 105 ValueGroupType = 0x00300800, // value group |= group|field 106 ValueListGroupType = 0x00500800, // value list group |= 107 // group|field 108 FieldGroupType = 0x00900800, // field group 109 110 ListType = 0x01000000, // list 111 ListTypeMask = 0x0effffff, // list mask 112 ObjectType = 0x03ffffff, // object 113 DescriptionType = 0x04000000, // description 114 115 ValueListType = DXType::ValueType | DXType::ListType, 116 ScalarListType = DXType::ScalarType | DXType::ListType, 117 IntegerListType = DXType::IntegerType | DXType::ListType, 118 FlagListType = DXType::FlagType | DXType::ListType, 119 TensorListType = DXType::TensorType | DXType::ListType, 120 VectorListType = DXType::VectorType | DXType::ListType, 121 StringListType = DXType::StringType | DXType::ListType, 122 123 ReservedType = 0x08000000, // RESERVED FOR FUTURE 124 125 UserType4 = 0x10000000, // user-defined 126 UserType5 = 0x20000000, // user-defined 127 UserType6 = 0x40000000 // user-defined 128 }; 129 130 // 131 // Determine the types of the items in a list. 132 // If there are mixed types then the returned type is DXType::ValueType. 133 // If there are not mixed types than the type of each item is returned. 134 // If an unrecognized list item is found, DXType::UndefinedType is 135 // returned. 136 // 137 static Type DetermineListItemType(const char *val); 138 139 // 140 // Adds a user-defined type to the class type list. 141 // Returns TRUE if successful; otherwise, FALSE. 142 // Note: The name string is copied by the function. 143 // 144 static boolean AddUserType(const Type type, 145 const char* name); 146 147 // 148 // Deletes a type (by type) from the class type list. 149 // Returns TRUE if successful; otherwise, FALSE. 150 // 151 static boolean DeleteType(const Type type); 152 153 // 154 // Given a string containing a value, determine its type. 155 // 156 static boolean ValueToType(const char *value, List& typelist); 157 158 159 // 160 // Deletes a type (by name) from the class type list. 161 // Returns TRUE if successful; otherwise, FALSE. 162 // 163 static boolean DeleteType(const char* name); 164 165 // 166 // Returns a name string of the specified type. 167 // 168 static const char* TypeToString(const Type type); 169 170 // 171 // Returns the type of the specified name string. 172 // 173 static Type StringToType(const char* string); 174 175 // 176 // Convert a version 1.0 (DX/6000 1.2 11/92) type to new type system. 177 // 178 static Type ConvertVersionType(Type t); 179 180 // 181 // Find the first type in the list of DXTypes, that matches the value. 182 // 183 static Type FindTypeMatch(const char *value, List *typelist); 184 185 // 186 // Returns TRUE if the source and destination types match; 187 // FALSE, otherwise. 188 // 189 static boolean MatchType(DXType& source, 190 DXType& destination); 191 192 static boolean MatchType(const Type source, 193 const Type destination); 194 195 // 196 // Returns TRUE if there exists a matching type in both lists. 197 // Returns FALSE otherwise. Note that the source list is 198 // semantically different from the destination list. 199 // 200 static boolean MatchTypeLists(List& source, 201 List& destination); 202 203 // 204 // Returns an intersection list of the first two type lists 205 // The returned list may be empty, and it must be deleted 206 // by the client. 207 // 208 static List* IntersectTypeLists(List& first, 209 List& second); 210 211 // 212 // Constructor: 213 // 214 DXType(); 215 DXType(const Type type); 216 217 // 218 // Destructor: 219 // ~DXType()220 ~DXType(){} 221 222 // 223 // Sets the type value IFF the type is a base or user-defined type. 224 // Returns TRUE if successful; FALSE, otherwise. 225 // 226 boolean setType(const Type type); 227 228 // 229 // Returns a pointer to the type name string. 230 // getName()231 const char* getName() 232 { 233 return this->name; 234 } 235 236 // 237 // Returns the type value. 238 // getType()239 long getType() 240 { 241 return this->type; 242 } 243 244 // 245 // DXType comparison equality operator. 246 // 247 boolean operator==(DXType type) 248 { 249 return this->type == type.type; 250 } 251 252 // 253 // Type bitwise AND operator. 254 // 255 boolean operator&(DXType type) 256 { 257 return this->type & type.type; 258 } 259 260 // 261 // Copy the instance data from this to newt. If newt is null allocate 262 // a new DXType. newt is returned. 263 // 264 DXType *duplicate(DXType *newt = NULL); 265 266 // 267 // Returns a pointer to the class name. 268 // getClassName()269 const char* getClassName() 270 { 271 return "DXType"; 272 } 273 }; 274 275 276 #endif // _DXType_h 277 278 279 280 281 282