casacore
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
casacore::TableRecord Class Reference

More...

#include <TableRecord.h>

Public Member Functions

 TableRecord ()
 Create a record with no fields. More...
 
 TableRecord (RecordType type, CheckFieldFunction *=0, const void *checkArgument=0)
 Create a record with no fields. More...
 
 TableRecord (const RecordDesc &description, RecordType type=Fixed, CheckFieldFunction *=0, const void *checkArgument=0)
 Create a record with the given description. More...
 
 TableRecord (const TableRecord &other)
 Create a copy of other using copy semantics. More...
 
 TableRecord (const RecordInterface &other)
 Create a TableRecord from another type of record. More...
 
TableRecordoperator= (const TableRecord &other)
 Copy the data in the other record to this record. More...
 
 ~TableRecord ()
 Release resources associated with this object. More...
 
virtual RecordInterfaceclone () const
 Make a copy of this object. More...
 
virtual void assign (const RecordInterface &that)
 Assign that RecordInterface object to this one. More...
 
Record toRecord () const
 Convert the TableRecord to a Record (recursively). More...
 
void fromRecord (const Record &rec)
 Fill the TableRecord from the given Record. More...
 
virtual ValueHolder asValueHolder (const RecordFieldId &) const
 Get or define the value as a ValueHolder. More...
 
virtual void defineFromValueHolder (const RecordFieldId &, const ValueHolder &)
 
virtual const Stringcomment (const RecordFieldId &) const
 Get the comment for this field. More...
 
virtual void setComment (const RecordFieldId &, const String &comment)
 Set the comment for this field. More...
 
const RecordDescdescription () const
 Describes the current structure of this TableRecord. More...
 
virtual void restructure (const RecordDesc &newDescription, Bool recursive=True)
 Change the structure of this TableRecord to contain the fields in newDescription. More...
 
Bool conform (const TableRecord &other) const
 Returns True if this and other have the same RecordDesc, other than different names for the fields. More...
 
virtual uInt nfields () const
 How many fields does this structure have? A convenient synonym for description().nfields(). More...
 
virtual Int fieldNumber (const String &fieldName) const
 Get the field number from the field name. More...
 
virtual DataType type (Int whichField) const
 Get the data type of this field. More...
 
void removeField (const RecordFieldId &)
 Remove a field from the record. More...
 
void renameField (const String &newName, const RecordFieldId &)
 Rename the given field. More...
 
void defineRecord (const RecordFieldId &, const TableRecord &value, RecordType type=Variable)
 Define a value for the given field. More...
 
virtual void defineRecord (const RecordFieldId &, const RecordInterface &value, RecordType=Variable)
 
void defineTable (const RecordFieldId &, const Table &value, RecordType type=Variable)
 
const TableRecordsubRecord (const RecordFieldId &) const
 Get the subrecord or table from the given field. More...
 
TableRecordrwSubRecord (const RecordFieldId &)
 
virtual const RecordInterfaceasRecord (const RecordFieldId &) const
 
virtual RecordInterfaceasrwRecord (const RecordFieldId &)
 
Table asTable (const RecordFieldId &) const
 Get the table from the given field. More...
 
Table asTable (const RecordFieldId &, const TableLock &lockOptions) const
 
const TableAttrtableAttributes (const RecordFieldId &) const
 Get the attributes of a table field. More...
 
void mergeField (const TableRecord &other, const RecordFieldId &, DuplicatesFlag=ThrowOnDuplicates)
 Merge a field from another record into this record. More...
 
void merge (const TableRecord &other, DuplicatesFlag=ThrowOnDuplicates)
 Merge all fields from the other record into this record. More...
 
void closeTable (const RecordFieldId &) const
 Close the table in the given field. More...
 
void closeTables () const
 Close all open tables. More...
 
void flushTables (Bool fsync=False) const
 Flush all open subtables. More...
 
void renameTables (const String &newParentName, const String &oldParentName)
 Rename the subtables with a path containing the old parent table name. More...
 
Bool areTablesMultiUsed () const
 Are subtables used in other processes. More...
 
void putRecord (AipsIO &os, const TableAttr &) const
 Put the data of a record. More...
 
void getRecord (AipsIO &os, const TableAttr &)
 Read a record. More...
 
void putData (AipsIO &os, const TableAttr &) const
 Put the data of a record. More...
 
void getData (AipsIO &os, uInt version, const TableAttr &)
 Read the data of a record. More...
 
virtual void print (std::ostream &, Int maxNrValues=25, const String &indent="") const
 Print the contents of the record. More...
 
void reopenRW ()
 Reopen possible tables in keywords as read/write. More...
 
void setTableAttr (const TableRecord &other, const TableAttr &defaultAttr)
 Recursively set the attributes of subtables to the ones in the other record for matching subtable field names. More...
 
virtual void makeUnique ()
 Make a unique record representation (to do copy-on-write in RecordFieldPtr). More...
 
- Public Member Functions inherited from casacore::RecordInterface
 RecordInterface ()
 The default constructor creates an empty record with a variable structure. More...
 
 RecordInterface (RecordType type, CheckFieldFunction *funcPtr, const void *checkArgument)
 Create a record with no fields. More...
 
 RecordInterface (const RecordInterface &other)
 Copy constructor (copy semantics). More...
 
RecordInterfaceoperator= (const RecordInterface &other)
 Assignment (copy semantics). More...
 
virtual ~RecordInterface ()
 Destruct the record. More...
 
Bool isFixed () const
 Is the Record structure fixed (i.e. More...
 
uInt size () const
 
bool empty () const
 Is the record empty? More...
 
Int idToNumber (const RecordFieldId &) const
 Get the field number for the given field id. More...
 
Bool isDefined (const String &fieldName) const
 Test if a field name exists. More...
 
DataType dataType (const RecordFieldId &) const
 
String name (const RecordFieldId &) const
 Get the name of this field. More...
 
IPosition shape (const RecordFieldId &) const
 Get the actual shape of this field. More...
 
RecordDesc description () const
 Get the description of this record. More...
 
void define (const RecordFieldId &, Bool value)
 Define a value for the given field. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
Double asdouble (const RecordFieldId &) const
 
const Array< Float > & asArrayfloat (const RecordFieldId &) const
 
const Array< Double > & asArraydouble (const RecordFieldId &) const
 
- Public Member Functions inherited from casacore::NoticeSource
 NoticeSource ()
 
virtual ~NoticeSource ()
 
void notify (const Notice &note)
 Sends the note to all NoticeTargets in the target list. More...
 

Protected Member Functions

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

Private Member Functions

virtual RecordDesc getDescription () const
 Get the description of this record. More...
 
 TableRecord (TableRecordRep *parent, const RecordDesc &description)
 Create TableRecord as a subrecord. More...
 
 TableRecord (TableRecordRep *parent, RecordType type)
 
void setRecordType (RecordType type)
 Set the recordtype of this record and all its subrecords (recursively). More...
 

Private Attributes

COWPtr< TableRecordReprep_p
 The TableRecord representation. More...
 
TableRecordRepparent_p
 The parent TableRecord. More...
 

Friends

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

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. More...
 

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:
tTableRecord

Prerequisite

Etymology

TableRecord is a Record to be used in the Table system.

Synopsis

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

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

A TableRecord is an hierarchical structure, because it can have fields containing TableRecord'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 TableRecord 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.
A Table field is conforming when the name of the table description of the source table matches the table description name defined in the RecordDesc field. When that name is blank, every table matches. In fact, defining a table description name is identical to defining an array shape..

When a TableRecord is read back, possible Tables contained in fields are only opended and read back when they are accessed for the first time. In that way no needless table opens are done. When a table has been opened, it is possible to close it. This can be useful to save memory usage.

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

Example

{
TableDesc td ("td", TableDesc::Scratch);
td.addColumn (ScalarColumnDesc<Int> ("col1"));
td.addColumn (ScalarColumnDesc<float> ("col2"));
SetupNewTable newtab ("tTableRecord_tmp.tab1", td1, Table::New);
Table tab (newtab, 10);
RecordDesc rd;
rd.addTable ("tab1", "td"); // with description name
rd.addField ("tab2", TpTable); // without description name
// Both define's are possible.
// The first one because the table description name matches.
// The second one because that field has no table description name,
// thus every table description matches.
rec.defineTable (rec.fieldNumber("tab1"), tab1);
rec.defineTable (rec.fieldNumber("tab2"), tab1);
Table t1 = rec.asTable ("tab1");
AlwaysAssertExit (t1.nrow() == 10 && t1.tableDesc().ncolumn() == 2);
Table t2 = rec.asTable ("tab2");
AlwaysAssertExit (t2.nrow() == 10 && t2.tableDesc().ncolumn() == 2);
AipsIO aos ("file.name", ByteIO::New);
aos << rec;
}
// Note that he above is put in a separate scope to be sure that
// all objects are deleted and tables are written.
{
AipsIO aos ("file.name");
aos >> rec;
// At this point the record is read back, but the tables are not opened.
// The next statement accesses the table resulting in its open.
Table t1 = rec.asTable ("tab1");
// The following statement closes it again.
rec.closeTable ("tab1");
#define AlwaysAssertExit(expr)
Definition: Assert.h:159
@ New
read/write; create file if not exist.
Definition: ByteIO.h:72
@ Variable
Record has a variable structure; after Record creation fields can be added or removed at will.
TableRecord()
Create a record with no fields.
@ New
create table
Definition: Table.h:176

Motivation

In principle the class Record could also support data type Table. However, this would have had the big disadvantage that all the Table code would have be linked in when only a simple Record is needed. It was decided that for that reason it was better to support tables in a separate class.

To Do

Definition at line 185 of file TableRecord.h.

Constructor & Destructor Documentation

◆ TableRecord() [1/7]

casacore::TableRecord::TableRecord ( )

Create a record with no fields.

The record has a variable structure.

◆ TableRecord() [2/7]

casacore::TableRecord::TableRecord ( 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).

◆ TableRecord() [3/7]

casacore::TableRecord::TableRecord ( 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).

◆ TableRecord() [4/7]

casacore::TableRecord::TableRecord ( const TableRecord other)

Create a copy of other using copy semantics.

◆ TableRecord() [5/7]

casacore::TableRecord::TableRecord ( const RecordInterface other)

Create a TableRecord from another type of record.

It uses copy-on-write semantics if possible (i.e. if other is a TableRecord), otherwise each field is copied. Subrecords are also copied and converted to TableRecords if needed.

◆ ~TableRecord()

casacore::TableRecord::~TableRecord ( )

Release resources associated with this object.

◆ TableRecord() [6/7]

casacore::TableRecord::TableRecord ( TableRecordRep parent,
const RecordDesc description 
)
private

Create TableRecord as a subrecord.

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

◆ TableRecord() [7/7]

casacore::TableRecord::TableRecord ( TableRecordRep parent,
RecordType  type 
)
private

Member Function Documentation

◆ addDataField()

virtual void casacore::TableRecord::addDataField ( const String name,
DataType  type,
const IPosition shape,
Bool  fixedShape,
const void *  value 
)
protectedvirtual

Add a field to the record.

Implements casacore::RecordInterface.

◆ areTablesMultiUsed()

Bool casacore::TableRecord::areTablesMultiUsed ( ) const
inline

Are subtables used in other processes.

Definition at line 561 of file TableRecord.h.

References casacore::TableRecordRep::areTablesMultiUsed(), and ref().

◆ asRecord()

virtual const RecordInterface& casacore::TableRecord::asRecord ( const RecordFieldId ) const
virtual

◆ asrwRecord()

virtual RecordInterface& casacore::TableRecord::asrwRecord ( const RecordFieldId )
virtual

◆ assign()

virtual void casacore::TableRecord::assign ( const RecordInterface that)
virtual

Assign that RecordInterface object to this one.

If that is a TableRecord, copy-on-write is used. Otherwise each individual field is copied.

Implements casacore::RecordInterface.

Referenced by casacore::ImageInterface< T >::setMiscInfoMember().

◆ asTable() [1/2]

Table casacore::TableRecord::asTable ( const RecordFieldId ) const

Get the table from the given field.

By default the read/write option and lock options are inherited from the parent table. If openWritable=True, the table is still opened as readonly if the file permissions do not permit write access.

◆ asTable() [2/2]

Table casacore::TableRecord::asTable ( const RecordFieldId ,
const TableLock lockOptions 
) const

◆ asValueHolder()

virtual ValueHolder casacore::TableRecord::asValueHolder ( const RecordFieldId ) const
virtual

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()

virtual RecordInterface* casacore::TableRecord::clone ( ) const
virtual

Make a copy of this object.

Implements casacore::RecordInterface.

◆ closeTable()

void casacore::TableRecord::closeTable ( const RecordFieldId ) const

Close the table in the given field.

When accessed again, it will be opened automatically. This can be useful to save memory usage.

◆ closeTables()

void casacore::TableRecord::closeTables ( ) const
inline

Close all open tables.

When accessed again, it will be opened automatically. This can be useful to save memory usage.

Definition at line 545 of file TableRecord.h.

References casacore::TableRecordRep::closeTables(), and ref().

◆ comment()

virtual const String& casacore::TableRecord::comment ( const RecordFieldId ) const
virtual

Get the comment for this field.

Implements casacore::RecordInterface.

◆ conform()

Bool casacore::TableRecord::conform ( const TableRecord 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 523 of file TableRecord.h.

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

◆ defineDataField()

virtual void casacore::TableRecord::defineDataField ( Int  whichField,
DataType  type,
const void *  value 
)
protectedvirtual

Define a value in the given field.

Implements casacore::RecordInterface.

◆ defineFromValueHolder()

virtual void casacore::TableRecord::defineFromValueHolder ( const RecordFieldId ,
const ValueHolder  
)
virtual

Reimplemented from casacore::RecordInterface.

◆ defineRecord() [1/2]

virtual void casacore::TableRecord::defineRecord ( const RecordFieldId ,
const RecordInterface value,
RecordType  = Variable 
)
virtual

◆ defineRecord() [2/2]

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

Define a value for the given field.

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 TableRecord using the TableRecord constructor taking a RecordInterface object.

◆ defineTable()

void casacore::TableRecord::defineTable ( const RecordFieldId ,
const Table value,
RecordType  type = Variable 
)

◆ description()

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

Describes the current structure of this TableRecord.

Definition at line 518 of file TableRecord.h.

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

◆ fieldNumber()

virtual Int casacore::TableRecord::fieldNumber ( const String fieldName) const
virtual

Get the field number from the field name.

-1 is returned if the field name is unknown.

Implements casacore::RecordInterface.

◆ flushTables()

void casacore::TableRecord::flushTables ( Bool  fsync = False) const
inline

Flush all open subtables.

Definition at line 550 of file TableRecord.h.

References casacore::TableRecordRep::flushTables(), and ref().

◆ fromRecord()

void casacore::TableRecord::fromRecord ( const Record rec)

Fill the TableRecord from the given Record.

The fields are appended to the TableRecord. It is the opposite of toRecord, so a String containing 'Table: ' is handled as a Table (if it exists).

◆ get_pointer() [1/2]

virtual void* casacore::TableRecord::get_pointer ( Int  whichField,
DataType  type 
) const
protectedvirtual

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

Implements casacore::RecordInterface.

◆ get_pointer() [2/2]

virtual void* casacore::TableRecord::get_pointer ( Int  whichField,
DataType  type,
const String recordType 
) const
protectedvirtual

◆ getData()

void casacore::TableRecord::getData ( AipsIO os,
uInt  version,
const TableAttr parentAttr 
)
inline

Read the data of a record.

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

Definition at line 534 of file TableRecord.h.

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

◆ getDescription()

virtual RecordDesc casacore::TableRecord::getDescription ( ) const
privatevirtual

Get the description of this record.

Implements casacore::RecordInterface.

◆ getRecord()

void casacore::TableRecord::getRecord ( AipsIO os,
const TableAttr  
)

Read a record.

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

◆ makeUnique()

virtual void casacore::TableRecord::makeUnique ( )
virtual

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

Implements casacore::RecordInterface.

◆ merge()

void casacore::TableRecord::merge ( const TableRecord 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::TableRecord::mergeField ( const TableRecord 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()

virtual uInt casacore::TableRecord::nfields ( ) const
virtual

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

Implements casacore::RecordInterface.

◆ operator=()

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

Copy the data in the other record to this record.

It can operate in 2 ways depending on the TableRecord 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()

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

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::TableRecord::putData ( AipsIO os,
const TableAttr parentAttr 
) const
inline

Put the data of a record.

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

Definition at line 528 of file TableRecord.h.

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

◆ putRecord()

void casacore::TableRecord::putRecord ( AipsIO os,
const TableAttr  
) const

Put the data of a record.

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

◆ ref()

const TableRecordRep & casacore::TableRecord::ref ( ) const
inlineprotected

Return a const reference to the underlying TableRecordRep.

Definition at line 514 of file TableRecord.h.

References rep_p.

Referenced by areTablesMultiUsed(), closeTables(), conform(), description(), flushTables(), and putData().

◆ removeField()

void casacore::TableRecord::removeField ( const RecordFieldId )
virtual

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::TableRecord::renameField ( const String newName,
const RecordFieldId  
)

Rename the given field.

◆ renameTables()

void casacore::TableRecord::renameTables ( const String newParentName,
const String oldParentName 
)
inline

Rename the subtables with a path containing the old parent table name.

Definition at line 555 of file TableRecord.h.

References casacore::TableRecordRep::renameTables(), and rwRef().

◆ reopenRW()

void casacore::TableRecord::reopenRW ( )
inline

Reopen possible tables in keywords as read/write.

Tables are not reopened if they are not writable.

Definition at line 540 of file TableRecord.h.

References casacore::TableRecordRep::reopenRW(), and rwRef().

◆ restructure()

virtual void casacore::TableRecord::restructure ( const RecordDesc newDescription,
Bool  recursive = True 
)
virtual

Change the structure of this TableRecord 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.
Restructuring is not possible and an exception is thrown if the Record has a fixed structure.

Implements casacore::RecordInterface.

◆ rwRef()

TableRecordRep& casacore::TableRecord::rwRef ( )
protected

Return a non-const reference to the underlying TableRecordRep.

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

Referenced by getData(), renameTables(), and reopenRW().

◆ rwSubRecord()

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

◆ setComment()

virtual void casacore::TableRecord::setComment ( const RecordFieldId ,
const String comment 
)
virtual

Set the comment for this field.

Implements casacore::RecordInterface.

◆ setRecordType()

void casacore::TableRecord::setRecordType ( RecordType  type)
private

Set the recordtype of this record and all its subrecords (recursively).

◆ setTableAttr()

void casacore::TableRecord::setTableAttr ( const TableRecord other,
const TableAttr defaultAttr 
)

Recursively set the attributes of subtables to the ones in the other record for matching subtable field names.

Otherwise set it to defaultAttr. The name attribute is not changed. It is primarily a helper function for PlainTable::syncTable and ColumnSet::syncColumns.
However, it can also be used to achieve that all subtables of a read/write table are opened as readonly. E.g.:

TableAttr newAttr(String(), False, mainTable.lockOptions());
mainTable.keywordSet().setTableAttr (TableRecord(), newAttr);
const Bool False
Definition: aipstype.h:44

◆ subRecord()

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

Get the subrecord or table 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;

◆ tableAttributes()

const TableAttr& casacore::TableRecord::tableAttributes ( const RecordFieldId ) const

Get the attributes of a table field.

◆ toRecord()

Record casacore::TableRecord::toRecord ( ) const

Convert the TableRecord to a Record (recursively).

A possible Table object is converted to a string containing the table name preceeded by 'Table: ' (as used by TableProxy).

◆ type()

virtual DataType casacore::TableRecord::type ( Int  whichField) const
virtual

Get the data type of this field.

Implements casacore::RecordInterface.

Friends And Related Function Documentation

◆ operator<<

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

Write the TableRecord to an output stream.

◆ operator>>

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

Read the TableRecord from an input stream.

◆ TableRecordRep

friend class TableRecordRep
friend

Definition at line 187 of file TableRecord.h.

Member Data Documentation

◆ parent_p

TableRecordRep* casacore::TableRecord::parent_p
private

The parent TableRecord.

Definition at line 509 of file TableRecord.h.

◆ rep_p

COWPtr<TableRecordRep> casacore::TableRecord::rep_p
private

The TableRecord representation.

Definition at line 507 of file TableRecord.h.

Referenced by ref().


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