casacore
|
#include <TableRecordRep.h>
Public Member Functions | |
TableRecordRep () | |
Create a record with no fields. More... | |
TableRecordRep (const RecordDesc &description) | |
Create a record with the given description. More... | |
TableRecordRep (const TableRecordRep &other) | |
Create a copy of other using copy semantics. More... | |
TableRecordRep & | operator= (const TableRecordRep &other) |
Copy all the data over. More... | |
~TableRecordRep () | |
Delete all data. More... | |
const String & | comment (Int whichField) const |
Get the comment for this field. More... | |
void | setComment (Int whichField, const String &comment) |
Set the comment for this field. More... | |
const RecordDesc & | description () const |
Describes the current structure of this Record. More... | |
void | restructure (const RecordDesc &newDescription, Bool recursive) |
Change the structure of this Record to contain the fields in newDescription. More... | |
Bool | conform (const TableRecordRep &other) const |
Returns True if this and other have the same RecordDesc, other than different names for the fields. More... | |
void | renameField (const String &newName, Int whichField) |
Rename the given field. More... | |
void | copyData (const TableRecordRep &other) |
Copy all data of the TableRecord. More... | |
void | addField (const String &name, const TableRecord &value, RecordInterface::RecordType type) |
Add a field with the given name and value to the record. More... | |
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. More... | |
void | closeTable (Int whichField) const |
Close the table in the given field. More... | |
void | closeTables () const |
Close all open tables. More... | |
void | flushTables (Bool fsync) 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, Int recordType, const TableAttr &) const |
Put the description and data of the Record. More... | |
void | getRecord (AipsIO &os, Int &recordType, const TableAttr &) |
Get the description and data of the 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... | |
void | reopenRW () |
Reopen possible tables in keywords as read/write. More... | |
void * | get_pointer (Int whichField, DataType type) const |
Used by the RecordFieldPtr classes to attach in a type-safe way to the correct field. More... | |
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. More... | |
void | merge (const TableRecordRep &other, RecordInterface::DuplicatesFlag) |
Merge all fields from the other record into this record. More... | |
void | print (std::ostream &, Int maxNrValues=25, const String &indent="") const |
Print a record. More... | |
Public Member Functions inherited from casacore::RecordRep | |
RecordRep () | |
Create a record with no fields. More... | |
RecordRep (const RecordDesc &description) | |
Create a record with the given description. More... | |
RecordRep (const RecordRep &other) | |
Create a copy of other using copy semantics. More... | |
RecordRep & | operator= (const RecordRep &other) |
Copy all the data over. More... | |
virtual | ~RecordRep () |
Delete all data. More... | |
const String & | comment (Int whichField) const |
Get the comment for this field. More... | |
void | setComment (Int whichField, const String &comment) |
Set the comment for this field. More... | |
const RecordDesc & | description () const |
Describes the current structure of this Record. More... | |
void | restructure (const RecordDesc &newDescription, Bool recursive) |
Change the structure of this Record to contain the fields in newDescription. More... | |
Bool | conform (const RecordRep &other) const |
Returns True if this and other have the same RecordDesc, other than different names for the fields. More... | |
void | copyData (const RecordRep &other) |
Copy all data of the Record. More... | |
void | copyDataField (DataType type, Int whichField, const void *that) const |
Copy a data field. More... | |
void | removeField (Int whichField) |
Remove a field from the record. More... | |
void | renameField (const String &newName, Int whichField) |
Rename the given field. More... | |
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. More... | |
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. More... | |
void | putRecord (AipsIO &os, int recordType) const |
Put the description and data of the Record. More... | |
void | getRecord (AipsIO &os, Int &recordType) |
Get the description and data of the Record. More... | |
void | putData (AipsIO &os) const |
Put the data of a record. More... | |
void | getData (AipsIO &os, uInt version) |
Read the data of a record. More... | |
void * | get_pointer (Int whichField, DataType type) const |
Used by the RecordFieldPtr classes to attach in a type-safe way to the correct field. More... | |
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. More... | |
void | merge (const RecordRep &other, RecordInterface::DuplicatesFlag) |
Merge all fields from the other record into this record. More... | |
void | print (std::ostream &, Int maxNrValues=25, const String &indent="") const |
Print a record. More... | |
Protected Member Functions | |
void | copy_other (const TableRecordRep &other) |
Utility function to avoid code duplication in the public member functions. More... | |
virtual Int | fieldNumber (const String &name) const |
Get the field number for a given name. More... | |
virtual void | addFieldToDesc (const String &name, DataType type, const IPosition &shape, Bool fixedShape) |
Add a field to the description. More... | |
virtual void | removeData (Int whichField, void *ptr, void *vecptr) |
Remove a data field. More... | |
virtual void | removeFieldFromDesc (Int whichField) |
Remove a field from the description. More... | |
void | getTableKeySet (AipsIO &os, uInt version, const TableAttr &, uInt type) |
Get a KeywordSet object as a TableRecord. More... | |
Protected Member Functions inherited from casacore::RecordRep | |
void | delete_myself (uInt nfields) |
Utility functions to avoid code duplication in the public member functions. More... | |
void | copy_other (const RecordRep &other) |
void | addDataPtr (void *ptr) |
Add the data pointer to the data block. More... | |
void | removeDataPtr (Int index) |
Remove a data pointer add the given index. More... | |
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. More... | |
void * | createDataField (DataType type, const IPosition &shape) |
Create a data field for the given type and shape. More... | |
void | deleteDataField (DataType type, void *ptr, void *vecptr) |
Delete a data field. More... | |
void | copyDataField (DataType type, void *ptr, const void *that) const |
Copy a data field. More... | |
void | printDataField (std::ostream &os, DataType type, const String &indent, Int maxNrValues, const void *ptr) const |
Print a data field. More... | |
void | putDataField (AipsIO &os, DataType type, const void *ptr) const |
Put a data field. More... | |
void | getDataField (AipsIO &os, DataType type, void *ptr) |
Get a data field. More... | |
void | makeDataVec (Int whichField, DataType type) |
Make an array for a scalar data field. More... | |
void | getKeySet (AipsIO &os, uInt version, uInt type) |
Get a Scalar/ArrayKeywordSet object as a Record. More... | |
void | getKeyDesc (AipsIO &os, RecordDesc &desc) |
Get the description of a keyword set as a RecordDesc. More... | |
void | getScalarKeys (AipsIO &os) |
Get the scalar values of a keyword set. More... | |
void | getArrayKeys (AipsIO &os) |
Get the array values of a keyword set. More... | |
Protected Attributes | |
RecordDesc | desc_p |
Holds the description. More... | |
Protected Attributes inherited from casacore::RecordRep | |
RecordDesc | desc_p |
Holds the structure of this Record. More... | |
Block< void * > | data_p |
Pointers to data values. More... | |
Block< void * > | datavec_p |
Pointers to a vector of a scalar (to access a scalar as an array). More... | |
uInt | nused_p |
#Entries used in data_p. More... | |
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.
casacore::TableRecordRep::TableRecordRep | ( | ) |
Create a record with no fields.
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).
casacore::TableRecordRep::TableRecordRep | ( | const TableRecordRep & | other | ) |
Create a copy of other using copy semantics.
casacore::TableRecordRep::~TableRecordRep | ( | ) |
Delete all data.
void casacore::TableRecordRep::addField | ( | const String & | name, |
const Table & | value, | ||
RecordInterface::RecordType | type | ||
) |
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.
|
protectedvirtual |
Add a field to the description.
Reimplemented from casacore::RecordRep.
Bool casacore::TableRecordRep::areTablesMultiUsed | ( | ) | const |
Are subtables used in other processes.
Referenced by casacore::TableRecord::areTablesMultiUsed().
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.
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().
Get the comment for this field.
Definition at line 268 of file TableRecordRep.h.
References casacore::RecordDesc::comment(), and desc_p.
Referenced by setComment().
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;
Referenced by casacore::TableRecord::conform().
|
protected |
Utility function to avoid code duplication in the public member functions.
void casacore::TableRecordRep::copyData | ( | const TableRecordRep & | other | ) |
Copy all data of the TableRecord.
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.
|
inline |
Describes the current structure of this Record.
Definition at line 278 of file TableRecordRep.h.
References desc_p.
Referenced by casacore::TableRecord::description().
Get the field number for a given name.
Reimplemented from casacore::RecordRep.
void casacore::TableRecordRep::flushTables | ( | Bool | fsync | ) | const |
Flush all open subtables.
Referenced by casacore::TableRecord::flushTables().
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.
void* casacore::TableRecordRep::get_pointer | ( | Int | whichField, |
DataType | type, | ||
const String & | recordType | ||
) | const |
Read the data of a record.
This is used to read a subrecord, whose description has already been read.
Referenced by casacore::TableRecord::getData().
Get the description and data of the Record.
It also gets the fixedFlag attribute (of the mother object).
|
protected |
Get a KeywordSet object as a TableRecord.
(type: 0=ScalarKeywordSet, 1=ArrayKeywordSet, 2=TableKeywordSet)
void casacore::TableRecordRep::merge | ( | const TableRecordRep & | other, |
RecordInterface::DuplicatesFlag | |||
) |
Merge all fields from the other record into this record.
void casacore::TableRecordRep::mergeField | ( | const TableRecordRep & | other, |
Int | whichFieldFromOther, | ||
RecordInterface::DuplicatesFlag | |||
) |
Merge a field from another record into this record.
TableRecordRep& casacore::TableRecordRep::operator= | ( | const TableRecordRep & | other | ) |
Copy all the data over.
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.
Put the data of a record.
This is used to write a subrecord, whose description has already been written.
Referenced by casacore::TableRecord::putData().
Put the description and data of the Record.
It also puts the fixedFlag attribute (of the mother object).
|
protectedvirtual |
Remove a data field.
Reimplemented from casacore::RecordRep.
|
protectedvirtual |
Remove a field from the description.
Reimplemented from casacore::RecordRep.
Rename the given field.
Definition at line 283 of file TableRecordRep.h.
References desc_p, and casacore::RecordDesc::renameField().
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().
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().
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
.
Set the comment for this field.
Definition at line 273 of file TableRecordRep.h.
References comment(), desc_p, and casacore::RecordDesc::setComment().
|
protected |
Holds the description.
Definition at line 264 of file TableRecordRep.h.
Referenced by comment(), description(), renameField(), and setComment().