casa
$Rev:20696$
|
The representation of a TableRecord. 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. | |
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 Attributes | |
RecordDesc | desc_p |
Holds the description. |
The representation of a TableRecord.
Internal
TableRecordRep is the REPresentation of a TableRecord.
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.
TableRecordRep mirrors all functions in TableRecord.
Having a separate TableRecordRep class makes copy-on-write possible. It also allows derivation from RecordRep.
Definition at line 98 of file TableRecordRep.h.
Create a record with no fields.
casa::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).
casa::TableRecordRep::TableRecordRep | ( | const TableRecordRep & | other | ) |
Create a copy of other using copy semantics.
Delete all data.
void casa::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.
void casa::TableRecordRep::addField | ( | const String & | name, |
const Table & | value, | ||
RecordInterface::RecordType | type | ||
) |
virtual void casa::TableRecordRep::addFieldToDesc | ( | const String & | name, |
DataType | type, | ||
const IPosition & | shape, | ||
Bool | fixedShape | ||
) | [protected, virtual] |
Add a field to the description.
Reimplemented from casa::RecordRep.
Bool casa::TableRecordRep::areTablesMultiUsed | ( | ) | const |
Are subtables used in other processes.
Referenced by casa::TableRecord::areTablesMultiUsed().
void casa::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.
void casa::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 casa::TableRecord::closeTables().
const String & casa::TableRecordRep::comment | ( | Int | whichField | ) | const [inline] |
Get the comment for this field.
Reimplemented from casa::RecordRep.
Definition at line 268 of file TableRecordRep.h.
References casa::RecordDesc::comment(), and desc_p.
Bool casa::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;
Referenced by casa::TableRecord::conform().
void casa::TableRecordRep::copy_other | ( | const TableRecordRep & | other | ) | [protected] |
Utility function to avoid code duplication in the public member functions.
void casa::TableRecordRep::copyData | ( | const TableRecordRep & | other | ) |
Copy all data of the TableRecord.
void casa::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.
Reimplemented from casa::RecordRep.
const RecordDesc & casa::TableRecordRep::description | ( | ) | const [inline] |
Describes the current structure of this Record.
Reimplemented from casa::RecordRep.
Definition at line 278 of file TableRecordRep.h.
References desc_p.
Referenced by casa::TableRecord::description().
virtual Int casa::TableRecordRep::fieldNumber | ( | const String & | name | ) | const [protected, virtual] |
Get the field number for a given name.
Reimplemented from casa::RecordRep.
void casa::TableRecordRep::flushTables | ( | Bool | fsync | ) | const |
Flush all open subtables.
Referenced by casa::TableRecord::flushTables().
void* casa::TableRecordRep::get_pointer | ( | Int | whichField, |
DataType | type | ||
) | const |
Used by the RecordFieldPtr classes to attach in a type-safe way to the correct field.
Reimplemented from casa::RecordRep.
void* casa::TableRecordRep::get_pointer | ( | Int | whichField, |
DataType | type, | ||
const String & | recordType | ||
) | const |
Reimplemented from casa::RecordRep.
void casa::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 casa::TableRecord::getData().
void casa::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).
void casa::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)
void casa::TableRecordRep::merge | ( | const TableRecordRep & | other, |
RecordInterface::DuplicatesFlag | |||
) |
Merge all fields from the other record into this record.
void casa::TableRecordRep::mergeField | ( | const TableRecordRep & | other, |
Int | whichFieldFromOther, | ||
RecordInterface::DuplicatesFlag | |||
) |
Merge a field from another record into this record.
TableRecordRep& casa::TableRecordRep::operator= | ( | const TableRecordRep & | other | ) |
Copy all the data over.
void casa::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.
Reimplemented from casa::RecordRep.
void casa::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 casa::TableRecord::putData().
void casa::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).
virtual void casa::TableRecordRep::removeData | ( | Int | whichField, |
void * | ptr, | ||
void * | vecptr | ||
) | [protected, virtual] |
Remove a data field.
Reimplemented from casa::RecordRep.
virtual void casa::TableRecordRep::removeFieldFromDesc | ( | Int | whichField | ) | [protected, virtual] |
Remove a field from the description.
Reimplemented from casa::RecordRep.
void casa::TableRecordRep::renameField | ( | const String & | newName, |
Int | whichField | ||
) | [inline] |
Rename the given field.
Reimplemented from casa::RecordRep.
Definition at line 283 of file TableRecordRep.h.
References desc_p, and casa::RecordDesc::renameField().
void casa::TableRecordRep::renameTables | ( | const String & | newParentName, |
const String & | oldParentName | ||
) |
Rename the subtables with a path containing the old parent table name.
Referenced by casa::TableRecord::renameTables().
void casa::TableRecordRep::reopenRW | ( | ) |
Reopen possible tables in keywords as read/write.
Tables are not reopened if they are not writable.
Referenced by casa::TableRecord::reopenRW().
void casa::TableRecordRep::restructure | ( | const RecordDesc & | newDescription, |
Bool | recursive | ||
) |
Change the structure of this Record to contain the fields in newDescription.
After calling restructure, description() == newDescription
.
Reimplemented from casa::RecordRep.
void casa::TableRecordRep::setComment | ( | Int | whichField, |
const String & | comment | ||
) | [inline] |
Set the comment for this field.
Reimplemented from casa::RecordRep.
Definition at line 273 of file TableRecordRep.h.
References desc_p, and casa::RecordDesc::setComment().
RecordDesc casa::TableRecordRep::desc_p [protected] |
Holds the description.
Reimplemented from casa::RecordRep.
Definition at line 264 of file TableRecordRep.h.
Referenced by comment(), description(), renameField(), and setComment().