casacore
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
casacore::Record Class Reference

More...

#include <Record.h>

Public Member Functions

 Record ()
 Create a record with no fields.
 
 Record (RecordType type, CheckFieldFunction *=0, const void *checkArgument=0)
 Create a record with no fields.
 
 Record (const RecordDesc &description, RecordType type=Fixed, CheckFieldFunction *=0, const void *checkArgument=0)
 Create a record with the given description.
 
 Record (const Record &other)
 Create a copy of other using copy semantics.
 
 Record (const RecordInterface &other)
 Create a Record from another type of record using copy semantics.
 
Recordoperator= (const Record &other)
 Copy the data in the other record to this record.
 
 ~Record ()
 Release resources associated with this object.
 
RecordInterfaceclone () const override
 Make a copy of this object.
 
void assign (const RecordInterface &that) override
 Assign that RecordInterface object to this one.
 
const Stringcomment (const RecordFieldId &) const override
 Get the comment for this field.
 
void setComment (const RecordFieldId &, const String &comment) override
 Set the comment for this field.
 
const RecordDescdescription () const
 Describes the current structure of this Record.
 
void restructure (const RecordDesc &newDescription, Bool recursive=True) override
 Change the structure of this Record to contain the fields in newDescription.
 
Bool conform (const Record &other) const
 Returns True if this and other have the same RecordDesc, other than different names for the fields.
 
uInt nfields () const override
 How many fields does this structure have? A convenient synonym for description().nfields().
 
Int fieldNumber (const String &fieldName) const override
 Get the field number from the field name.
 
DataType type (Int whichField) const override
 Get the data type of this field.
 
void removeField (const RecordFieldId &) override
 Remove a field from the record.
 
void renameField (const String &newName, const RecordFieldId &)
 Rename the given field.
 
void defineRecord (const RecordFieldId &, const Record &value, RecordType type=Variable)
 Define a value for the given field containing a subrecord.
 
void defineRecord (const RecordFieldId &, const RecordInterface &value, RecordType=Variable) override
 
const RecordsubRecord (const RecordFieldId &) const
 Get the subrecord from the given field.
 
RecordrwSubRecord (const RecordFieldId &)
 
const RecordInterfaceasRecord (const RecordFieldId &) const override
 
RecordInterfaceasrwRecord (const RecordFieldId &) override
 
ValueHolder asValueHolder (const RecordFieldId &) const override
 Get or define the value as a ValueHolder.
 
void defineFromValueHolder (const RecordFieldId &, const ValueHolder &) override
 
void mergeField (const Record &other, const RecordFieldId &, DuplicatesFlag=ThrowOnDuplicates)
 Merge a field from another record into this record.
 
void merge (const Record &other, DuplicatesFlag=ThrowOnDuplicates)
 Merge all fields from the other record into this record.
 
void putRecord (AipsIO &os) const
 Write the Record to an output stream.
 
void getRecord (AipsIO &os)
 Read the Record from an input stream.
 
void putData (AipsIO &os) const
 Put the data of a record.
 
void getData (AipsIO &os, uInt version)
 Read the data of a record.
 
void makeUnique () override
 Make a unique record representation (to do copy-on-write in RecordFieldPtr).
 
void print (std::ostream &, Int maxNrValues=25, const String &indent="") const override
 Print the contents of the record.
 
- Public Member Functions inherited from casacore::RecordInterface
 RecordInterface ()
 The default constructor creates an empty record with a variable structure.
 
 RecordInterface (RecordType type, CheckFieldFunction *funcPtr, const void *checkArgument)
 Create a record with no fields.
 
 RecordInterface (const RecordInterface &other)
 Copy constructor (copy semantics).
 
RecordInterfaceoperator= (const RecordInterface &other)
 Assignment (copy semantics).
 
virtual ~RecordInterface ()
 Destruct the record.
 
