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