Loading...
Searching...
No Matches
casacore::TableRecordRep Class Reference
tables package (libcasa_tables) » Tables_module » Tables_module_internal_classes

More...

`#include <TableRecordRep.h>`

## Public Member Functions

| TableRecordRep ()
| Create a record with no fields.
| TableRecordRep (const RecordDesc &description)
| Create a record with the given description.
| TableRecordRep (const TableRecordRep &other)
| Create a copy of other using copy semantics.
TableRecordRep & | operator= (const TableRecordRep &other)
| Copy all the data over.
| ~TableRecordRep ()
| Delete all data.
const String & | comment (Int whichField) const
| Get the comment for this field.
void | setComment (Int whichField, const String &comment)
| Set the comment for this field.
const RecordDesc & | description () const
| Describes the current structure of this Record.
void | restructure (const RecordDesc &newDescription, Bool recursive)
| Change the structure of this Record to contain the fields in newDescription.
Bool | conform (const TableRecordRep &other) const
| Returns True if this and other have the same RecordDesc, other than different names for the fields.
void | renameField (const String &newName, Int whichField)
| Rename the given field.
void | copyData (const TableRecordRep &other)
| Copy all data of the TableRecord.
void | addField (const String &name, const TableRecord &value, RecordInterface::RecordType type)
| Add a field with the given name and value to the record.
void | addField (const String &name, const Table &value, RecordInterface::RecordType type)
void | defineDataField (Int whichField, DataType type, const void *value)
| Define a value for the given field.
void | closeTable (Int whichField) const
| Close the table in the given field.
void | closeTables () const
| Close all open tables.
void | flushTables (Bool fsync) const
| Flush all open subtables.
void | renameTables (const String &newParentName, const String &oldParentName)
| Rename the subtables with a path containing the old parent table name.
Bool | areTablesMultiUsed () const
| Are subtables used in other processes.
void | putRecord (AipsIO &os, Int recordType, const TableAttr &) const
| Put the description and data of the Record.
void | getRecord (AipsIO &os, Int &recordType, const TableAttr &)
| Get the description and data of the Record.
void | putData (AipsIO &os, const TableAttr &) const
| Put the data of a record.
void | getData (AipsIO &os, uInt version, const TableAttr &)
| Read the data of a record.
void | reopenRW ()
| Reopen possible tables in keywords as read/write.
void * | get_pointer (Int whichField, DataType type) const
| Used by the RecordFieldPtr classes to attach in a type-safe way to the correct field.
void * | get_pointer (Int whichField, DataType type, const String &recordType) const
void | mergeField (const TableRecordRep &other, Int whichFieldFromOther, RecordInterface::DuplicatesFlag)
| Merge a field from another record into this record.
void | merge (const TableRecordRep &other, RecordInterface::DuplicatesFlag)
| Merge all fields from the other record into this record.
void | print (std::ostream &, Int maxNrValues=25, const String &indent="") const
| Print a record.
Public Member Functions inherited from casacore::RecordRep
| RecordRep ()
| Create a record with no fields.
| RecordRep (const RecordDesc &description)
| Create a record with the given description.
| RecordRep (const RecordRep &other)
| Create a copy of other using copy semantics.
RecordRep & | operator= (const RecordRep &other)
| Copy all the data over.
virtual | ~RecordRep ()
| Delete all data.
const String & | comment (Int whichField) const
| Get the comment for this field.
void | setComment (Int whichField, const String &comment)
| Set the comment for this field.
const RecordDesc & | description () const
| Describes the current structure of this Record.
void | restructure (const RecordDesc &newDescription, Bool recursive)
| Change the structure of this Record to contain the fields in newDescription.
Bool | conform (const RecordRep &other) const
| Returns True if this and other have the same RecordDesc, other than different names for the fields.
void | copyData (const RecordRep &other)
| Copy all data of the Record.
void | copyDataField (DataType type, Int whichField, const void *that) const
| Copy a data field.
void | removeField (Int whichField)
| Remove a field from the record.
void | renameField (const String &newName, Int whichField)
| Rename the given field.
void | addDataField (const String &name, DataType type, const IPosition &shape, Bool fixedShape, const void *data)
| Add a field with the given name and value to the record.
void | addField (const String &name, const Record &value, RecordInterface::RecordType type)
void | defineDataField (Int whichField, DataType type, const void *value)
| Define a value for the given field.
void | putRecord (AipsIO &os, int recordType) const
| Put the description and data of the Record.
void | getRecord (AipsIO &os, Int &recordType)
| Get the description and data of the Record.
void | putData (AipsIO &os) const
| Put the data of a record.
void | getData (AipsIO &os, uInt version)
| Read the data of a record.
void * | get_pointer (Int whichField, DataType type) const
| Used by the RecordFieldPtr classes to attach in a type-safe way to the correct field.
void * | get_pointer (Int whichField, DataType type, const String &recordType) const
void | mergeField (const RecordRep &other, Int whichFieldFromOther, RecordInterface::DuplicatesFlag)
| Merge a field from another record into this record.
void | merge (const RecordRep &other, RecordInterface::DuplicatesFlag)
| Merge all fields from the other record into this record.
void | print (std::ostream &, Int maxNrValues=25, const String &indent="") const
| Print a record.

## Protected Member Functions

void | copy_other (const TableRecordRep &other)
| Utility function to avoid code duplication in the public member functions.
virtual Int | fieldNumber (const String &name) const
| Get the field number for a given name.
virtual void | addFieldToDesc (const String &name, DataType type, const IPosition &shape, Bool fixedShape)
| Add a field to the description.
virtual void | removeData (Int whichField, void *ptr, void *vecptr)
| Remove a data field.
virtual void | removeFieldFromDesc (Int whichField)
| Remove a field from the description.
void | getTableKeySet (AipsIO &os, uInt version, const TableAttr &, uInt type)
| Get a KeywordSet object as a TableRecord.
Protected Member Functions inherited from casacore::RecordRep
void | delete_myself (uInt nfields)
| Utility functions to avoid code duplication in the public member functions.
void | copy_other (const RecordRep &other)
void | addDataPtr (void *ptr)
| Add the data pointer to the data block.
void | removeDataPtr (Int index)
| Remove a data pointer add the given index.
void | checkShape (DataType type, const IPosition &shape, const void *value, const String &fieldName)
| Check if the shape of the data array matches the shape of a fixed-shaped array in the description.
void * | createDataField (DataType type, const IPosition &shape)
| Create a data field for the given type and shape.
void | deleteDataField (DataType type, void *ptr, void *vecptr)
| Delete a data field.
void | copyDataField (DataType type, void *ptr, const void *that) const
| Copy a data field.
void | printDataField (std::ostream &os, DataType type, const String &indent, Int maxNrValues, const void *ptr) const
| Print a data field.
void | putDataField (AipsIO &os, DataType type, const void *ptr) const
| Put a data field.
void | getDataField (AipsIO &os, DataType type, void *ptr)
| Get a data field.
void | makeDataVec (Int whichField, DataType type)
| Make an array for a scalar data field.
void | getKeySet (AipsIO &os, uInt version, uInt type)
| Get a Scalar/ArrayKeywordSet object as a Record.
void | getKeyDesc (AipsIO &os, RecordDesc &desc)
| Get the description of a keyword set as a RecordDesc.
void | getScalarKeys (AipsIO &os)
| Get the scalar values of a keyword set.
void | getArrayKeys (AipsIO &os)
| Get the array values of a keyword set.

## Protected Attributes

RecordDesc | desc_p
| Holds the description.
Protected Attributes inherited from casacore::RecordRep
RecordDesc | desc_p
| Holds the structure of this Record.
Block< void * > | data_p
| Pointers to data values.
Block< void * > | datavec_p
| Pointers to a vector of a scalar (to access a scalar as an array).
uInt | nused_p
| #Entries used in data_p.

## Detailed Description

The representation of a TableRecord

### Intended use:

Internal

### Review Status

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

### Prerequisite

- TableRecord.
- RecordRep.

### Etymology

TableRecordRep is the REPresentation of a TableRecord.

### Synopsis

TableRecordRep is the actual implementation of a TableRecord object. It contains the description and the data. The data is stored as a collection of void* pointers to the actual data. By storing it in this indirect way, it is easier to extend the data block. It also means that RecordFieldPtr objects always have the correct pointer and do not need to be adjusted when the data block is extended.

Despite the fact that the data pointers have type void*, the functions are completely type safe. This is done by passing the type around using the DataType enumeration. The downpart is that only types from that enumeration are supported (but that is also required by the RecordDesc mechanics).

Note that TableRecordRep does not know anything about RecordFieldPtr objects pointing to its data. Only its mother class TableRecord knows about them and handles all cases where the RecordFieldPtr's have to be notified.

Fields containing tables are not directly handled using class Table. Instead the class TableKeyword is used to map a table name to a table and to take care of opening a table on demand.

### Example

TableRecordRep mirrors all functions in TableRecord.

### Motivation

Having a separate TableRecordRep class makes copy-on-write possible. It also allows derivation from RecordRep.

Definition at line 95 of file TableRecordRep.h.

## Constructor & Destructor Documentation

## TableRecordRep() [1/3]

casacore::TableRecordRep::TableRecordRep | ( |  | ) |

Create a record with no fields.

Referenced by conform(), copy_other(), copyData(), merge(), mergeField(), operator=(), and TableRecordRep().

## TableRecordRep() [2/3]

casacore::TableRecordRep::TableRecordRep | ( | const RecordDesc & | description | ) |

Create a record with the given description.

If it is not possible to create all fields (for example, if a field of an unsupported type is requested), an exception is thrown. All fields are checked by the field checking function (if defined).

References description().

## TableRecordRep() [3/3]

casacore::TableRecordRep::TableRecordRep | ( | const TableRecordRep & | other | ) |

Create a copy of other using copy semantics.

References TableRecordRep().

## ~TableRecordRep()

casacore::TableRecordRep::~TableRecordRep | ( |  | ) |

Delete all data.

References comment().

## Member Function Documentation

## addField() [1/2]

void casacore::TableRecordRep::addField | ( | const String & | name,
|  | const Table & | value,
|  | RecordInterface::RecordType | type )

References casacore::name(), and casacore::NewDelAllocator< T >::value.

## addField() [2/2]

void casacore::TableRecordRep::addField | ( | const String & | name,
|  | const TableRecord & | value,
|  | RecordInterface::RecordType | type )

Add a field with the given name and value to the record.

The data type of the field is determined by the data type of the value.

References casacore::name(), and casacore::NewDelAllocator< T >::value.

## addFieldToDesc()

virtual void casacore::TableRecordRep::addFieldToDesc | ( | const String & | name,
|  | DataType | type,
|  | const IPosition & | shape,
|  | Bool | fixedShape )

protected virtual

Add a field to the description.

Reimplemented from casacore::RecordRep.

References casacore::name(), and casacore::shape().

## areTablesMultiUsed()

Bool casacore::TableRecordRep::areTablesMultiUsed | ( |  | ) | const

Are subtables used in other processes.

Referenced by casacore::TableRecord::areTablesMultiUsed().

## closeTable()

void casacore::TableRecordRep::closeTable | ( | Int | whichField | ) | 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::TableRecordRep::closeTables | ( |  | ) | const

Close all open tables.

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

Referenced by casacore::TableRecord::closeTables().

## comment()

const String & casacore::TableRecordRep::comment | ( | Int | whichField | ) | const

inline

Get the comment for this field.

Definition at line 265 of file TableRecordRep.h.

References desc_p.

Referenced by setComment(), and ~TableRecordRep().

## conform()

Bool casacore::TableRecordRep::conform | ( | const TableRecordRep & | other | ) | const

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;

References TableRecordRep().

Referenced by casacore::TableRecord::conform().

## copy_other()

void casacore::TableRecordRep::copy_other | ( | const TableRecordRep & | other | ) |

protected

Utility function to avoid code duplication in the public member functions.

References TableRecordRep().

## copyData()

void casacore::TableRecordRep::copyData | ( | const TableRecordRep & | other | ) |

Copy all data of the TableRecord.

References TableRecordRep().

## defineDataField()

void casacore::TableRecordRep::defineDataField | ( | Int | whichField,
|  | DataType | type,
|  | const void * | value )

Define a value for the given field.

Array conformance rules will not be applied for variable shaped arrays. When the field and value data type mismatch, type promotion of scalars will be done if possible. If not possible, an exception is thrown.

References casacore::NewDelAllocator< T >::value.

## description()

const RecordDesc & casacore::TableRecordRep::description | ( |  | ) | const

inline

Describes the current structure of this Record.

Definition at line 275 of file TableRecordRep.h.

References desc_p.

Referenced by casacore::TableRecord::description(), and TableRecordRep().

## fieldNumber()

virtual Int casacore::TableRecordRep::fieldNumber | ( | const String & | name | ) | const

protected virtual

Get the field number for a given name.

Reimplemented from casacore::RecordRep.

References casacore::name().

## flushTables()

void casacore::TableRecordRep::flushTables | ( | Bool | fsync | ) | const

Flush all open subtables.

Referenced by casacore::TableRecord::flushTables().

## get_pointer() [1/2]

void * casacore::TableRecordRep::get_pointer | ( | Int | whichField,
|  | DataType | type ) const

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

## get_pointer() [2/2]

void * casacore::TableRecordRep::get_pointer | ( | Int | whichField,
|  | DataType | type,
|  | const String & | recordType ) const

References casacore::recordType().

## getData()

void casacore::TableRecordRep::getData | ( | AipsIO & | os,
|  | uInt | version,
|  | const TableAttr & | )

Read the data of a record.

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

Referenced by casacore::TableRecord::getData().

## getRecord()

void casacore::TableRecordRep::getRecord | ( | AipsIO & | os,
|  | Int & | recordType,
|  | const TableAttr & | )

Get the description and data of the Record.

It also gets the fixedFlag attribute (of the mother object).

References casacore::recordType().

## getTableKeySet()

void casacore::TableRecordRep::getTableKeySet | ( | AipsIO & | os,
|  | uInt | version,
|  | const TableAttr & | ,
|  | uInt | type )

protected

Get a KeywordSet object as a TableRecord.

(type: 0=ScalarKeywordSet, 1=ArrayKeywordSet, 2=TableKeywordSet)

## merge()

void casacore::TableRecordRep::merge | ( | const TableRecordRep & | other,
|  | RecordInterface::DuplicatesFlag | )

Merge all fields from the other record into this record.

References TableRecordRep().

## mergeField()

void casacore::TableRecordRep::mergeField | ( | const TableRecordRep & | other,
|  | Int | whichFieldFromOther,
|  | RecordInterface::DuplicatesFlag | )

Merge a field from another record into this record.

References TableRecordRep().

## operator=()

TableRecordRep & casacore::TableRecordRep::operator= | ( | const TableRecordRep & | other | ) |

Copy all the data over.

References TableRecordRep().

## print()

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

Print a record.

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

## putData()

void casacore::TableRecordRep::putData | ( | AipsIO & | os,
|  | const TableAttr & | ) const

Put the data of a record.

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

Referenced by casacore::TableRecord::putData().

## putRecord()

void casacore::TableRecordRep::putRecord | ( | AipsIO & | os,
|  | Int | recordType,
|  | const TableAttr & | ) const

Put the description and data of the Record.

It also puts the fixedFlag attribute (of the mother object).

References casacore::recordType().

## removeData()

virtual void casacore::TableRecordRep::removeData | ( | Int | whichField,
|  | void * | ptr,
|  | void * | vecptr )

protected virtual

Remove a data field.

Reimplemented from casacore::RecordRep.

## removeFieldFromDesc()

virtual void casacore::TableRecordRep::removeFieldFromDesc | ( | Int | whichField | ) |

protected virtual

Remove a field from the description.

Reimplemented from casacore::RecordRep.

## renameField()

void casacore::TableRecordRep::renameField | ( | const String & | newName,
|  | Int | whichField )

inline

Rename the given field.

Definition at line 280 of file TableRecordRep.h.

References desc_p.

## renameTables()

void casacore::TableRecordRep::renameTables | ( | const String & | newParentName,
|  | const String & | oldParentName )

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

Referenced by casacore::TableRecord::renameTables().

## reopenRW()

void casacore::TableRecordRep::reopenRW | ( |  | ) |

Reopen possible tables in keywords as read/write.

Tables are not reopened if they are not writable.

Referenced by casacore::TableRecord::reopenRW().

## restructure()

void casacore::TableRecordRep::restructure | ( | const RecordDesc & | newDescription,
|  | Bool | recursive )

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

After calling restructure, description() == newDescription.

## setComment()

void casacore::TableRecordRep::setComment | ( | Int | whichField,
|  | const String & | comment )

inline

Set the comment for this field.

Definition at line 270 of file TableRecordRep.h.

References comment(), and desc_p.

## Member Data Documentation

## desc_p

RecordDesc casacore::TableRecordRep::desc_p

protected

Holds the description.

Definition at line 261 of file TableRecordRep.h.

Referenced by comment(), description(), renameField(), and setComment().

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

- tables/Tables/TableRecordRep.h