casacore
Loading...
Searching...
No Matches
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: casa-feedback@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#ifndef CASA_RECORDINTERFACE_H
28#define CASA_RECORDINTERFACE_H
29
30
31//# Includes
32#include <casacore/casa/aips.h>
33#include <casacore/casa/BasicSL/String.h>
34#include <casacore/casa/Utilities/DataType.h>
35#include <casacore/casa/Containers/RecordFieldId.h>
36#include <casacore/casa/Arrays/Array.h>
37
38namespace casacore { //# NAMESPACE CASACORE - BEGIN
39
40//# Forward Declarations
41class RecordDesc;
42class ValueHolder;
43class IPosition;
44
45
46// <summary>
47// Abstract base class for Record classes
48// </summary>
49
50// <use visibility=export>
51// <reviewed reviewer="Mark Wieringa" date="1996/04/15" tests="tRecord">
52// </reviewed>
53
54//# <prerequisite>
55//# </prerequisite>
56
57// <etymology>
58// ``Record'' is a widely used term in both programming languages and data
59// structures to denote an imhogeneous set of fields. An alternative would
60// have been to name it <em>struct</em>ure, which would have perhaps been
61// a clearer name for C++ programmers.
62// <br>
63// RecordInterface denotes that this class defines the common interface to
64// possible Record classes.
65// </etymology>
66
67// <synopsis>
68// A Record is an heterogeneous, hierarchical, collection of named fields. The
69// fields may be of scalar type, array type, a Table or a Record. This latter
70// feature is what makes the Record a (potentially) hierarchical type.
71// <p>
72// RecordInterface is the abstract base class for various Record classes.
73// At the moment three Record classes exist:
74// <ul>
75// <li> <linkto class=Record>Record</linkto>
76// <li> <linkto class=TableRecord>TableRecord</linkto>
77// </ul>
78// Presently, the scalar types are chosen to be compatible with the native
79// types of the Table system, viz: Bool, uChar, Short, Int, uInt, Int64,
80// Float, Double, Complex, DComplex, String.
81// Arrays of all these types are also available.
82// It is fairly straightforward to extend this set if necessary, although it
83// will result in more template instantiations with the current implementation.
84// <p>
85// Each field has an integral index, which ranges between 0 and
86// <src>nfields() - 1</src>. The values of a field can be manipulated
87// in two ways:
88// <ol>
89// <li> Through the get and put functions in this class.
90// They are easy to use and support type promotion.
91// However, they are a bit less efficient than the second way.
92// <li> Through the class
93// <linkto class="RecordFieldPtr">RecordFieldPtr</linkto>.
94// This is a bit less convenient. However, it is more efficient if
95// the same field is accessed multiple times.
96// </ol>
97// The structure of a record can be fixed or variable.
98// If fixed, it is not possible to change the structure once the
99// record has been instantiated. If variable, the record can be
100// restructured or fields can be added/removed.
101// <br>
102// When a field gets added, it is possible to check if its name and
103// type are valid by means of the CheckFunction callback. This is
104// for instance used by the table system to assure that keywords
105// and columns in a table do not have the same name.
106// <p>
107// Arrays in a record description can be fixed or variable shaped.
108// If fixed shaped, only arrays with that shape can be stored
109// in that field in the record. If variable shaped, any array
110// can be stored.
111// <br> However, note there is a difference between assign and define.
112// Assign invokes the array assignment operator which checks for
113// conformance. Thus even for variable shaped arrays, the new array
114// must conform the exisitng one when using assign. Define simply replaces
115// the array, thus for variable shaped arrays ay array shape will do.
116// <p>
117// RecordFieldPtr objects attached to a Record have to be notified when
118// the Record is deleted or changed.
119// The RecordInterface class provides the hooks for this via the
120// Notice system. It is derived from
121// <linkto class=NoticeSource> NoticeSource</linkto>. The class
122// <linkto class=RecordNotice>RecordNotice</linkto> is for the messages.
123// </synopsis>
124
125// <motivation>
126// This common base class provides a common interface to the various
127// Record classes.
128// Furthermore it is needed for the class RecordFieldPtr.
129// Finally it provides the hooks for the notification in case the
130// record structure changes.
131// </motivation>
132//
133// <todo asof="1996/03/10">
134// <li> A record reference class, which contains some fields from another
135// record, would likely be useful. This would be analagous to a
136// subarray sliced from an existing array.
137// </todo>
138
139
141{
142public:
143 // Define the flag telling if a Record has a fixed or
144 // variable structure.
146 // Record has a fixed structure; that is, no fields can
147 // be added or removed once the Record is created.
149 // Record has a variable structure; after Record creation
150 // fields can be added or removed at will.
152
153 // Define the Duplicates flag for the function merge in the various
154 // record classes.
155 // This function merges the fields from that record (description)
156 // into this one.
157 // DuplicatesFlag determines what to do if a field already exists.
159 // Rename a name from the other set to name_n,
160 // where n is the first positive number making the name unique.
162 // Skip duplicate names from the other set.
164 // Overwrite the value of a duplicate keyword
165 // This will also happen if their types differ.
167 // Throw an exception.
169
170 // Define the signature of the add callback function.
171 // This function is called when a field is added to the record
172 // (thus also when a Record is constructed from a RecordDesc).
173 // The function can check if the name and/or data type are valid.
174 // The extra argument is the argument given to the Record constructor
175 // which can be used to pass non-Record information.
176 // The function should return False if name or data type is invalid.
177 // In that case it can fill the message string, which will be added
178 // to the message in the thrown exception.
179 typedef Bool CheckFieldFunction (const String& fieldName,
180 DataType dataType,
181 const void* extraArgument,
182 String& message);
183
184 // The default constructor creates an empty record with a variable
185 // structure.
187
188 // Create a record with no fields.
189 // The callback function is called when a field is added to the Record.
190 // That function can check the name and of data type of the new field
191 // (for instance, the Table system uses it to ensure that table columns
192 // and keywords have different names).
194 const void* checkArgument);
195
196 // Copy constructor (copy semantics).
198
199 // Assignment (copy semantics).
200 // This only assigns the RecordInterface object itself,
201 // thus not the data in a derived class.
202 // To do that the function <src>assign</src> below can be used.
204
205 // Destruct the record.
206 // All attached RecordFieldPtr objects are notified to detach themselves.
208
209 // Make a copy of this object.
210 virtual RecordInterface* clone() const = 0;
211
212 // Assign that RecordInterface object to this one.
213 // Unlike <src>operator=</src> it copies all data in the derived
214 // class.
215 virtual void assign (const RecordInterface& that) = 0;
216
217 // Is the Record structure fixed (i.e. impossible to restructure or
218 // to add or remove fields)?
219 Bool isFixed() const;
220
221 // How many fields does this structure have?
222 // <group>
223 virtual uInt nfields() const = 0;
224 uInt size() const
225 { return nfields(); }
226 // </group>
227
228 // Is the record empty?
229 bool empty() const
230 { return size() == 0; }
231
232 // Get the field number from the field name.
233 // -1 is returned if the field name is unknown.
234 virtual Int fieldNumber (const String& fieldName) const = 0;
235
236 // Get the field number for the given field id.
237 // It throws an exception if id is unrecognized (e.g. an unknown name).
239
240 // Test if a field name exists.
241 //# Is here for backward compatibility with KeywordSet.
242 Bool isDefined (const String& fieldName) const;
243
244 // Get the data type of this field (as defined in DataType.h).
245 // <group>
246 virtual DataType type (Int whichField) const = 0;
247 DataType dataType (const RecordFieldId&) const;
248 // </group>
249
250 // Get the name of this field.
251 String name (const RecordFieldId&) const;
252
253 // Get the comment for this field.
254 virtual const String& comment (const RecordFieldId&) const = 0;
255
256 // Set the comment for this field.
257 virtual void setComment (const RecordFieldId&, const String& comment) = 0;
258
259 // Get the actual shape of this field.
260 // It returns [1] for non-array fields.
262
263 // Get the description of this record.
265
266 // Change the structure of this Record to contain the fields in
267 // newDescription. After calling restructure, <src>description() ==
268 // newDescription</src>. Any existing RecordFieldPtr objects are
269 // invalidated (their <src>isAttached()</src> members return False) after
270 // this call.
271 // <br>If the new description contains subrecords, those subrecords
272 // will be restructured if <src>recursive=True</src> is given.
273 // Otherwise the subrecord is a variable empty record.
274 // Subrecords will be variable if their description is empty (i.e. does
275 // not contain any field), otherwise they are fixed.
276 // <br>Restructuring is not possible and an exception is thrown
277 // if the Record has a fixed structure.
278 virtual void restructure (const RecordDesc& newDescription,
279 Bool recursive=True) = 0;
280
281 // Remove a field from the record.
282 // <note role=caution>
283 // Removing a field means that the field number of the fields following
284 // it will be decremented. It will invalidate RecordFieldPtr's
285 // pointing to the removed field, but no other RecordFieldPtr's.
286 // </note>
287 virtual void removeField (const RecordFieldId&) = 0;
288
289 // Get or define the value as a ValueHolder.
290 // This is useful to pass around a value of any supported type.
291 // <group>
294 const ValueHolder&);
295 // </group>
296
297 // Define a value for the given field.
298 // Array conformance rules will not be applied for variable shaped arrays.
299 // If the field and value data type mismatch, type promotion
300 // of scalars will be done if possible. If not possible, an exception
301 // is thrown.
302 // <br>
303 // If the field does not exist, it will be added to the record.
304 // This results in an exception for fixed structured records.
305 // The field is checked by a possible field checking function
306 // before it gets added.
307 // <group>
316 void define (const RecordFieldId&, const Complex& value);
317 void define (const RecordFieldId&, const DComplex& value);
318 void define (const RecordFieldId&, const Char* value);
319 void define (const RecordFieldId&, const String& value);
320 void define (const RecordFieldId&, const Array<Bool>& value,
321 Bool FixedShape = False);
323 Bool FixedShape = False);
325 Bool FixedShape = False);
326 void define (const RecordFieldId&, const Array<Int>& value,
327 Bool FixedShape = False);
328 void define (const RecordFieldId&, const Array<uInt>& value,
329 Bool FixedShape = False);
331 Bool FixedShape = False);
333 Bool FixedShape = False);
335 Bool FixedShape = False);
337 Bool FixedShape = False);
339 Bool FixedShape = False);
341 Bool FixedShape = False);
342 virtual void defineRecord (const RecordFieldId&,
343 const RecordInterface& value,
344 RecordType = Variable) = 0;
345 // </group>
346
347 // Get the value of the given field.
348 // If the field and value data type mismatch, type promotion
349 // will be done if possible. If not possible, an exception
350 // is thrown.
351 // If the value argument is an array, it will be reshaped if needed.
352 // <group>
353 void get (const RecordFieldId&, Bool& value) const;
354 void get (const RecordFieldId&, uChar& value) const;
355 void get (const RecordFieldId&, Short& value) const;
356 void get (const RecordFieldId&, Int& value) const;
357 void get (const RecordFieldId&, uInt& value) const;
358 void get (const RecordFieldId&, Int64& value) const;
359 void get (const RecordFieldId&, Float& value) const;
360 void get (const RecordFieldId&, Double& value) const;
361 void get (const RecordFieldId&, Complex& value) const;
362 void get (const RecordFieldId&, DComplex& value) const;
363 void get (const RecordFieldId&, String& value) const;
364 void get (const RecordFieldId&, Array<Bool>& value) const;
365 void get (const RecordFieldId&, Array<uChar>& value) const;
366 void get (const RecordFieldId&, Array<Short>& value) const;
367 void get (const RecordFieldId&, Array<Int>& value) const;
368 void get (const RecordFieldId&, Array<uInt>& value) const;
369 void get (const RecordFieldId&, Array<Int64>& value) const;
370 void get (const RecordFieldId&, Array<Float>& value) const;
371 void get (const RecordFieldId&, Array<Double>& value) const;
372 void get (const RecordFieldId&, Array<Complex>& value) const;
373 void get (const RecordFieldId&, Array<DComplex>& value) const;
374 void get (const RecordFieldId&, Array<String>& value) const;
375 // </group>
376
377 // The following functions get the value based on field name or number.
378 // The scalar functions promote the data type if needed. It also supports
379 // conversion of Int to Bool.
380 // <br>The array functions throw an exception if the data type mismatches.
381 // The toArrayX function can be used for array type promotion.
382 // <group>
383 Bool asBool (const RecordFieldId&) const;
386 Int asInt (const RecordFieldId&) const;
387 uInt asuInt (const RecordFieldId&) const;
391 Complex asComplex (const RecordFieldId&) const;
392 DComplex asDComplex(const RecordFieldId&) const;
393 const String& asString (const RecordFieldId&) const;
394 const Array<Bool>& asArrayBool (const RecordFieldId&) const;
397 const Array<Int>& asArrayInt (const RecordFieldId&) const;
398 const Array<uInt>& asArrayuInt (const RecordFieldId&) const;
405 virtual const RecordInterface& asRecord (const RecordFieldId&) const = 0;
407 // </group>
408
409 // Get an array while promoting the data as needed.
410 // Int values can be converted to Bool.
411 // A scalar value is also converted to an array.
412 // These functions are slower than <src>asX</src>, but more general.
413 // <group>
425 void toArray (const RecordFieldId& id, Array<Bool>& array) const
426 { array.reference (toArrayBool (id)); }
427 void toArray (const RecordFieldId& id, Array<uChar>& array) const
428 { array.reference (toArrayuChar (id)); }
429 void toArray (const RecordFieldId& id, Array<Short>& array) const
430 { array.reference (toArrayShort (id)); }
431 void toArray (const RecordFieldId& id, Array<Int>& array) const
432 { array.reference (toArrayInt (id)); }
433 void toArray (const RecordFieldId& id, Array<uInt>& array) const
434 { array.reference (toArrayuInt (id)); }
435 void toArray (const RecordFieldId& id, Array<Int64>& array) const
436 { array.reference (toArrayInt64 (id)); }
437 void toArray (const RecordFieldId& id, Array<Float>& array) const
438 { array.reference (toArrayFloat (id)); }
439 void toArray (const RecordFieldId& id, Array<Double>& array) const
440 { array.reference (toArrayDouble (id)); }
441 void toArray (const RecordFieldId& id, Array<Complex>& array) const
442 { array.reference (toArrayComplex (id)); }
444 { array.reference (toArrayDComplex (id)); }
445 void toArray (const RecordFieldId& id, Array<String>& array) const
446 { array.reference (toArrayString (id)); }
447 // </group>
448
449 // Get value based on field name or number.
450 // They are here for backward compatibility with the old KeywordSet
451 // classes and will be removed in the future.
452 // <group>
453 Float asfloat (const RecordFieldId&) const;
454 Double asdouble (const RecordFieldId&) const;
455 const Array<Float>& asArrayfloat (const RecordFieldId&) const;
456 const Array<Double>& asArraydouble (const RecordFieldId&) const;
457 // </group>
458
459 // Make a unique record representation
460 // (for copy-on-write in RecordFieldPtr).
461 virtual void makeUnique() = 0;
462
463 // Define a data field (for RecordFieldPtr).
464 //# This function has to be public for the global defineRecordFieldPtr
465 //# functions in RecordField.h.
466 virtual void defineDataField (Int whichField, DataType type,
467 const void* value) = 0;
468
469 // Used by the RecordFieldPtr classes to attach to the correct field.
470 //# This function has to be public for the global attachRecordFieldPtr
471 //# functions in RecordField.h.
472 // The latter function is used to attach to a Record-type field
473 // checking if the correct Record type is used.
474 // <group>
475 virtual void* get_pointer (Int whichField, DataType type) const = 0;
476 virtual void* get_pointer (Int whichField, DataType type,
477 const String& recordType) const = 0;
478 // </group>
479
480 // Print the contents of the record.
481 // Only the first <src>maxNrValues</src> of an array will be printed.
482 // A value < 0 means the entire array.
483 // <group>
484 friend inline std::ostream& operator<< (std::ostream& os,
485 const RecordInterface& rec)
486 { rec.print (os, 25, " "); return os; }
487 virtual void print (std::ostream&,
488 Int maxNrValues = 25,
489 const String& indent="") const = 0;
490 // </group>
491
492
493protected:
494 // Let the derived class add an array field with the given type, shape,
495 // and value.
496 virtual void addDataField (const String& name, DataType type,
497 const IPosition& shape, Bool fixedShape,
498 const void* value) = 0;
499
500 // Check if the Record has a non-fixed structure.
501 // If it is fixed, it throws an exception.
502 // This can be used by other functions (like define).
503 void throwIfFixed() const;
504
505 // Check if the new field name is correct.
506 // This is done by calling the checkFunction (if defined).
507 // If incorrect, an exception is thrown.
508 void checkName (const String& fieldName, DataType type) const;
509
510 // Give access to the RecordType flag (write-access is needed when
511 // a record is read back).
512 // <group>
514 RecordType recordType() const;
515 // </group>
516
517 // Get the field number for the given field id.
518 // It returns -1 if an unknown name was given.
520
521 // Add a scalar field with the given type 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, const void* value);
525
526 // Add an array field with the given type, shape and value.
527 // An exception is thrown if the record structure is fixed
528 // or if the name is invalid.
529 void defineField (const RecordFieldId&, DataType type,
530 const IPosition& shape, Bool fixedShape,
531 const void* value);
532
533
534private:
535 // Get the description of this record.
536 virtual RecordDesc getDescription() const = 0;
537
538 // Holds the callback function plus argument.
540 const void* checkArgument_p;
541
542 // Defines if the Record has a fixed structure.
544};
545
546
548{
549 return (type_p == Fixed);
550}
551inline Bool RecordInterface::isDefined (const String& fieldName) const
552{
553 return (fieldNumber(fieldName) >= 0);
554}
563inline DataType RecordInterface::dataType (const RecordFieldId& id) const
564{
565 return type (idToNumber(id));
566}
567inline void RecordInterface::define (const RecordFieldId& id, const Char* value)
568{
569 define (id, String(value));
570}
572{
573 return asFloat (id);
574}
576{
577 return asDouble (id);
578}
580 (const RecordFieldId& id) const
581{
582 return asArrayFloat (id);
583}
585 (const RecordFieldId& id) const
586{
587 return asArrayDouble (id);
588}
589
590} //# NAMESPACE CASACORE - END
591
592#endif
void get(const RecordFieldId &, Float &value) const
RecordInterface(RecordType type, CheckFieldFunction *funcPtr, const void *checkArgument)
Create a record with no fields.
Int newIdToNumber(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).
const Array< Int > & asArrayInt(const RecordFieldId &) const
virtual const RecordInterface & asRecord(const RecordFieldId &) const =0
void toArray(const RecordFieldId &id, Array< String > &array) const
uInt asuInt(const RecordFieldId &) const
RecordType & recordType()
Give access to the RecordType flag (write-access is needed when a record is read back).
void define(const RecordFieldId &, const Array< Float > &value, Bool FixedShape=False)
Array< Complex > toArrayComplex(const RecordFieldId &) const
const String & asString(const RecordFieldId &) const
virtual uInt nfields() const =0
How many fields does this structure have?
void toArray(const RecordFieldId &id, Array< Double > &array) const
Complex asComplex(const RecordFieldId &) const
virtual void * get_pointer(Int whichField, DataType type, const String &recordType) const =0
void toArray(const RecordFieldId &id, Array< uChar > &array) const
void get(const RecordFieldId &, Array< Complex > &value) const
void define(const RecordFieldId &, const Array< DComplex > &value, Bool FixedShape=False)
virtual RecordInterface * clone() const =0
Make a copy of this object.
Int64 asInt64(const RecordFieldId &) const
friend std::ostream & operator<<(std::ostream &os, const RecordInterface &rec)
Print the contents of the record.
virtual void defineRecord(const RecordFieldId &, const RecordInterface &value, RecordType=Variable)=0
const Array< String > & asArrayString(const RecordFieldId &) const
Int asInt(const RecordFieldId &) const
void get(const RecordFieldId &, Array< Short > &value) const
Array< String > toArrayString(const RecordFieldId &) const
void define(const RecordFieldId &, const Array< Int64 > &value, Bool FixedShape=False)
void define(const RecordFieldId &, const Array< Bool > &value, Bool FixedShape=False)
void toArray(const RecordFieldId &id, Array< Float > &array) const
void define(const RecordFieldId &, const DComplex &value)
virtual void setComment(const RecordFieldId &, const String &comment)=0
Set the comment for this field.
void define(const RecordFieldId &, const Array< Complex > &value, Bool FixedShape=False)
void define(const RecordFieldId &, const Array< uInt > &value, Bool FixedShape=False)
Int idToNumber(const RecordFieldId &) const
Get the field number for the given field id.
void get(const RecordFieldId &, Int64 &value) const
void define(const RecordFieldId &, const Array< Int > &value, Bool FixedShape=False)
bool empty() const
Is the record empty?
Array< DComplex > toArrayDComplex(const RecordFieldId &) const
void get(const RecordFieldId &, Array< String > &value) const
const Array< Bool > & asArrayBool(const RecordFieldId &) const
void get(const RecordFieldId &, Double &value) const
void define(const RecordFieldId &, const Array< Short > &value, Bool FixedShape=False)
const Array< Short > & asArrayShort(const RecordFieldId &) const
Array< Bool > toArrayBool(const RecordFieldId &) const
Get an array while promoting the data as needed.
void get(const RecordFieldId &, Array< uInt > &value) const
virtual ~RecordInterface()
Destruct the record.
String name(const RecordFieldId &) const
Get the name of this field.
virtual RecordInterface & asrwRecord(const RecordFieldId &)=0
const Array< Double > & asArraydouble(const RecordFieldId &) const
void get(const RecordFieldId &, DComplex &value) const
IPosition shape(const RecordFieldId &) const
Get the actual shape of this field.
void get(const RecordFieldId &, Array< DComplex > &value) const
virtual RecordDesc getDescription() const =0
Get the description of this record.
CheckFieldFunction * checkFunction_p
Holds the callback function plus argument.
const Array< uChar > & asArrayuChar(const RecordFieldId &) const
void define(const RecordFieldId &, const Array< uChar > &value, Bool FixedShape=False)
void define(const RecordFieldId &, const Complex &value)
virtual Int fieldNumber(const String &fieldName) const =0
Get the field number from the field name.
virtual void restructure(const RecordDesc &newDescription, Bool recursive=True)=0
Change the structure of this Record to contain the fields in newDescription.
DComplex asDComplex(const RecordFieldId &) const
void get(const RecordFieldId &, Short &value) const
virtual ValueHolder asValueHolder(const RecordFieldId &) const
Get or define the value as a ValueHolder.
void get(const RecordFieldId &, uChar &value) const
virtual const String & comment(const RecordFieldId &) const =0
Get the comment for this field.
const Array< Double > & asArrayDouble(const RecordFieldId &) const
const Array< Float > & asArrayFloat(const RecordFieldId &) const
virtual void defineDataField(Int whichField, DataType type, const void *value)=0
Define a data field (for RecordFieldPtr).
void get(const RecordFieldId &, uInt &value) const
void toArray(const RecordFieldId &id, Array< DComplex > &array) const
void define(const RecordFieldId &, Int64 value)
virtual void removeField(const RecordFieldId &)=0
Remove a field from the record.
void get(const RecordFieldId &, String &value) const
DataType dataType(const RecordFieldId &) const
void toArray(const RecordFieldId &id, Array< uInt > &array) const
void checkName(const String &fieldName, DataType type) const
Check if the new field name is correct.
void define(const RecordFieldId &, Double value)
void toArray(const RecordFieldId &id, Array< Bool > &array) const
void toArray(const RecordFieldId &id, Array< Int > &array) const
void define(const RecordFieldId &, uChar value)
void toArray(const RecordFieldId &id, Array< Short > &array) const
Short asShort(const RecordFieldId &) const
uChar asuChar(const RecordFieldId &) const
void get(const RecordFieldId &, Array< Bool > &value) const
Bool isDefined(const String &fieldName) const
Test if a field name exists.
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.
virtual void * get_pointer(Int whichField, DataType type) const =0
Used by the RecordFieldPtr classes to attach to the correct field.
void define(const RecordFieldId &, const String &value)
void defineField(const RecordFieldId &, DataType type, const IPosition &shape, Bool fixedShape, const void *value)
Add an array field with the given type, shape and value.
void get(const RecordFieldId &, Int &value) const
const Array< Int64 > & asArrayInt64(const RecordFieldId &) const
virtual void defineFromValueHolder(const RecordFieldId &, const ValueHolder &)
Array< Int64 > toArrayInt64(const RecordFieldId &) const
void define(const RecordFieldId &, Float value)
Float asfloat(const RecordFieldId &) const
Get value based on field name or number.
void get(const RecordFieldId &, Array< Int64 > &value) const
void get(const RecordFieldId &, Complex &value) const
Bool isFixed() const
Is the Record structure fixed (i.e.
void define(const RecordFieldId &, const Array< Double > &value, Bool FixedShape=False)
void toArray(const RecordFieldId &id, Array< Int64 > &array) const
RecordInterface & operator=(const RecordInterface &other)
Assignment (copy semantics).
Bool asBool(const RecordFieldId &) const
The following functions get the value based on field name or number.
RecordInterface(const RecordInterface &other)
Copy constructor (copy semantics).
RecordType
Define the flag telling if a Record has a fixed or variable structure.
@ Variable
Record has a variable structure; after Record creation fields can be added or removed at will.
@ Fixed
Record has a fixed structure; that is, no fields can be added or removed once the Record is created.
Array< uChar > toArrayuChar(const RecordFieldId &) const
Array< uInt > toArrayuInt(const RecordFieldId &) const
void get(const RecordFieldId &, Array< Int > &value) const
void define(const RecordFieldId &, Short value)
void throwIfFixed() const
Check if the Record has a non-fixed structure.
Bool CheckFieldFunction(const String &fieldName, DataType dataType, const void *extraArgument, String &message)
Define the signature of the add callback function.
Array< Int > toArrayInt(const RecordFieldId &) const
void define(const RecordFieldId &, Int value)
void define(const RecordFieldId &, Bool value)
Define a value for the given field.
const Array< uInt > & asArrayuInt(const RecordFieldId &) const
DuplicatesFlag
Define the Duplicates flag for the function merge in the various record classes.
@ ThrowOnDuplicates
Throw an exception.
@ OverwriteDuplicates
Overwrite the value of a duplicate keyword This will also happen if their types differ.
@ RenameDuplicates
Rename a name from the other set to name_n, where n is the first positive number making the name uniq...
@ SkipDuplicates
Skip duplicate names from the other set.
const Array< Float > & asArrayfloat(const RecordFieldId &) const
void get(const RecordFieldId &, Array< Float > &value) const
Double asDouble(const RecordFieldId &) const
Array< Float > toArrayFloat(const RecordFieldId &) const
virtual void assign(const RecordInterface &that)=0
Assign that RecordInterface object to this one.
Double asdouble(const RecordFieldId &) const
Array< Double > toArrayDouble(const RecordFieldId &) const
RecordInterface()
The default constructor creates an empty record with a variable structure.
const Array< DComplex > & asArrayDComplex(const RecordFieldId &) const
void toArray(const RecordFieldId &id, Array< Complex > &array) const
void get(const RecordFieldId &, Bool &value) const
Get the value of the given field.
const Array< Complex > & asArrayComplex(const RecordFieldId &) const
void define(const RecordFieldId &, uInt value)
virtual void print(std::ostream &, Int maxNrValues=25, const String &indent="") const =0
void get(const RecordFieldId &, Array< uChar > &value) const
Float asFloat(const RecordFieldId &) const
void get(const RecordFieldId &, Array< Double > &value) const
void define(const RecordFieldId &, const Array< String > &value, Bool FixedShape=False)
void defineField(const RecordFieldId &, DataType type, const void *value)
Add a scalar field with the given type and value.
virtual DataType type(Int whichField) const =0
Get the data type of this field (as defined in DataType.h).
Array< Short > toArrayShort(const RecordFieldId &) const
RecordType type_p
Defines if the Record has a fixed structure.
RecordDesc description() const
Get the description of this record.
String: the storage and methods of handling collections of characters.
Definition String.h:223
this file contains all the compiler specific defines
Definition mainpage.dox:28
unsigned char uChar
Definition aipstype.h:45
const Bool False
Definition aipstype.h:42
short Short
Definition aipstype.h:46
unsigned int uInt
Definition aipstype.h:49
TableExprNode array(const TableExprNode &values, const TableExprNodeSet &shape)
Create an array of the given shape and fill it with the values.
Definition ExprNode.h:1933
long long Int64
Define the extra non-standard types used by Casacore (like proposed uSize, Size)
Definition aipsxtype.h:36
float Float
Definition aipstype.h:52
int Int
Definition aipstype.h:48
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
const Bool True
Definition aipstype.h:41
double Double
Definition aipstype.h:53
char Char
Definition aipstype.h:44