30 #ifndef CASA_RECORDINTERFACE_H
31 #define CASA_RECORDINTERFACE_H
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>
185 const void* extraArgument,
198 const void* checkArgument);
234 {
return size() == 0; }
250 virtual DataType
type (
Int whichField)
const = 0;
471 const void*
value) = 0;
490 { rec.
print (os, 25,
" ");
return os; }
492 Int maxNrValues = 25,
493 const String& indent=
"")
const = 0;
502 const void*
value) = 0;
base class for notice originators
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.
Array< Float > toArrayFloat(const RecordFieldId &) const
virtual void makeUnique()=0
Make a unique record representation (for copy-on-write in RecordFieldPtr).
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)
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
const Array< Int64 > & asArrayInt64(const RecordFieldId &) const
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)
Int64 asInt64(const RecordFieldId &) const
const Array< Double > & asArrayDouble(const RecordFieldId &) const
virtual void defineRecord(const RecordFieldId &, const RecordInterface &value, RecordType=Variable)=0
Int asInt(const RecordFieldId &) const
Array< DComplex > toArrayDComplex(const RecordFieldId &) const
void get(const RecordFieldId &, Array< Short > &value) 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)
const Array< Int > & asArrayInt(const RecordFieldId &) const
Array< Complex > toArrayComplex(const RecordFieldId &) const
const Array< Bool > & asArrayBool(const RecordFieldId &) const
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)
const Array< String > & asArrayString(const RecordFieldId &) const
bool empty() const
Is the record empty?
const Array< Float > & asArrayFloat(const RecordFieldId &) const
void get(const RecordFieldId &, Array< String > &value) const
void get(const RecordFieldId &, Double &value) const
void define(const RecordFieldId &, const Array< Short > &value, Bool FixedShape=False)
void get(const RecordFieldId &, Array< uInt > &value) const
const String & asString(const RecordFieldId &) const
virtual ~RecordInterface()
Destruct the record.
String name(const RecordFieldId &) const
Get the name of this field.
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< Complex > & asArrayComplex(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 RecordInterface & asRecord(const RecordFieldId &) const =0
Array< Int > toArrayInt(const RecordFieldId &) const
virtual void defineDataField(Int whichField, DataType type, const void *value)=0
Define a data field (for RecordFieldPtr).
Array< Int64 > toArrayInt64(const RecordFieldId &) const
friend std::ostream & operator<<(std::ostream &os, const RecordInterface &rec)
Print the contents of the record.
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
const void * checkArgument_p
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.
Array< uInt > toArrayuInt(const RecordFieldId &) const
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
Array< uChar > toArrayuChar(const RecordFieldId &) const
Short asShort(const RecordFieldId &) const
const Array< DComplex > & asArrayDComplex(const RecordFieldId &) const
uChar asuChar(const RecordFieldId &) const
RecordInterface & operator=(const RecordInterface &other)
Assignment (copy semantics).
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.
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
virtual RecordInterface * clone() const =0
Make a copy of this object.
virtual void defineFromValueHolder(const RecordFieldId &, const ValueHolder &)
virtual const String & comment(const RecordFieldId &) const =0
Get the comment for this field.
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
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< Double > toArrayDouble(const RecordFieldId &) const
void get(const RecordFieldId &, Array< Int > &value) const
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 &, Short value)
void throwIfFixed() const
Check if the Record has a non-fixed structure.
const Array< uInt > & asArrayuInt(const RecordFieldId &) const
Bool CheckFieldFunction(const String &fieldName, DataType dataType, const void *extraArgument, String &message)
Define the signature of the add callback function.
void define(const RecordFieldId &, Int value)
void define(const RecordFieldId &, Bool value)
Define a value for the given field.
Array< Bool > toArrayBool(const RecordFieldId &) const
Get an array while promoting the data as needed.
virtual RecordInterface & asrwRecord(const RecordFieldId &)=0
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
Array< String > toArrayString(const RecordFieldId &) const
void get(const RecordFieldId &, Array< Float > &value) const
Double asDouble(const RecordFieldId &) const
virtual void assign(const RecordInterface &that)=0
Assign that RecordInterface object to this one.
Double asdouble(const RecordFieldId &) const
RecordInterface()
The default constructor creates an empty record with a variable structure.
void toArray(const RecordFieldId &id, Array< Complex > &array) const
void get(const RecordFieldId &, Bool &value) const
Get the value of the given field.
virtual void * get_pointer(Int whichField, DataType type, const String &recordType) const =0
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
const Array< uChar > & asArrayuChar(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).
RecordType type_p
Defines if the Record has a fixed structure.
Array< Short > toArrayShort(const RecordFieldId &) const
RecordDesc description() const
Get the description of this record.
const Array< Short > & asArrayShort(const RecordFieldId &) const
Helper class to notify class Record about changes.
RecordNotice(NoticeType changeType, uInt fieldNumber)
Construct a notice for the given type and field number.
virtual bool operator==(const Notice &that) const
Always returns False.
NoticeType
Define the possible change types.
@ ACQUIRE
RecordRep has been copied; re-acquire the pointers in all RecordFieldPtr's.
@ DETACH
Record has been deleted; detach all RecordFieldPtr's.
@ REMOVE
A field has been removed; detach that RecordFieldPtr and decrement field numbers in RecordFieldPtr's ...
Int fieldNumber() const
Return the field number.
NoticeType changeType() const
Return the change type.
String: the storage and methods of handling collections of characters.
std::complex< Float > Complex
std::complex< Double > DComplex
this file contains all the compiler specific defines
TableExprNode array(const TableExprNode &values, const TableExprNodeSet &shape)
Create an array of the given shape and fill it with the values.
long long Int64
Define the extra non-standard types used by Casacore (like proposed uSize, Size)
bool Bool
Define the standard types used by Casacore.
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.