Bool isFixed () const
 Is the Record structure fixed (i.e.
 
uInt size () const
 
bool empty () const
 Is the record empty?
 
Int idToNumber (const RecordFieldId &) const
 Get the field number for the given field id.
 
Bool isDefined (const String &fieldName) const
 Test if a field name exists.
 
DataType dataType (const RecordFieldId &) const
 
String name (const RecordFieldId &) const
 Get the name of this field.
 
IPosition shape (const RecordFieldId &) const
 Get the actual shape of this field.
 
RecordDesc description () const
 Get the description of this record.
 
void define (const RecordFieldId &, Bool value)
 Define a value for the given field.
 
void define (const RecordFieldId &, uChar value)
 
void define (const RecordFieldId &, Short value)
 
void define (const RecordFieldId &, Int value)
 
void define (const RecordFieldId &, uInt value)
 
void define (const RecordFieldId &, Int64 value)
 
void define (const RecordFieldId &, Float value)
 
void define (const RecordFieldId &, Double value)
 
void define (const RecordFieldId &, const Complex &value)
 
void define (const RecordFieldId &, const DComplex &value)
 
void define (const RecordFieldId &, const Char *value)
 
void define (const RecordFieldId &, const String &value)
 
void define (const RecordFieldId &, const Array< Bool > &value, Bool FixedShape=False)
 
void define (const RecordFieldId &, const Array< uChar > &value, Bool FixedShape=False)
 
void define (const RecordFieldId &, const Array< Short > &value, Bool FixedShape=False)
 
void define (const RecordFieldId &, const Array< Int > &value, Bool FixedShape=False)
 
void define (const RecordFieldId &, const Array< uInt > &value, Bool FixedShape=False)
 
void define (const RecordFieldId &, const Array< Int64 > &value, Bool FixedShape=False)
 
void define (const RecordFieldId &, const Array< Float > &value, Bool FixedShape=False)
 
void define (const RecordFieldId &, const Array< Double > &value, Bool FixedShape=False)
 
void define (const RecordFieldId &, const Array< Complex > &value, Bool FixedShape=False)
 
void define (const RecordFieldId &, const Array< DComplex > &value, Bool FixedShape=False)
 
void define (const RecordFieldId &, const Array< String > &value, Bool FixedShape=False)
 
void get (const RecordFieldId &, Bool &value) const
 Get the value of the given field.
 
void get (const RecordFieldId &, uChar &value) const
 
void get (const RecordFieldId &, Short &value) const
 
void get (const RecordFieldId &, Int &value) const
 
void get (const RecordFieldId &, uInt &value) const
 
void get (const RecordFieldId &, Int64 &value) const
 
void get (const RecordFieldId &, Float &value) const
 
void get (const RecordFieldId &, Double &value) const
 
void get (const RecordFieldId &, Complex &value) const
 
void get (const RecordFieldId &, DComplex &value) const
 
void get (const RecordFieldId &, String &value) const
 
void get (const RecordFieldId &, Array< Bool > &value) const
 
void get (const RecordFieldId &, Array< uChar > &value) const
 
void get (const RecordFieldId &, Array< Short > &value) const
 
void get (const RecordFieldId &, Array< Int > &value) const
 
void get (const RecordFieldId &, Array< uInt > &value) const
 
void get (const RecordFieldId &, Array< Int64 > &value) const
 
void get (const RecordFieldId &, Array< Float > &value) const
 
void get (const RecordFieldId &, Array< Double > &value) const
 
void get (const RecordFieldId &, Array< Complex > &value) const
 
void get (const RecordFieldId &, Array< DComplex > &value) const
 
void get (const RecordFieldId &, Array< String > &value) const
 
Bool asBool (const RecordFieldId &) const
 The following functions get the value based on field name or number.
 
uChar asuChar (const RecordFieldId &) const
 
Short asShort (const RecordFieldId &) const
 
Int asInt (const RecordFieldId &) const
 
uInt asuInt (const RecordFieldId &) const
 
Int64 asInt64 (const RecordFieldId &) const
 
Float asFloat (const RecordFieldId &) const
 
Double asDouble (const RecordFieldId &) const
 
Complex asComplex (const RecordFieldId &) const
 
DComplex asDComplex (const RecordFieldId &) const
 
const StringasString (const RecordFieldId &) const
 
const Array< Bool > & asArrayBool (const RecordFieldId &) const
 
const Array< uChar > & asArrayuChar (const RecordFieldId &) const
 
const Array< Short > & asArrayShort (const RecordFieldId &) const
 
const Array< Int > & asArrayInt (const RecordFieldId &) const
 
const Array< uInt > & asArrayuInt (const RecordFieldId &) const
 
const Array< Int64 > & asArrayInt64 (const RecordFieldId &) const
 
const Array< Float > & asArrayFloat (const RecordFieldId &) const
 
const Array< Double > & asArrayDouble (const RecordFieldId &) const
 
const Array< Complex > & asArrayComplex (const RecordFieldId &) const
 
const Array< DComplex > & asArrayDComplex (const RecordFieldId &) const
 
const Array< String > & asArrayString (const RecordFieldId &) const
 
Array< BooltoArrayBool (const RecordFieldId &) const
 Get an array while promoting the data as needed.
 
Array< uChartoArrayuChar (const RecordFieldId &) const
 
Array< ShorttoArrayShort (const RecordFieldId &) const
 
Array< InttoArrayInt (const RecordFieldId &) const
 
Array< uInttoArrayuInt (const RecordFieldId &) const
 
Array< Int64toArrayInt64 (const RecordFieldId &) const
 
Array< FloattoArrayFloat (const RecordFieldId &) const
 
Array< DoubletoArrayDouble (const RecordFieldId &) const
 
Array< Complex > toArrayComplex (const RecordFieldId &) const
 
Array< DComplex > toArrayDComplex (const RecordFieldId &) const
 
Array< StringtoArrayString (const RecordFieldId &) const
 
void toArray (const RecordFieldId &id, Array< Bool > &array) const
 
void toArray (const RecordFieldId &id, Array< uChar > &array) const
 
void toArray (const RecordFieldId &id, Array< Short > &array) const
 
void toArray (const RecordFieldId &id, Array< Int > &array) const
 
void toArray (const RecordFieldId &id, Array< uInt > &array) const
 
void toArray (const RecordFieldId &id, Array< Int64 > &array) const
 
void toArray (const RecordFieldId &id, Array< Float > &array) const
 
void toArray (const RecordFieldId &id, Array< Double > &array) const
 
void toArray (const RecordFieldId &id, Array< Complex > &array) const
 
void toArray (const RecordFieldId &id, Array< DComplex > &array) const
 
void toArray (const RecordFieldId &id, Array< String > &array) const
 
Float asfloat (const RecordFieldId &) const
 Get value based on field name or number.
 
Double asdouble (const RecordFieldId &) const
 
const Array< Float > & asArrayfloat (const RecordFieldId &) const
 
const Array< Double > & asArraydouble (const RecordFieldId &) const
 

Protected Member Functions

void * get_pointer (Int whichField, DataType type) const override
 Used by the RecordField classes to attach in a type-safe way to the correct field.
 
void * get_pointer (Int whichField, DataType type, const String &recordType) const override
 
const RecordRepref () const
 Return a const reference to the underlying RecordRep.
 
RecordReprwRef ()
 Return a non-const reference to the underlying RecordRep.
 
void addDataField (const String &name, DataType type, const IPosition &shape, Bool fixedShape, const void *value) override
 Add a field to the record.
 
void defineDataField (Int whichField, DataType type, const void *value) override
 Define a value in the given field.
 
- Protected Member Functions inherited from casacore::RecordInterface
void throwIfFixed () const
 Check if the Record has a non-fixed structure.
 
void checkName (const String &fieldName, DataType type) const
 Check if the new field name is correct.
 
RecordTyperecordType ()
 Give access to the RecordType flag (write-access is needed when a record is read back).
 
RecordType recordType () const
 
Int newIdToNumber (const RecordFieldId &) const
 Get the field number for the given field id.
 
void defineField (const RecordFieldId &, DataType type, const void *value)
 Add a scalar field with the given type and 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.
 

Private Member Functions

RecordDesc getDescription () const override
 Get the description of this record.
 
 Record (RecordRep *parent, const RecordDesc &description)
 Create Record as a subrecord.
 
 Record (RecordRep *parent, RecordType type)
 

Private Attributes

COWPtr< RecordReprep_p
 The Record representation.
 
RecordRepparent_p
 The parent Record.
 

Friends

class RecordRep
 
AipsIOoperator<< (AipsIO &os, const Record &rec)
 Write the Record to an output stream.
 
AipsIOoperator>> (AipsIO &os, Record &rec)
 Read the Record from an input stream.
 

Additional Inherited Members

- Public Types inherited from casacore::RecordInterface
enum  RecordType {
  Fixed ,
  Variable
}
 Define the flag telling if a Record has a fixed or variable structure. More...
 
enum  DuplicatesFlag {
  RenameDuplicates ,
  SkipDuplicates ,
  OverwriteDuplicates ,
  ThrowOnDuplicates
}
 Define the Duplicates flag for the function merge in the various record classes. More...
 
typedef Bool CheckFieldFunction(const String &fieldName, DataType dataType, const void *extraArgument, String &message)
 Define the signature of the add callback function.
 

Detailed Description

A hierarchical collection of named fields of various types

Intended use:

Public interface

Review Status

Reviewed By:
Mark Wieringa
Date Reviewed:
1996/04/15
Test programs:
tRecord

Prerequisite

Etymology

`‘Record’' is a widely used term in both programming languages and data structures to denote an imhogeneous set of fields. An alternative would have been to name it structure, which would have perhaps been a clearer name for C++ programmers.

Synopsis

Class RecordInterface decribes the fundamental properties of records.
The Record class is a particular type of a record class. The fields in Record may be of scalar type, array type, or a Record. The types are chosen to be compatible with the native types of the Table system, viz: Bool, uChar, Short, Int, uInt, float, double, Complex, DComplex, String. Arrays of all these types are also available. Note that a Record is not a space-efficient way of storing small objects.

The structure of a Record is defined by the RecordDesc class. The structure of the Record can be defined at construction time. It can thereafter be restructured. This has the effect, however, that any existing RecordFieldPtr objects become invalid.
It is possible to add or remove fields once a Record is constructed. However, this is not possible when the Record is constructed with a fixed structure (i.e. with the fixedStructure flag set).

A Record is a hierarchical structure, because it can have fields containing Record's (as layed out in the RecordDesc). A subrecord has a variable structure, when its RecordDesc is empty (i.e. contains no fields). It is fixed when its RecordDesc contains fields.

A Record may be assigned to another only if they conform; that is if their fields have the identical type in the identical order. The field names do not need to be identical however, only the types. That is, the structure needs to be identical, but not the labels. Note that field order is significant, [ifield(type=Int),ffield(type=float)] is not the same as [ffield(type=float),ifield(type=Int)]
Conformance is checked recursively for fixed subrecords. That is, a variable structured subrecord is not checked, because any record can be assigned to it. A fixed structured subrecord has to conform the corresponding subrecord in the source.

Record uses copy-on-write semantics. This means that when a Record is copied, only the pointer to the underlying RecordRep object is copied. Only when the Record gets changed (i.e. when a non-const Record member function is called), the RecordRep object is copied. This results in a cheap copy behaviour.

Example

Suppose we wanted to create a records that describe the favorite example of the OO world - an employee:

RecordDesc employeeDesc;
employeeDesc.addField ("name", TpString);
employeeDesc.addField ("salary", TpDouble);
uInt addField(const String &fieldName, DataType dataType)
Add scalar, array, sub-record, or table field.
Definition RecordDesc.h:321

The above creates the description (structure) for some record objects.

Record employeeA(employeeDesc);
Record employeeB(employeeDesc, False);
const Bool False
Definition aipstype.h:42

And these two lines create Record objects which share this common structure. The first Record has a fixed structure, the 2nd variable.

RecordFieldPtr<String> nameA(employeeA, 0);
RecordFieldPtr<String> nameB(employeeB, 0);
RecordFieldPtr<double> salaryA(employeeA, 1);
RecordFieldPtr<double> salaryB(employeeB, "salary");

This shows how we can get access to the individual fields. The fields are fundamentally identified by number, but the number can be looked up through the use of the fieldNumber member function.

nameA.define ("Tim");
nameB.define ("Brian");
salaryA.define (1.0e+8);
salaryB.define (1.0 / *salaryA);

Once obtained, the fields are readily manipulated, as shown above. Note that the field values are obtained through the dereference (*) operator. This is to identify that the field objects are pointers to the values in the underlying Record; that is

salaryA = salaryB;
*salaryA = *salaryB;

Do very different things; the first line is a pointer copy; salaryA and salaryB now point to the same field in salaryB. The second line is a value copy.

Whole records can be copied as long as their structures are compatible, so that employeeA = employeeB is a legal statement. However, if the structure is changed, assignment is no longer possible, and all of the field pointers are invalidated:

employeeB.define ("age", (Int)40);
employeeA = employeeB; // exception - no longer conformant
int Int
Definition aipstype.h:48

Motivation

Collections of data with different types are frequently needed. Record makes it possible to hold such data in a flexible way.

To Do

Definition at line 177 of file Record.h.

Constructor & Destructor Documentation

◆ Record() [1/7]

casacore::Record::Record ( )

Create a record with no fields.

The record has a variable structure.

◆ Record() [2/7]

casacore::Record::Record ( RecordType  type,
CheckFieldFunction = 0,
const void *  checkArgument = 0 
)
explicit

Create a record with no fields.

The type determines if the record has a fixed or variable structure. The callback function is called when a field is added to the Record. That function can check the name and of data type of the new field (for instance, the Table system uses it to ensure that table columns and keywords have different names).

◆ Record() [3/7]

casacore::Record::Record ( const RecordDesc description,
RecordType  type = Fixed,
CheckFieldFunction = 0,
const void *  checkArgument = 0 
)
explicit

Create a record with the given description.

If it is not possible to create all fields (for example, if a field with an unsupported data type is requested), an exception is thrown. The type determines if the record has a fixed or variable structure. All fields are checked by the field checking function (if defined) (for instance, the Table system uses it to ensure that table columns and keywords have different names).

◆ Record() [4/7]

casacore::Record::Record ( const Record other)

Create a copy of other using copy semantics.

◆ Record() [5/7]

casacore::Record::Record ( const RecordInterface other)

Create a Record from another type of record using copy semantics.

Subrecords are also converted to a Record.

◆ ~Record()

casacore::Record::~Record ( )

Release resources associated with this object.

◆ Record() [6/7]

casacore::Record::Record ( RecordRep parent,
const RecordDesc description 
)
private

Create Record as a subrecord.

When the description is empty, the record has a variable structure. Otherwise it is fixed.

◆ Record() [7/7]

casacore::Record::Record ( RecordRep parent,
RecordType  type 
)
private

Member Function Documentation

◆ addDataField()

void casacore::Record::addDataField ( const String name,
DataType  type,
const IPosition shape,
Bool  fixedShape,
const void *  value 
)
overrideprotectedvirtual

Add a field to the record.

Implements casacore::RecordInterface.

◆ asRecord()

const RecordInterface & casacore::Record::asRecord ( const RecordFieldId ) const
overridevirtual

◆ asrwRecord()

RecordInterface & casacore::Record::asrwRecord ( const RecordFieldId )
overridevirtual

◆ assign()

void casacore::Record::assign ( const RecordInterface that)
overridevirtual

Assign that RecordInterface object to this one.

Unlike operator= it copies all data in the derived class.

Implements casacore::RecordInterface.

◆ asValueHolder()

ValueHolder casacore::Record::asValueHolder ( const RecordFieldId ) const
overridevirtual

Get or define the value as a ValueHolder.

This is useful to pass around a value of any supported type.

Reimplemented from casacore::RecordInterface.

◆ clone()

RecordInterface * casacore::Record::clone ( ) const
overridevirtual

Make a copy of this object.

Implements casacore::RecordInterface.

◆ comment()

const String & casacore::Record::comment ( const RecordFieldId ) const
overridevirtual

Get the comment for this field.

Implements casacore::RecordInterface.

◆ conform()

Bool casacore::Record::conform ( const Record other) const
inline

Returns True if this and other have the same RecordDesc, other than different names for the fields.

That is, the number, type and the order of the fields must be identical (recursively for fixed structured sub-Records in this).
Caution: thisRecord;conform(thatRecord) == True does not imply
thatRecord;conform(thisRecord) == True, because a variable record in one conforms a fixed record in that, but not vice-versa;

Definition at line 447 of file Record.h.

References casacore::RecordRep::conform(), and ref().

◆ defineDataField()

void casacore::Record::defineDataField ( Int  whichField,
DataType  type,
const void *  value 
)
overrideprotectedvirtual

Define a value in the given field.

Implements casacore::RecordInterface.

◆ defineFromValueHolder()

void casacore::Record::defineFromValueHolder ( const RecordFieldId ,
const ValueHolder  
)
overridevirtual

Reimplemented from casacore::RecordInterface.

◆ defineRecord() [1/2]

void casacore::Record::defineRecord ( const RecordFieldId ,
const Record value,
RecordType  type = Variable 
)

Define a value for the given field containing a subrecord.

When the field is unknown, it will be added to the record. The second version is meant for any type of record (e.g. Record, TableRecord, GlishRecord). It is converted to a Record using the Record constructor taking a RecordInterface object.

Referenced by casacore::RFWriter::setOptions().

◆ defineRecord() [2/2]

void casacore::Record::defineRecord ( const RecordFieldId ,
const RecordInterface value,
RecordType  = Variable 
)
overridevirtual

◆ description()

const RecordDesc & casacore::Record::description ( ) const
inline

Describes the current structure of this Record.

Definition at line 442 of file Record.h.

References casacore::RecordRep::description(), and ref().

◆ fieldNumber()

Int casacore::Record::fieldNumber ( const String fieldName) const
overridevirtual

Get the field number from the field name.

-1 is returned if the field name is unknown.

Implements casacore::RecordInterface.

◆ get_pointer() [1/2]

void * casacore::Record::get_pointer ( Int  whichField,
DataType  type 
) const
overrideprotectedvirtual

Used by the RecordField classes to attach in a type-safe way to the correct field.

Implements casacore::RecordInterface.

◆ get_pointer() [2/2]

void * casacore::Record::get_pointer ( Int  whichField,
DataType  type,
const String recordType 
) const
overrideprotectedvirtual

◆ getData()

void casacore::Record::getData ( AipsIO os,
uInt  version 
)
inline

Read the data of a record.

This is used to read a subrecord, whose description has already been read.

Definition at line 467 of file Record.h.

References casacore::RecordRep::getData(), and rwRef().

◆ getDescription()

RecordDesc casacore::Record::getDescription ( ) const
overrideprivatevirtual

Get the description of this record.

Implements casacore::RecordInterface.

◆ getRecord()

void casacore::Record::getRecord ( AipsIO os)

Read the Record from an input stream.

This is used to read a subrecord, whose description has not been read.

◆ makeUnique()

void casacore::Record::makeUnique ( )
overridevirtual

Make a unique record representation (to do copy-on-write in RecordFieldPtr).

Implements casacore::RecordInterface.

◆ merge()

void casacore::Record::merge ( const Record other,
DuplicatesFlag  = ThrowOnDuplicates 
)

Merge all fields from the other record into this record.

The DuplicatesFlag (as described in RecordInterface) determines what will be done in case a field name already exists. An exception will be thrown if other is the same as this (i.e. if merging the record itself).

◆ mergeField()

void casacore::Record::mergeField ( const Record other,
const RecordFieldId ,
DuplicatesFlag  = ThrowOnDuplicates 
)

Merge a field from another record into this record.

The DuplicatesFlag (as described in RecordInterface) determines what will be done in case the field name already exists.

◆ nfields()

uInt casacore::Record::nfields ( ) const
overridevirtual

How many fields does this structure have? A convenient synonym for description().nfields().

Implements casacore::RecordInterface.

◆ operator=()

Record & casacore::Record::operator= ( const Record other)

Copy the data in the other record to this record.

It can operate in 2 ways depending on the Record structure flag.

  • For variable structured records the existing fields are thrown away and replaced by the new fields. This means that RecordFieldPtr's using this record get invalidated. Because copy-on-write semantics are used, this kind of assignment is a very efficient operation.
  • For fixed structured records the existing values are replaced by the new values. This means that RecordFieldPtr's using this record remain valid. The structure of the other record has to conform this record or this record has to be empty, otherwise an exception is thrown. This assignment is less efficient, because it has to check the conformance and because each value has to be copied.


Warning: Attributes like fixed structure flag and check function will not be copied;

◆ print()

void casacore::Record::print ( std::ostream &  ,
Int  maxNrValues = 25,
const String indent = "" 
) const
overridevirtual

Print the contents of the record.

Only the first maxNrValues of an array will be printed. A value < 0 means the entire array.

Implements casacore::RecordInterface.

◆ putData()

void casacore::Record::putData ( AipsIO os) const
inline

Put the data of a record.

This is used to write a subrecord, whose description has already been written.

Definition at line 457 of file Record.h.

References casacore::RecordRep::putData(), and ref().

◆ putRecord()

void casacore::Record::putRecord ( AipsIO os) const

Write the Record to an output stream.

This is used to write a subrecord, whose description has not been written.

◆ ref()

const RecordRep & casacore::Record::ref ( ) const
inlineprotected

Return a const reference to the underlying RecordRep.

Definition at line 438 of file Record.h.

References rep_p.

Referenced by conform(), description(), and putData().

◆ removeField()

void casacore::Record::removeField ( const RecordFieldId )
overridevirtual

Remove a field from the record.


Caution: Removing a field means that the field number of the fields following it will be decremented; Only the RecordFieldPtr's pointing to the removed field will be invalidated;

Implements casacore::RecordInterface.

◆ renameField()

void casacore::Record::renameField ( const String newName,
const RecordFieldId  
)

Rename the given field.

◆ restructure()

void casacore::Record::restructure ( const RecordDesc newDescription,
Bool  recursive = True 
)
overridevirtual

Change the structure of this Record to contain the fields in newDescription.

After calling restructure, description() == newDescription. Any existing RecordFieldPtr objects are invalidated (their isAttached() members return False) after this call.
When the new description contains subrecords, those subrecords will be restructured if recursive=True is given. Otherwise the subrecord is a variable empty record. Subrecords will be variable if their description is empty (i.e. does not contain any field), otherwise they are fixed. The 2nd form of the restructure function will overwrite those implicit record types with the given record type. The new type will also be given to this top record.
Restructuring is not possible and an exception is thrown if the Record has a fixed structure.

Implements casacore::RecordInterface.

◆ rwRef()

RecordRep & casacore::Record::rwRef ( )
protected

Return a non-const reference to the underlying RecordRep.

When needed, the RecordRep will be copied and all RecordField objects will be notified.

Referenced by getData().

◆ rwSubRecord()

Record & casacore::Record::rwSubRecord ( const RecordFieldId )

◆ setComment()

void casacore::Record::setComment ( const RecordFieldId ,
const String comment 
)
overridevirtual

Set the comment for this field.

Implements casacore::RecordInterface.

◆ subRecord()

const Record & casacore::Record::subRecord ( const RecordFieldId ) const

Get the subrecord from the given field.


Note: The non-const version has a different name to prevent that the copy-on-write mechanism makes a copy when not necessary;

◆ type()

DataType casacore::Record::type ( Int  whichField) const
overridevirtual

Get the data type of this field.

Implements casacore::RecordInterface.

Friends And Related Symbol Documentation

◆ operator<<

AipsIO & operator<< ( AipsIO os,
const Record rec 
)
friend

Write the Record to an output stream.

Definition at line 452 of file Record.h.

◆ operator>>

AipsIO & operator>> ( AipsIO os,
Record rec 
)
friend

Read the Record from an input stream.

Definition at line 462 of file Record.h.

◆ RecordRep

friend class RecordRep
friend

Definition at line 179 of file Record.h.

Member Data Documentation

◆ parent_p

RecordRep* casacore::Record::parent_p
private

The parent Record.

Definition at line 433 of file Record.h.

◆ rep_p

COWPtr<RecordRep> casacore::Record::rep_p
private

The Record representation.

Definition at line 431 of file Record.h.

Referenced by ref().


The documentation for this class was generated from the following file: