casacore
RecordInterface.h
Go to the documentation of this file.
1 //# RecordInterface.h: Abstract base class for Record classes
2 //# Copyright (C) 1996,1997,1998,1999,2001
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //#
27 //# $Id$
28 
29 
30 #ifndef CASA_RECORDINTERFACE_H
31 #define CASA_RECORDINTERFACE_H
32 
33 
34 //# Includes
35 #include <casacore/casa/aips.h>
36 #include <casacore/casa/BasicSL/String.h>
37 #include <casacore/casa/Utilities/Notice.h>
38 #include <casacore/casa/Utilities/DataType.h>
39 #include <casacore/casa/Containers/RecordFieldId.h>
40 #include <casacore/casa/Arrays/Array.h>
41 
42 namespace casacore { //# NAMESPACE CASACORE - BEGIN
43 
44 //# Forward Declarations
45 class RecordDesc;
46 class IPosition;
47 
48 
49 // <summary>
50 // Abstract base class for Record classes
51 // </summary>
52 
53 // <use visibility=export>
54 // <reviewed reviewer="Mark Wieringa" date="1996/04/15" tests="tRecord">
55 // </reviewed>
56 
57 //# <prerequisite>
58 //# </prerequisite>
59 
60 // <etymology>
61 // ``Record'' is a widely used term in both programming languages and data
62 // structures to denote an imhogeneous set of fields. An alternative would
63 // have been to name it <em>struct</em>ure, which would have perhaps been
64 // a clearer name for C++ programmers.
65 // <br>
66 // RecordInterface denotes that this class defines the common interface to
67 // possible Record classes.
68 // </etymology>
69 
70 // <synopsis>
71 // A Record is an inhomogeneous, hierarchical, collection of named fields. The
72 // fields may be of scalar type, array type, a Table or a Record. This latter
73 // feature is what makes the Record a (potentially) hierarchical type.
74 // <p>
75 // RecordInterface is the abstract base class for various Record classes.
76 // At the moment three Record classes exist:
77 // <ul>
78 // <li> <linkto class=Record>Record</linkto>
79 // <li> <linkto class=TableRecord>TableRecord</linkto>
80 // </ul>
81 // Presently, the scalar types are chosen to be compatible with the native
82 // types of the Table system, viz: Bool, uChar, Short, Int, uInt, Int64,
83 // Float, Double, Complex, DComplex, String.
84 // Arrays of all these types are also available.
85 // It is fairly straightforward to extend this set if necessary, although it
86 // will result in more template instantiations with the current implementation.
87 // <p>
88 // Each field has an integral index, which ranges between 0 and
89 // <src>nfields() - 1</src>. The values of a field can be manipulated
90 // in two ways:
91 // <ol>
92 // <li> Through the get and put functions in this class.
93 // They are easy to use and support type promotion.
94 // However, they are a bit less efficient than the second way.
95 // <li> Through the class
96 // <linkto class="RecordFieldPtr">RecordFieldPtr</linkto>.
97 // This is a bit less convenient. However, it is more efficient if
98 // the same field is accessed multiple times.
99 // </ol>
100 // The structure of a record can be fixed or variable.
101 // If fixed, it is not possible to change the structure once the
102 // record has been instantiated. If variable, the record can be
103 // restructured or fields can be added/removed.
104 // <br>
105 // When a field gets added, it is possible to check if its name and
106 // type are valid by means of the CheckFunction callback. This is
107 // for instance used by the table system to assure that keywords
108 // and columns in a table do not have the same name.
109 // <p>
110 // Arrays in a record description can be fixed or variable shaped.
111 // If fixed shaped, only arrays with that shape can be stored
112 // in that field in the record. If variable shaped, any array
113 // can be stored.
114 // <br> However, note there is a difference between assign and define.
115 // Assign invokes the array assignment operator which checks for
116 // conformance. Thus even for variable shaped arrays, the new array
117 // must conform the exisitng one when using assign. Define simply replaces
118 // the array, thus for variable shaped arrays ay array shape will do.
119 // <p>
120 // RecordFieldPtr objects attached to a Record have to be notified when
121 // the Record is deleted or changed.
122 // The RecordInterface class provides the hooks for this via the
123 // Notice system. It is derived from
124 // <linkto class=NoticeSource> NoticeSource</linkto>. The class
125 // <linkto class=RecordNotice>RecordNotice</linkto> is for the messages.
126 // </synopsis>
127 
128 // <motivation>
129 // This common base class provides a common interface to the various
130 // Record classes.
131 // Furthermore it is needed for the class RecordFieldPtr.
132 // Finally it provides the hooks for the notification in case the
133 // record structure changes.
134 // </motivation>
135 //
136 // <todo asof="1996/03/10">
137 // <li> A record reference class, which contains some fields from another
138 // record, would likely be useful. This would be analagous to a
139 // subarray sliced from an existing array.
140 // </todo>
141 
142 
144 {
145 public:
146  // Define the flag telling if a Record has a fixed or
147  // variable structure.
148  enum RecordType {
149  // Record has a fixed structure; that is, no fields can
150  // be added or removed once the Record is created.
152  // Record has a variable structure; after Record creation
153  // fields can be added or removed at will.
155 
156  // Define the Duplicates flag for the function merge in the various
157  // record classes.
158  // This function merges the fields from that record (description)
159  // into this one.
160  // DuplicatesFlag determines what to do if a field already exists.
162  // Rename a name from the other set to name_n,
163  // where n is the first positive number making the name unique.
165  // Skip duplicate names from the other set.
167  // Overwrite the value of a duplicate keyword
168  // This will also happen if their types differ.
170  // Throw an exception.
172 
173  // Define the signature of the add callback function.
174  // This function is called when a field is added to the record
175  // (thus also when a Record is constructed from a RecordDesc).
176  // The function can check if the name and/or data type are valid.
177  // The extra argument is the argument given to the Record constructor
178  // which can be used to pass non-Record information.
179  // The function should return False if name or data type is invalid.
180  // In that case it can fill the message string, which will be added
181  // to the message in the thrown exception.
182  typedef Bool CheckFieldFunction (const String& fieldName,
183  DataType dataType,
184  const void* extraArgument,
185  String& message);
186 
187  // The default constructor creates an empty record with a variable
188  // structure.
189  RecordInterface();
190 
191  // Create a record with no fields.
192  // The callback function is called when a field is added to the Record.
193  // That function can check the name and of data type of the new field
194  // (for instance, the Table system uses it to ensure that table columns
195  // and keywords have different names).
197  const void* checkArgument);
198 
199  // Copy constructor (copy semantics).
200  RecordInterface (const RecordInterface& other);
201 
202  // Assignment (copy semantics).
203  // This only assigns the RecordInterface object itself,
204  // thus not the data in a derived class.
205  // To do that the function <src>assign</src> below can be used.
207 
208  // Destruct the record.
209  // All attached RecordFieldPtr objects are notified to detach themselves.
211 
212  // Make a copy of this object.
213  virtual RecordInterface* clone() const = 0;
214 
215  // Assign that RecordInterface object to this one.
216  // Unlike <src>operator=</src> it copies all data in the derived
217  // class.
218  virtual void assign (const RecordInterface& that) = 0;
219 
220  // Is the Record structure fixed (i.e. impossible to restructure or
221  // to add or remove fields)?
222  Bool isFixed() const;
223 
224  // How many fields does this structure have?
225  // <group>
226  virtual uInt nfields() const = 0;
227  uInt size() const
228  { return nfields(); }
229  // </group>
230 
231  // Is the record empty?
232  bool empty() const
233  { return size() == 0; }
234 
235  // Get the field number from the field name.
236  // -1 is returned if the field name is unknown.
237  virtual Int fieldNumber (const String& fieldName) const = 0;
238 
239  // Get the field number for the given field id.
240  // It throws an exception if id is unrecognized (e.g. an unknown name).
241  Int idToNumber (const RecordFieldId&) const;
242 
243  // Test if a field name exists.
244  //# Is here for backward compatibility with KeywordSet.
245  Bool isDefined (const String& fieldName) const;
246 
247  // Get the data type of this field (as defined in DataType.h).
248  // <group>
249  virtual DataType type (Int whichField) const = 0;
250  DataType dataType (const RecordFieldId&) const;
251  // </group>
252 
253  // Get the name of this field.
254  String name (const RecordFieldId&) const;
255 
256  // Get the comment for this field.
257  virtual const String& comment (const RecordFieldId&) const = 0;
258 
259  // Set the comment for this field.
260  virtual void setComment (const RecordFieldId&, const String& comment) = 0;
261 
262  // Get the actual shape of this field.
263  // It returns [1] for non-array fields.
264  IPosition shape (const RecordFieldId&) const;
265 
266  // Get the description of this record.
267  RecordDesc description() const;
268 
269  // Change the structure of this Record to contain the fields in
270  // newDescription. After calling restructure, <src>description() ==
271  // newDescription</src>. Any existing RecordFieldPtr objects are
272  // invalidated (their <src>isAttached()</src> members return False) after
273  // this call.
274  // <br>If the new description contains subrecords, those subrecords
275  // will be restructured if <src>recursive=True</src> is given.
276  // Otherwise the subrecord is a variable empty record.
277  // Subrecords will be variable if their description is empty (i.e. does
278  // not contain any field), otherwise they are fixed.
279  // <br>Restructuring is not possible and an exception is thrown
280  // if the Record has a fixed structure.
281  virtual void restructure (const RecordDesc& newDescription,
282  Bool recursive=True) = 0;
283 
284  // Remove a field from the record.
285  // <note role=caution>
286  // Removing a field means that the field number of the fields following
287  // it will be decremented. It will invalidate RecordFieldPtr's
288  // pointing to the removed field, but no other RecordFieldPtr's.
289  // </note>
290  virtual void removeField (const RecordFieldId&) = 0;
291 
292  // Define a value for the given field.
293  // Array conformance rules will not be applied for variable shaped arrays.
294  // If the field and value data type mismatch, type promotion
295  // of scalars will be done if possible. If not possible, an exception
296  // is thrown.
297  // <br>
298  // If the field does not exist, it will be added to the record.
299  // This results in an exception for fixed structured records.
300  // The field is checked by a possible field checking function
301  // before it gets added.
302  // <group>
303  void define (const RecordFieldId&, Bool value);
304  void define (const RecordFieldId&, uChar value);
305  void define (const RecordFieldId&, Short value);
306  void define (const RecordFieldId&, Int value);
307  void define (const RecordFieldId&, uInt value);
308  void define (const RecordFieldId&, Int64 value);
309  void define (const RecordFieldId&, Float value);
310  void define (const RecordFieldId&, Double value);
311  void define (const RecordFieldId&, const Complex& value);
312  void define (const RecordFieldId&, const DComplex& value);
313  void define (const RecordFieldId&, const Char* value);
314  void define (const RecordFieldId&, const String& value);
315  void define (const RecordFieldId&, const Array<Bool>& value,
316  Bool FixedShape = False);
317  void define (const RecordFieldId&, const Array<uChar>& value,
318  Bool FixedShape = False);
319  void define (const RecordFieldId&, const Array<Short>& value,
320  Bool FixedShape = False);
321  void define (const RecordFieldId&, const Array<Int>& value,
322  Bool FixedShape = False);
323  void define (const RecordFieldId&, const Array<uInt>& value,
324  Bool FixedShape = False);
325  void define (const RecordFieldId&, const Array<Int64>& value,
326  Bool FixedShape = False);
327  void define (const RecordFieldId&, const Array<Float>& value,
328  Bool FixedShape = False);
329  void define (const RecordFieldId&, const Array<Double>& value,
330  Bool FixedShape = False);
331  void define (const RecordFieldId&, const Array<Complex>& value,
332  Bool FixedShape = False);
333  void define (const RecordFieldId&, const Array<DComplex>& value,
334  Bool FixedShape = False);
335  void define (const RecordFieldId&, const Array<String>& value,
336  Bool FixedShape = False);
337  virtual void defineRecord (const RecordFieldId&,
338  const RecordInterface& value,
339  RecordType = Variable) = 0;
340  // </group>
341 
342  // Get the value of the given field.
343  // If the field and value data type mismatch, type promotion
344  // of scalars will be done if possible. If not possible, an exception
345  // is thrown.
346  // If the value argument is an array, it will be reshaped if needed.
347  // <group>
348  void get (const RecordFieldId&, Bool& value) const;
349  void get (const RecordFieldId&, uChar& value) const;
350  void get (const RecordFieldId&, Short& value) const;
351  void get (const RecordFieldId&, Int& value) const;
352  void get (const RecordFieldId&, uInt& value) const;
353  void get (const RecordFieldId&, Int64& value) const;
354  void get (const RecordFieldId&, Float& value) const;
355  void get (const RecordFieldId&, Double& value) const;
356  void get (const RecordFieldId&, Complex& value) const;
357  void get (const RecordFieldId&, DComplex& value) const;
358  void get (const RecordFieldId&, String& value) const;
359  void get (const RecordFieldId&, Array<Bool>& value) const;
360  void get (const RecordFieldId&, Array<uChar>& value) const;
361  void get (const RecordFieldId&, Array<Short>& value) const;
362  void get (const RecordFieldId&, Array<Int>& value) const;
363  void get (const RecordFieldId&, Array<uInt>& value) const;
364  void get (const RecordFieldId&, Array<Int64>& value) const;
365  void get (const RecordFieldId&, Array<Float>& value) const;
366  void get (const RecordFieldId&, Array<Double>& value) const;
367  void get (const RecordFieldId&, Array<Complex>& value) const;
368  void get (const RecordFieldId&, Array<DComplex>& value) const;
369  void get (const RecordFieldId&, Array<String>& value) const;
370  // </group>
371 
372  // The following functions get the value based on field name or number.
373  // The scalar functions promote the data type if needed. It also supports
374  // conversion of Int to Bool.
375  // <br>The array functions throw an exception if the data type mismatches.
376  // The toArrayX function can be used for array type promotion.
377  // <group>
378  Bool asBool (const RecordFieldId&) const;
379  uChar asuChar (const RecordFieldId&) const;
380  Short asShort (const RecordFieldId&) const;
381  Int asInt (const RecordFieldId&) const;
382  uInt asuInt (const RecordFieldId&) const;
383  Int64 asInt64 (const RecordFieldId&) const;
384  Float asFloat (const RecordFieldId&) const;
385  Double asDouble (const RecordFieldId&) const;
386  Complex asComplex (const RecordFieldId&) const;
387  DComplex asDComplex(const RecordFieldId&) const;
388  const String& asString (const RecordFieldId&) const;
389  const Array<Bool>& asArrayBool (const RecordFieldId&) const;
390  const Array<uChar>& asArrayuChar (const RecordFieldId&) const;
391  const Array<Short>& asArrayShort (const RecordFieldId&) const;
392  const Array<Int>& asArrayInt (const RecordFieldId&) const;
393  const Array<uInt>& asArrayuInt (const RecordFieldId&) const;
394  const Array<Int64>& asArrayInt64 (const RecordFieldId&) const;
395  const Array<Float>& asArrayFloat (const RecordFieldId&) const;
396  const Array<Double>& asArrayDouble (const RecordFieldId&) const;
397  const Array<Complex>& asArrayComplex (const RecordFieldId&) const;
398  const Array<DComplex>& asArrayDComplex(const RecordFieldId&) const;
399  const Array<String>& asArrayString (const RecordFieldId&) const;
400  virtual const RecordInterface& asRecord (const RecordFieldId&) const = 0;
401  virtual RecordInterface& asrwRecord (const RecordFieldId&) = 0;
402  // </group>
403 
404  // Get an array while promoting the data as needed.
405  // Int values can be converted to Bool.
406  // A scalar value is also converted to an array.
407  // These functions are slower than <src>asX</src>, but more general.
408  // <group>
409  Array<Bool> toArrayBool (const RecordFieldId&) const;
410  Array<uChar> toArrayuChar (const RecordFieldId&) const;
411  Array<Short> toArrayShort (const RecordFieldId&) const;
412  Array<Int> toArrayInt (const RecordFieldId&) const;
413  Array<uInt> toArrayuInt (const RecordFieldId&) const;
414  Array<Int64> toArrayInt64 (const RecordFieldId&) const;
415  Array<Float> toArrayFloat (const RecordFieldId&) const;
420  void toArray (const RecordFieldId& id, Array<Bool>& array) const
421  { array.reference (toArrayBool (id)); }
422  void toArray (const RecordFieldId& id, Array<uChar>& array) const
423  { array.reference (toArrayuChar (id)); }
424  void toArray (const RecordFieldId& id, Array<Short>& array) const
425  { array.reference (toArrayShort (id)); }
426  void toArray (const RecordFieldId& id, Array<Int>& array) const
427  { array.reference (toArrayInt (id)); }
428  void toArray (const RecordFieldId& id, Array<uInt>& array) const
429  { array.reference (toArrayuInt (id)); }
430  void toArray (const RecordFieldId& id, Array<Int64>& array) const
431  { array.reference (toArrayInt64 (id)); }
432  void toArray (const RecordFieldId& id, Array<Float>& array) const
433  { array.reference (toArrayFloat (id)); }
434  void toArray (const RecordFieldId& id, Array<Double>& array) const
435  { array.reference (toArrayDouble (id)); }
436  void toArray (const RecordFieldId& id, Array<Complex>& array) const
437  { array.reference (toArrayComplex (id)); }
438  void toArray (const RecordFieldId& id, Array<DComplex>& array) const
439  { array.reference (toArrayDComplex (id)); }
440  void toArray (const RecordFieldId& id, Array<String>& array) const
441  { array.reference (toArrayString (id)); }
442  // </group>
443 
444  // Get value based on field name or number.
445  // They are here for backward compatibility with the old KeywordSet
446  // classes and will be removed in the future.
447  // <group>
448  Float asfloat (const RecordFieldId&) const;
449  Double asdouble (const RecordFieldId&) const;
450  const Array<Float>& asArrayfloat (const RecordFieldId&) const;
451  const Array<Double>& asArraydouble (const RecordFieldId&) const;
452  // </group>
453 
454  // Make a unique record representation
455  // (for copy-on-write in RecordFieldPtr).
456  virtual void makeUnique() = 0;
457 
458  // Define a data field (for RecordFieldPtr).
459  //# This function has to be public for the global defineRecordFieldPtr
460  //# functions in RecordField.h.
461  virtual void defineDataField (Int whichField, DataType type,
462  const void* value) = 0;
463 
464  // Used by the RecordFieldPtr classes to attach to the correct field.
465  //# This function has to be public for the global attachRecordFieldPtr
466  //# functions in RecordField.h.
467  // The latter function is used to attach to a Record-type field
468  // checking if the correct Record type is used.
469  // <group>
470  virtual void* get_pointer (Int whichField, DataType type) const = 0;
471  virtual void* get_pointer (Int whichField, DataType type,
472  const String& recordType) const = 0;
473  // </group>
474 
475  // Print the contents of the record.
476  // Only the first <src>maxNrValues</src> of an array will be printed.
477  // A value < 0 means the entire array.
478  // <group>
479  friend inline std::ostream& operator<< (std::ostream& os,
480  const RecordInterface& rec)
481  { rec.print (os, 25, " "); return os; }
482  virtual void print (std::ostream&,
483  Int maxNrValues = 25,
484  const String& indent="") const = 0;
485  // </group>
486 
487 
488 protected:
489  // Let the derived class add an array field with the given type, shape,
490  // and value.
491  virtual void addDataField (const String& name, DataType type,
492  const IPosition& shape, Bool fixedShape,
493  const void* value) = 0;
494 
495  // Check if the Record has a non-fixed structure.
496  // If it is fixed, it throws an exception.
497  // This can be used by other functions (like define).
498  void throwIfFixed() const;
499 
500  // Check if the new field name is correct.
501  // This is done by calling the checkFunction (if defined).
502  // If incorrect, an exception is thrown.
503  void checkName (const String& fieldName, DataType type) const;
504 
505  // Give access to the RecordType flag (write-access is needed when
506  // a record is read back).
507  // <group>
509  RecordType recordType() const;
510  // </group>
511 
512  // Get the field number for the given field id.
513  // It returns -1 if an unknown name was given.
514  Int newIdToNumber (const RecordFieldId&) const;
515 
516  // Add a scalar field with the given type and value.
517  // An exception is thrown if the record structure is fixed
518  // or if the name is invalid.
519  void defineField (const RecordFieldId&, DataType type, const void* value);
520 
521  // Add an array field with the given type, shape and value.
522  // An exception is thrown if the record structure is fixed
523  // or if the name is invalid.
524  void defineField (const RecordFieldId&, DataType type,
525  const IPosition& shape, Bool fixedShape,
526  const void* value);
527 
528 
529 private:
530  // Get the description of this record.
531  virtual RecordDesc getDescription() const = 0;
532 
533  // Holds the callback function plus argument.
535  const void* checkArgument_p;
536 
537  // Defines if the Record has a fixed structure.
539 };
540 
541 
543 {
544  return (type_p == Fixed);
545 }
546 inline Bool RecordInterface::isDefined (const String& fieldName) const
547 {
548  return (fieldNumber(fieldName) >= 0);
549 }
551 {
552  return type_p;
553 }
555 {
556  return type_p;
557 }
558 inline DataType RecordInterface::dataType (const RecordFieldId& id) const
559 {
560  return type (idToNumber(id));
561 }
562 inline void RecordInterface::define (const RecordFieldId& id, const Char* value)
563 {
564  define (id, String(value));
565 }
567 {
568  return asFloat (id);
569 }
571 {
572  return asDouble (id);
573 }
575  (const RecordFieldId& id) const
576 {
577  return asArrayFloat (id);
578 }
580  (const RecordFieldId& id) const
581 {
582  return asArrayDouble (id);
583 }
584 
585 
586 
587 
588 // <summary>
589 // Helper class to notify class Record about changes
590 // </summary>
591 
592 // <use visibility=local>
593 
594 // <reviewed reviewer="Mark Wieringa" date="1996/04/15" tests="tRecord">
595 // </reviewed>
596 
597 // <prerequisite>
598 // <li> <linkto class="Notice">Notice</linkto>.
599 // </prerequisite>
600 
601 // <synopsis>
602 // This class is of essentially no interest. The Notification system which is
603 // used to invalidate RecordFieldPtr's to a destructed or changed record
604 // requires that a class derived from Notice be available to carry
605 // messages. There are 3 messages which are described below.
606 // </synopsis>
607 
608 class RecordNotice : public Notice
609 {
610 public:
611  // Define the possible change types.
612  enum NoticeType {
613  // Record has been deleted; detach all RecordFieldPtr's.
615  // RecordRep has been copied; re-acquire the pointers in
616  // all RecordFieldPtr's.
618  // A field has been removed; detach that RecordFieldPtr and
619  // decrement field numbers in RecordFieldPtr's following it.
620  REMOVE};
621 
622  // Construct a notice for the given type and field number.
623  // The field number is only used for type REMOVE.
624  RecordNotice (NoticeType changeType, uInt fieldNumber);
625 
626  // Returns the change type.
627  virtual uInt type() const;
628 
629  // Always returns False.
630  virtual int operator== (const Notice& that) const;
631 
632  // Return the change type.
633  NoticeType changeType() const;
634 
635  // Return the field number.
636  Int fieldNumber() const;
637 
638 private:
640  uInt fieldNumber_p; //# only used for REMOVE
641 };
642 
643 
645 {
646  return changeType_p;
647 }
649 {
650  return fieldNumber_p;
651 }
652 
653 
654 
655 
656 } //# NAMESPACE CASACORE - END
657 
658 #endif
Bool asBool(const RecordFieldId &) const
The following functions get the value based on field name or number.
A Vector of integers, for indexing into Array<T> objects.
Definition: IPosition.h:119
void toArray(const RecordFieldId &id, Array< Float > &array) const
const Array< Float > & asArrayfloat(const RecordFieldId &) const
long long Int64
Define the extra non-standard types used by Casacore (like proposed uSize, Size)
Definition: aipsxtype.h:38
int Int
Definition: aipstype.h:47
RecordType
Define the flag telling if a Record has a fixed or variable structure.
virtual const RecordInterface & asRecord(const RecordFieldId &) const =0
Rename a name from the other set to name_n, where n is the first positive number making the name uniq...
IPosition shape(const RecordFieldId &) const
Get the actual shape of this field.
Int idToNumber(const RecordFieldId &) const
Get the field number for the given field id.
virtual void makeUnique()=0
Make a unique record representation (for copy-on-write in RecordFieldPtr).
Int64 asInt64(const RecordFieldId &) const
const Array< String > & asArrayString(const RecordFieldId &) const
const Array< Double > & asArraydouble(const RecordFieldId &) const
Record has been deleted; detach all RecordFieldPtr&#39;s.
bool operator==(const std11_allocator< T > &, const std11_allocator< T > &)
Definition: Allocator.h:99
virtual RecordInterface * clone() const =0
Make a copy of this object.
Int newIdToNumber(const RecordFieldId &) const
Get the field number for the given field id.
DComplex asDComplex(const RecordFieldId &) const
TableExprNode array(const TableExprNode &values, const TableExprNodeSet &shape)
Create an array of the given shape and fill it with the values.
Definition: ExprNode.h:1986
RecordRep has been copied; re-acquire the pointers in all RecordFieldPtr&#39;s.
unsigned char uChar
Definition: aipstype.h:44
void throwIfFixed() const
Check if the Record has a non-fixed structure.
Array< Int64 > toArrayInt64(const RecordFieldId &) const
const Array< Complex > & asArrayComplex(const RecordFieldId &) const
const Array< Bool > & asArrayBool(const RecordFieldId &) const
uChar asuChar(const RecordFieldId &) const
char Char
Definition: aipstype.h:43
void defineField(const RecordFieldId &, DataType type, const void *value)
Add a scalar field with the given type and value.
virtual RecordDesc getDescription() const =0
Get the description of this record.
virtual void removeField(const RecordFieldId &)=0
Remove a field from the record.
bool empty() const
Is the record empty?
const Array< Int64 > & asArrayInt64(const RecordFieldId &) const
const Array< Int > & asArrayInt(const RecordFieldId &) const
Double asdouble(const RecordFieldId &) const
const Array< Double > & asArrayDouble(const RecordFieldId &) const
DataType dataType(const RecordFieldId &) const
virtual void reference(const Array< T > &other)
After invocation, this array and other reference the same storage.
base class for notice originators
Definition: Notice.h:102
Array< uChar > toArrayuChar(const RecordFieldId &) const
Array< Short > toArrayShort(const RecordFieldId &) const
short Short
Definition: aipstype.h:45
Helper class to notify class Record about changes.
Array< Bool > toArrayBool(const RecordFieldId &) const
Get an array while promoting the data as needed.
Float asFloat(const RecordFieldId &) const
Record has a fixed structure; that is, no fields can be added or removed once the Record is created...
The identification of a record field.
Definition: RecordFieldId.h:91
Short asShort(const RecordFieldId &) const
virtual void setComment(const RecordFieldId &, const String &comment)=0
Set the comment for this field.
CheckFieldFunction * checkFunction_p
Holds the callback function plus argument.
Description of the fields in a record object.
Definition: RecordDesc.h:105
uInt asuInt(const RecordFieldId &) const
virtual void defineDataField(Int whichField, DataType type, const void *value)=0
Define a data field (for RecordFieldPtr).
double Double
Definition: aipstype.h:52
void toArray(const RecordFieldId &id, Array< Int > &array) const
Record has a variable structure; after Record creation fields can be added or removed at will...
const Array< uInt > & asArrayuInt(const RecordFieldId &) const
DuplicatesFlag
Define the Duplicates flag for the function merge in the various record classes.
void toArray(const RecordFieldId &id, Array< Bool > &array) const
Double asDouble(const RecordFieldId &) const
virtual RecordInterface & asrwRecord(const RecordFieldId &)=0
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:39
abstract base class for notices
Definition: Notice.h:62
virtual void addDataField(const String &name, DataType type, const IPosition &shape, Bool fixedShape, const void *value)=0
Let the derived class add an array field with the given type, shape, and value.
NoticeType
Define the possible change types.
Float asfloat(const RecordFieldId &) const
Get value based on field name or number.
Bool isDefined(const String &fieldName) const
Test if a field name exists.
Array< Double > toArrayDouble(const RecordFieldId &) const
float Float
Definition: aipstype.h:51
const Array< Short > & asArrayShort(const RecordFieldId &) const
virtual uInt nfields() const =0
How many fields does this structure have?
const Bool False
Definition: aipstype.h:41
virtual DataType type(Int whichField) const =0
Get the data type of this field (as defined in DataType.h).
void checkName(const String &fieldName, DataType type) const
Check if the new field name is correct.
virtual void print(std::ostream &, Int maxNrValues=25, const String &indent="") const =0
RecordDesc description() const
Get the description of this record.
Int fieldNumber() const
Return the field number.
void toArray(const RecordFieldId &id, Array< DComplex > &array) const
void toArray(const RecordFieldId &id, Array< uInt > &array) const
Array< Complex > toArrayComplex(const RecordFieldId &) const
Int asInt(const RecordFieldId &) const
NoticeType changeType() const
Return the change type.
Overwrite the value of a duplicate keyword This will also happen if their types differ.
RecordInterface()
The default constructor creates an empty record with a variable structure.
void toArray(const RecordFieldId &id, Array< Complex > &array) const
void toArray(const RecordFieldId &id, Array< uChar > &array) const
const Array< DComplex > & asArrayDComplex(const RecordFieldId &) const
const String & asString(const RecordFieldId &) const
RecordType & recordType()
Give access to the RecordType flag (write-access is needed when a record is read back).
virtual const String & comment(const RecordFieldId &) const =0
Get the comment for this field.
Complex asComplex(const RecordFieldId &) const
Array< String > toArrayString(const RecordFieldId &) const
virtual void restructure(const RecordDesc &newDescription, Bool recursive=True)=0
Change the structure of this Record to contain the fields in newDescription.
RecordInterface & operator=(const RecordInterface &other)
Assignment (copy semantics).
String: the storage and methods of handling collections of characters.
Definition: String.h:223
virtual void * get_pointer(Int whichField, DataType type) const =0
Used by the RecordFieldPtr classes to attach to the correct field.
RecordType type_p
Defines if the Record has a fixed structure.
void toArray(const RecordFieldId &id, Array< Double > &array) const
Abstract base class for Record classes.
Array< Float > toArrayFloat(const RecordFieldId &) const
Bool CheckFieldFunction(const String &fieldName, DataType dataType, const void *extraArgument, String &message)
Define the signature of the add callback function.
Array< uInt > toArrayuInt(const RecordFieldId &) const
const Array< uChar > & asArrayuChar(const RecordFieldId &) const
const Array< Float > & asArrayFloat(const RecordFieldId &) const
void toArray(const RecordFieldId &id, Array< String > &array) const
void define(const RecordFieldId &, Bool value)
Define a value for the given field.
virtual void assign(const RecordInterface &that)=0
Assign that RecordInterface object to this one.
virtual Int fieldNumber(const String &fieldName) const =0
Get the field number from the field name.
const Bool True
Definition: aipstype.h:40
~RecordInterface()
Destruct the record.
void toArray(const RecordFieldId &id, Array< Short > &array) const
friend std::ostream & operator<<(std::ostream &os, const RecordInterface &rec)
Print the contents of the record.
this file contains all the compiler specific defines
Definition: mainpage.dox:28
Array< Int > toArrayInt(const RecordFieldId &) const
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
String name(const RecordFieldId &) const
Get the name of this field.
unsigned int uInt
Definition: aipstype.h:48
Bool isFixed() const
Is the Record structure fixed (i.e.
Skip duplicate names from the other set.
void toArray(const RecordFieldId &id, Array< Int64 > &array) const
Array< DComplex > toArrayDComplex(const RecordFieldId &) const
virtual void defineRecord(const RecordFieldId &, const RecordInterface &value, RecordType=Variable)=0