casa
$Rev:20696$
|
00001 //# RecordInterface.h: Abstract base class for Record classes 00002 //# Copyright (C) 1996,1997,1998,1999,2001 00003 //# Associated Universities, Inc. Washington DC, USA. 00004 //# 00005 //# This library is free software; you can redistribute it and/or modify it 00006 //# under the terms of the GNU Library General Public License as published by 00007 //# the Free Software Foundation; either version 2 of the License, or (at your 00008 //# option) any later version. 00009 //# 00010 //# This library is distributed in the hope that it will be useful, but WITHOUT 00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00012 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00013 //# License for more details. 00014 //# 00015 //# You should have received a copy of the GNU Library General Public License 00016 //# along with this library; if not, write to the Free Software Foundation, 00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. 00018 //# 00019 //# Correspondence concerning AIPS++ should be addressed as follows: 00020 //# Internet email: aips2-request@nrao.edu. 00021 //# Postal address: AIPS++ Project Office 00022 //# National Radio Astronomy Observatory 00023 //# 520 Edgemont Road 00024 //# Charlottesville, VA 22903-2475 USA 00025 //# 00026 //# 00027 //# $Id: RecordInterface.h 21022 2011-03-01 10:07:47Z gervandiepen $ 00028 00029 00030 #ifndef CASA_RECORDINTERFACE_H 00031 #define CASA_RECORDINTERFACE_H 00032 00033 00034 //# Includes 00035 #include <casa/aips.h> 00036 #include <casa/BasicSL/String.h> 00037 #include <casa/Utilities/Notice.h> 00038 #include <casa/Utilities/DataType.h> 00039 #include <casa/Containers/RecordFieldId.h> 00040 #include <casa/Arrays/Array.h> 00041 00042 namespace casa { //# NAMESPACE CASA - BEGIN 00043 00044 //# Forward Declarations 00045 class RecordDesc; 00046 class IPosition; 00047 00048 00049 // <summary> 00050 // Abstract base class for Record classes 00051 // </summary> 00052 00053 // <use visibility=export> 00054 // <reviewed reviewer="Mark Wieringa" date="1996/04/15" tests="tRecord"> 00055 // </reviewed> 00056 00057 //# <prerequisite> 00058 //# </prerequisite> 00059 00060 // <etymology> 00061 // ``Record'' is a widely used term in both programming languages and data 00062 // structures to denote an imhogeneous set of fields. An alternative would 00063 // have been to name it <em>struct</em>ure, which would have perhaps been 00064 // a clearer name for C++ programmers. 00065 // <br> 00066 // RecordInterface denotes that this class defines the common interface to 00067 // possible Record classes. 00068 // </etymology> 00069 00070 // <synopsis> 00071 // A Record is an inhomogeneous, hierarchical, collection of named fields. The 00072 // fields may be of scalar type, array type, a Table or a Record. This latter 00073 // feature is what makes the Record a (potentially) hierarchical type. 00074 // <p> 00075 // RecordInterface is the abstract base class for various Record classes. 00076 // At the moment three Record classes exist: 00077 // <ul> 00078 // <li> <linkto class=Record>Record</linkto> 00079 // <li> <linkto class=TableRecord>TableRecord</linkto> 00080 // </ul> 00081 // Presently, the scalar types are chosen to be compatible with the native 00082 // types of the Table system, viz: Bool, uChar, Short, Int, uInt, Int64, 00083 // Float, Double, Complex, DComplex, String. 00084 // Arrays of all these types are also available. 00085 // It is fairly straightforward to extend this set if necessary, although it 00086 // will result in more template instantiations with the current implementation. 00087 // <p> 00088 // Each field has an integral index, which ranges between 0 and 00089 // <src>nfields() - 1</src>. The values of a field can be manipulated 00090 // in two ways: 00091 // <ol> 00092 // <li> Through the get and put functions in this class. 00093 // They are easy to use and support type promotion. 00094 // However, they are a bit less efficient than the second way. 00095 // <li> Through the class 00096 // <linkto class="RecordFieldPtr">RecordFieldPtr</linkto>. 00097 // This is a bit less convenient. However, it is more efficient if 00098 // the same field is accessed multiple times. 00099 // </ol> 00100 // The structure of a record can be fixed or variable. 00101 // If fixed, it is not possible to change the structure once the 00102 // record has been instantiated. If variable, the record can be 00103 // restructured or fields can be added/removed. 00104 // <br> 00105 // When a field gets added, it is possible to check if its name and 00106 // type are valid by means of the CheckFunction callback. This is 00107 // for instance used by the table system to assure that keywords 00108 // and columns in a table do not have the same name. 00109 // <p> 00110 // Arrays in a record description can be fixed or variable shaped. 00111 // If fixed shaped, only arrays with that shape can be stored 00112 // in that field in the record. If variable shaped, any array 00113 // can be stored. 00114 // <br> However, note there is a difference between assign and define. 00115 // Assign invokes the array assignment operator which checks for 00116 // conformance. Thus even for variable shaped arrays, the new array 00117 // must conform the exisitng one when using assign. Define simply replaces 00118 // the array, thus for variable shaped arrays ay array shape will do. 00119 // <p> 00120 // RecordFieldPtr objects attached to a Record have to be notified when 00121 // the Record is deleted or changed. 00122 // The RecordInterface class provides the hooks for this via the 00123 // Notice system. It is derived from 00124 // <linkto class=NoticeSource> NoticeSource</linkto>. The class 00125 // <linkto class=RecordNotice>RecordNotice</linkto> is for the messages. 00126 // </synopsis> 00127 00128 // <motivation> 00129 // This common base class provides a common interface to the various 00130 // Record classes. 00131 // Furthermore it is needed for the class RecordFieldPtr. 00132 // Finally it provides the hooks for the notification in case the 00133 // record structure changes. 00134 // </motivation> 00135 // 00136 // <todo asof="1996/03/10"> 00137 // <li> A record reference class, which contains some fields from another 00138 // record, would likely be useful. This would be analagous to a 00139 // subarray sliced from an existing array. 00140 // </todo> 00141 00142 00143 class RecordInterface : public NoticeSource 00144 { 00145 public: 00146 // Define the flag telling if a Record has a fixed or 00147 // variable structure. 00148 enum RecordType { 00149 // Record has a fixed structure; that is, no fields can 00150 // be added or removed once the Record is created. 00151 Fixed, 00152 // Record has a variable structure; after Record creation 00153 // fields can be added or removed at will. 00154 Variable}; 00155 00156 // Define the Duplicates flag for the function merge in the various 00157 // record classes. 00158 // This function merges the fields from that record (description) 00159 // into this one. 00160 // DuplicatesFlag determines what to do if a field already exists. 00161 enum DuplicatesFlag { 00162 // Rename a name from the other set to name_n, 00163 // where n is the first positive number making the name unique. 00164 RenameDuplicates, 00165 // Skip duplicate names from the other set. 00166 SkipDuplicates, 00167 // Overwrite the value of a duplicate keyword 00168 // This will also happen if their types differ. 00169 OverwriteDuplicates, 00170 // Throw an exception. 00171 ThrowOnDuplicates}; 00172 00173 // Define the signature of the add callback function. 00174 // This function is called when a field is added to the record 00175 // (thus also when a Record is constructed from a RecordDesc). 00176 // The function can check if the name and/or data type are valid. 00177 // The extra argument is the argument given to the Record constructor 00178 // which can be used to pass non-Record information. 00179 // The function should return False if name or data type is invalid. 00180 // In that case it can fill the message string, which will be added 00181 // to the message in the thrown exception. 00182 typedef Bool CheckFieldFunction (const String& fieldName, 00183 DataType dataType, 00184 const void* extraArgument, 00185 String& message); 00186 00187 // The default constructor creates an empty record with a variable 00188 // structure. 00189 RecordInterface(); 00190 00191 // Create a record with no fields. 00192 // The callback function is called when a field is added to the Record. 00193 // That function can check the name and of data type of the new field 00194 // (for instance, the Table system uses it to ensure that table columns 00195 // and keywords have different names). 00196 RecordInterface (RecordType type, CheckFieldFunction* funcPtr, 00197 const void* checkArgument); 00198 00199 // Copy constructor (copy semantics). 00200 RecordInterface (const RecordInterface& other); 00201 00202 // Assignment (copy semantics). 00203 // This only assigns the RecordInterface object itself, 00204 // thus not the data in a derived class. 00205 // To do that the function <src>assign</src> below can be used. 00206 RecordInterface& operator= (const RecordInterface& other); 00207 00208 // Destruct the record. 00209 // All attached RecordFieldPtr objects are notified to detach themselves. 00210 ~RecordInterface(); 00211 00212 // Make a copy of this object. 00213 virtual RecordInterface* clone() const = 0; 00214 00215 // Assign that RecordInterface object to this one. 00216 // Unlike <src>operator=</src> it copies all data in the derived 00217 // class. 00218 virtual void assign (const RecordInterface& that) = 0; 00219 00220 // Is the Record structure fixed (i.e. impossible to restructure or 00221 // to add or remove fields)? 00222 Bool isFixed() const; 00223 00224 // How many fields does this structure have? 00225 // <group> 00226 virtual uInt nfields() const = 0; 00227 uInt size() const 00228 { return nfields(); } 00229 // </group> 00230 00231 // Is the record empty? 00232 bool empty() const 00233 { return size() == 0; } 00234 00235 // Get the field number from the field name. 00236 // -1 is returned if the field name is unknown. 00237 virtual Int fieldNumber (const String& fieldName) const = 0; 00238 00239 // Get the field number for the given field id. 00240 // It throws an exception if id is unrecognized (e.g. an unknown name). 00241 Int idToNumber (const RecordFieldId&) const; 00242 00243 // Test if a field name exists. 00244 //# Is here for backward compatibility with KeywordSet. 00245 Bool isDefined (const String& fieldName) const; 00246 00247 // Get the data type of this field (as defined in DataType.h). 00248 // <group> 00249 virtual DataType type (Int whichField) const = 0; 00250 DataType dataType (const RecordFieldId&) const; 00251 // </group> 00252 00253 // Get the name of this field. 00254 String name (const RecordFieldId&) const; 00255 00256 // Get the comment for this field. 00257 virtual const String& comment (const RecordFieldId&) const = 0; 00258 00259 // Set the comment for this field. 00260 virtual void setComment (const RecordFieldId&, const String& comment) = 0; 00261 00262 // Get the actual shape of this field. 00263 // It returns [1] for non-array fields. 00264 IPosition shape (const RecordFieldId&) const; 00265 00266 // Get the description of this record. 00267 RecordDesc description() const; 00268 00269 // Change the structure of this Record to contain the fields in 00270 // newDescription. After calling restructure, <src>description() == 00271 // newDescription</src>. Any existing RecordFieldPtr objects are 00272 // invalidated (their <src>isAttached()</src> members return False) after 00273 // this call. 00274 // <br>If the new description contains subrecords, those subrecords 00275 // will be restructured if <src>recursive=True</src> is given. 00276 // Otherwise the subrecord is a variable empty record. 00277 // Subrecords will be variable if their description is empty (i.e. does 00278 // not contain any field), otherwise they are fixed. 00279 // <br>Restructuring is not possible and an exception is thrown 00280 // if the Record has a fixed structure. 00281 virtual void restructure (const RecordDesc& newDescription, 00282 Bool recursive=True) = 0; 00283 00284 // Remove a field from the record. 00285 // <note role=caution> 00286 // Removing a field means that the field number of the fields following 00287 // it will be decremented. It will invalidate RecordFieldPtr's 00288 // pointing to the removed field, but no other RecordFieldPtr's. 00289 // </note> 00290 virtual void removeField (const RecordFieldId&) = 0; 00291 00292 // Define a value for the given field. 00293 // Array conformance rules will not be applied for variable shaped arrays. 00294 // If the field and value data type mismatch, type promotion 00295 // of scalars will be done if possible. If not possible, an exception 00296 // is thrown. 00297 // <br> 00298 // If the field does not exist, it will be added to the record. 00299 // This results in an exception for fixed structured records. 00300 // The field is checked by a possible field checking function 00301 // before it gets added. 00302 // <group> 00303 void define (const RecordFieldId&, Bool value); 00304 void define (const RecordFieldId&, uChar value); 00305 void define (const RecordFieldId&, Short value); 00306 void define (const RecordFieldId&, Int value); 00307 void define (const RecordFieldId&, uInt value); 00308 void define (const RecordFieldId&, Int64 value); 00309 void define (const RecordFieldId&, Float value); 00310 void define (const RecordFieldId&, Double value); 00311 void define (const RecordFieldId&, const Complex& value); 00312 void define (const RecordFieldId&, const DComplex& value); 00313 void define (const RecordFieldId&, const Char* value); 00314 void define (const RecordFieldId&, const String& value); 00315 void define (const RecordFieldId&, const Array<Bool>& value, 00316 Bool FixedShape = False); 00317 void define (const RecordFieldId&, const Array<uChar>& value, 00318 Bool FixedShape = False); 00319 void define (const RecordFieldId&, const Array<Short>& value, 00320 Bool FixedShape = False); 00321 void define (const RecordFieldId&, const Array<Int>& value, 00322 Bool FixedShape = False); 00323 void define (const RecordFieldId&, const Array<uInt>& value, 00324 Bool FixedShape = False); 00325 void define (const RecordFieldId&, const Array<Int64>& value, 00326 Bool FixedShape = False); 00327 void define (const RecordFieldId&, const Array<Float>& value, 00328 Bool FixedShape = False); 00329 void define (const RecordFieldId&, const Array<Double>& value, 00330 Bool FixedShape = False); 00331 void define (const RecordFieldId&, const Array<Complex>& value, 00332 Bool FixedShape = False); 00333 void define (const RecordFieldId&, const Array<DComplex>& value, 00334 Bool FixedShape = False); 00335 void define (const RecordFieldId&, const Array<String>& value, 00336 Bool FixedShape = False); 00337 virtual void defineRecord (const RecordFieldId&, 00338 const RecordInterface& value, 00339 RecordType = Variable) = 0; 00340 // </group> 00341 00342 // Get the value of the given field. 00343 // If the field and value data type mismatch, type promotion 00344 // of scalars will be done if possible. If not possible, an exception 00345 // is thrown. 00346 // If the value argument is an array, it will be reshaped if needed. 00347 // <group> 00348 void get (const RecordFieldId&, Bool& value) const; 00349 void get (const RecordFieldId&, uChar& value) const; 00350 void get (const RecordFieldId&, Short& value) const; 00351 void get (const RecordFieldId&, Int& value) const; 00352 void get (const RecordFieldId&, uInt& value) const; 00353 void get (const RecordFieldId&, Int64& value) const; 00354 void get (const RecordFieldId&, Float& value) const; 00355 void get (const RecordFieldId&, Double& value) const; 00356 void get (const RecordFieldId&, Complex& value) const; 00357 void get (const RecordFieldId&, DComplex& value) const; 00358 void get (const RecordFieldId&, String& value) const; 00359 void get (const RecordFieldId&, Array<Bool>& value) const; 00360 void get (const RecordFieldId&, Array<uChar>& value) const; 00361 void get (const RecordFieldId&, Array<Short>& value) const; 00362 void get (const RecordFieldId&, Array<Int>& value) const; 00363 void get (const RecordFieldId&, Array<uInt>& value) const; 00364 void get (const RecordFieldId&, Array<Int64>& value) const; 00365 void get (const RecordFieldId&, Array<Float>& value) const; 00366 void get (const RecordFieldId&, Array<Double>& value) const; 00367 void get (const RecordFieldId&, Array<Complex>& value) const; 00368 void get (const RecordFieldId&, Array<DComplex>& value) const; 00369 void get (const RecordFieldId&, Array<String>& value) const; 00370 // </group> 00371 00372 // The following functions get the value based on field name or number. 00373 // The scalar functions promote the data type if needed. It also supports 00374 // conversion of Int to Bool. 00375 // <br>The array functions throw an exception if the data type mismatches. 00376 // The toArrayX function can be used for array type promotion. 00377 // <group> 00378 Bool asBool (const RecordFieldId&) const; 00379 uChar asuChar (const RecordFieldId&) const; 00380 Short asShort (const RecordFieldId&) const; 00381 Int asInt (const RecordFieldId&) const; 00382 uInt asuInt (const RecordFieldId&) const; 00383 Int64 asInt64 (const RecordFieldId&) const; 00384 Float asFloat (const RecordFieldId&) const; 00385 Double asDouble (const RecordFieldId&) const; 00386 Complex asComplex (const RecordFieldId&) const; 00387 DComplex asDComplex(const RecordFieldId&) const; 00388 const String& asString (const RecordFieldId&) const; 00389 const Array<Bool>& asArrayBool (const RecordFieldId&) const; 00390 const Array<uChar>& asArrayuChar (const RecordFieldId&) const; 00391 const Array<Short>& asArrayShort (const RecordFieldId&) const; 00392 const Array<Int>& asArrayInt (const RecordFieldId&) const; 00393 const Array<uInt>& asArrayuInt (const RecordFieldId&) const; 00394 const Array<Int64>& asArrayInt64 (const RecordFieldId&) const; 00395 const Array<Float>& asArrayFloat (const RecordFieldId&) const; 00396 const Array<Double>& asArrayDouble (const RecordFieldId&) const; 00397 const Array<Complex>& asArrayComplex (const RecordFieldId&) const; 00398 const Array<DComplex>& asArrayDComplex(const RecordFieldId&) const; 00399 const Array<String>& asArrayString (const RecordFieldId&) const; 00400 virtual const RecordInterface& asRecord (const RecordFieldId&) const = 0; 00401 virtual RecordInterface& asrwRecord (const RecordFieldId&) = 0; 00402 // </group> 00403 00404 // Get an array while promoting the data as needed. 00405 // Int values can be converted to Bool. 00406 // A scalar value is also converted to an array. 00407 // These functions are slower than <src>asX</src>, but more general. 00408 // <group> 00409 Array<Bool> toArrayBool (const RecordFieldId&) const; 00410 Array<uChar> toArrayuChar (const RecordFieldId&) const; 00411 Array<Short> toArrayShort (const RecordFieldId&) const; 00412 Array<Int> toArrayInt (const RecordFieldId&) const; 00413 Array<uInt> toArrayuInt (const RecordFieldId&) const; 00414 Array<Int64> toArrayInt64 (const RecordFieldId&) const; 00415 Array<Float> toArrayFloat (const RecordFieldId&) const; 00416 Array<Double> toArrayDouble (const RecordFieldId&) const; 00417 Array<Complex> toArrayComplex (const RecordFieldId&) const; 00418 Array<DComplex> toArrayDComplex(const RecordFieldId&) const; 00419 Array<String> toArrayString (const RecordFieldId&) const; 00420 void toArray (const RecordFieldId& id, Array<Bool>& array) const 00421 { array.reference (toArrayBool (id)); } 00422 void toArray (const RecordFieldId& id, Array<uChar>& array) const 00423 { array.reference (toArrayuChar (id)); } 00424 void toArray (const RecordFieldId& id, Array<Short>& array) const 00425 { array.reference (toArrayShort (id)); } 00426 void toArray (const RecordFieldId& id, Array<Int>& array) const 00427 { array.reference (toArrayInt (id)); } 00428 void toArray (const RecordFieldId& id, Array<uInt>& array) const 00429 { array.reference (toArrayuInt (id)); } 00430 void toArray (const RecordFieldId& id, Array<Int64>& array) const 00431 { array.reference (toArrayInt64 (id)); } 00432 void toArray (const RecordFieldId& id, Array<Float>& array) const 00433 { array.reference (toArrayFloat (id)); } 00434 void toArray (const RecordFieldId& id, Array<Double>& array) const 00435 { array.reference (toArrayDouble (id)); } 00436 void toArray (const RecordFieldId& id, Array<Complex>& array) const 00437 { array.reference (toArrayComplex (id)); } 00438 void toArray (const RecordFieldId& id, Array<DComplex>& array) const 00439 { array.reference (toArrayDComplex (id)); } 00440 void toArray (const RecordFieldId& id, Array<String>& array) const 00441 { array.reference (toArrayString (id)); } 00442 // </group> 00443 00444 // Get value based on field name or number. 00445 // They are here for backward compatibility with the old KeywordSet 00446 // classes and will be removed in the future. 00447 // <group> 00448 Float asfloat (const RecordFieldId&) const; 00449 Double asdouble (const RecordFieldId&) const; 00450 const Array<Float>& asArrayfloat (const RecordFieldId&) const; 00451 const Array<Double>& asArraydouble (const RecordFieldId&) const; 00452 // </group> 00453 00454 // Make a unique record representation 00455 // (for copy-on-write in RecordFieldPtr). 00456 virtual void makeUnique() = 0; 00457 00458 // Define a data field (for RecordFieldPtr). 00459 //# This function has to be public for the global defineRecordFieldPtr 00460 //# functions in RecordField.h. 00461 virtual void defineDataField (Int whichField, DataType type, 00462 const void* value) = 0; 00463 00464 // Used by the RecordFieldPtr classes to attach to the correct field. 00465 //# This function has to be public for the global attachRecordFieldPtr 00466 //# functions in RecordField.h. 00467 // The latter function is used to attach to a Record-type field 00468 // checking if the correct Record type is used. 00469 // <group> 00470 virtual void* get_pointer (Int whichField, DataType type) const = 0; 00471 virtual void* get_pointer (Int whichField, DataType type, 00472 const String& recordType) const = 0; 00473 // </group> 00474 00475 // Print the contents of the record. 00476 // Only the first <src>maxNrValues</src> of an array will be printed. 00477 // A value < 0 means the entire array. 00478 // <group> 00479 friend inline std::ostream& operator<< (std::ostream& os, 00480 const RecordInterface& rec) 00481 { rec.print (os, 25, " "); return os; } 00482 virtual void print (std::ostream&, 00483 Int maxNrValues = 25, 00484 const String& indent="") const = 0; 00485 // </group> 00486 00487 00488 protected: 00489 // Let the derived class add an array field with the given type, shape, 00490 // and value. 00491 virtual void addDataField (const String& name, DataType type, 00492 const IPosition& shape, Bool fixedShape, 00493 const void* value) = 0; 00494 00495 // Check if the Record has a non-fixed structure. 00496 // If it is fixed, it throws an exception. 00497 // This can be used by other functions (like define). 00498 void throwIfFixed() const; 00499 00500 // Check if the new field name is correct. 00501 // This is done by calling the checkFunction (if defined). 00502 // If incorrect, an exception is thrown. 00503 void checkName (const String& fieldName, DataType type) const; 00504 00505 // Give access to the RecordType flag (write-access is needed when 00506 // a record is read back). 00507 // <group> 00508 RecordType& recordType(); 00509 RecordType recordType() const; 00510 // </group> 00511 00512 // Get the field number for the given field id. 00513 // It returns -1 if an unknown name was given. 00514 Int newIdToNumber (const RecordFieldId&) const; 00515 00516 // Add a scalar field with the given type and value. 00517 // An exception is thrown if the record structure is fixed 00518 // or if the name is invalid. 00519 void defineField (const RecordFieldId&, DataType type, const void* value); 00520 00521 // Add an array field with the given type, shape and value. 00522 // An exception is thrown if the record structure is fixed 00523 // or if the name is invalid. 00524 void defineField (const RecordFieldId&, DataType type, 00525 const IPosition& shape, Bool fixedShape, 00526 const void* value); 00527 00528 00529 private: 00530 // Get the description of this record. 00531 virtual RecordDesc getDescription() const = 0; 00532 00533 // Holds the callback function plus argument. 00534 CheckFieldFunction* checkFunction_p; 00535 const void* checkArgument_p; 00536 00537 // Defines if the Record has a fixed structure. 00538 RecordType type_p; 00539 }; 00540 00541 00542 inline Bool RecordInterface::isFixed() const 00543 { 00544 return (type_p == Fixed); 00545 } 00546 inline Bool RecordInterface::isDefined (const String& fieldName) const 00547 { 00548 return (fieldNumber(fieldName) >= 0); 00549 } 00550 inline RecordInterface::RecordType& RecordInterface::recordType() 00551 { 00552 return type_p; 00553 } 00554 inline RecordInterface::RecordType RecordInterface::recordType() const 00555 { 00556 return type_p; 00557 } 00558 inline DataType RecordInterface::dataType (const RecordFieldId& id) const 00559 { 00560 return type (idToNumber(id)); 00561 } 00562 inline void RecordInterface::define (const RecordFieldId& id, const Char* value) 00563 { 00564 define (id, String(value)); 00565 } 00566 inline Float RecordInterface::asfloat (const RecordFieldId& id) const 00567 { 00568 return asFloat (id); 00569 } 00570 inline Double RecordInterface::asdouble (const RecordFieldId& id) const 00571 { 00572 return asDouble (id); 00573 } 00574 inline const Array<Float>& RecordInterface::asArrayfloat 00575 (const RecordFieldId& id) const 00576 { 00577 return asArrayFloat (id); 00578 } 00579 inline const Array<Double>& RecordInterface::asArraydouble 00580 (const RecordFieldId& id) const 00581 { 00582 return asArrayDouble (id); 00583 } 00584 00585 00586 00587 00588 // <summary> 00589 // Helper class to notify class Record about changes 00590 // </summary> 00591 00592 // <use visibility=local> 00593 00594 // <reviewed reviewer="Mark Wieringa" date="1996/04/15" tests="tRecord"> 00595 // </reviewed> 00596 00597 // <prerequisite> 00598 // <li> <linkto class="Notice">Notice</linkto>. 00599 // </prerequisite> 00600 00601 // <synopsis> 00602 // This class is of essentially no interest. The Notification system which is 00603 // used to invalidate RecordFieldPtr's to a destructed or changed record 00604 // requires that a class derived from Notice be available to carry 00605 // messages. There are 3 messages which are described below. 00606 // </synopsis> 00607 00608 class RecordNotice : public Notice 00609 { 00610 public: 00611 // Define the possible change types. 00612 enum NoticeType { 00613 // Record has been deleted; detach all RecordFieldPtr's. 00614 DETACH, 00615 // RecordRep has been copied; re-acquire the pointers in 00616 // all RecordFieldPtr's. 00617 ACQUIRE, 00618 // A field has been removed; detach that RecordFieldPtr and 00619 // decrement field numbers in RecordFieldPtr's following it. 00620 REMOVE}; 00621 00622 // Construct a notice for the given type and field number. 00623 // The field number is only used for type REMOVE. 00624 RecordNotice (NoticeType changeType, uInt fieldNumber); 00625 00626 // Returns the change type. 00627 virtual uInt type() const; 00628 00629 // Always returns False. 00630 virtual int operator== (const Notice& that) const; 00631 00632 // Return the change type. 00633 NoticeType changeType() const; 00634 00635 // Return the field number. 00636 Int fieldNumber() const; 00637 00638 private: 00639 NoticeType changeType_p; 00640 uInt fieldNumber_p; //# only used for REMOVE 00641 }; 00642 00643 00644 inline RecordNotice::NoticeType RecordNotice::changeType() const 00645 { 00646 return changeType_p; 00647 } 00648 inline Int RecordNotice::fieldNumber() const 00649 { 00650 return fieldNumber_p; 00651 } 00652 00653 00654 00655 00656 } //# NAMESPACE CASA - END 00657 00658 #endif