RecordInterface.h

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

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1