TableRecordRep.h
Classes
- TableRecordRep -- The representation of a TableRecord (full description)
Interface
- Public Members
- TableRecordRep()
- TableRecordRep (const RecordDesc& description)
- TableRecordRep (const TableRecordRep& other)
- TableRecordRep& operator= (const TableRecordRep& other)
- ~TableRecordRep()
- const String& comment (Int whichField) const
- void setComment (Int whichField, const String& comment)
- const RecordDesc& description() const
- void restructure (const RecordDesc& newDescription, Bool recursive)
- Bool conform (const TableRecordRep& other) const
- void renameField (const String& newName, Int whichField)
- void copyData (const TableRecordRep& other)
- void addField (const String& name, const TableRecord& value, RecordInterface::RecordType type)
- void addField (const String& name, const Table& value, RecordInterface::RecordType type)
- void defineDataField (Int whichField, DataType type, const void* value)
- void closeTable (Int whichField) const
- void renameTables (const String& newParentName, const String& oldParentName)
- Bool areTablesMultiUsed() const
- void putRecord (AipsIO& os, int recordType, const TableAttr&) const
- void getRecord (AipsIO& os, int& recordType, const TableAttr&)
- void putData (AipsIO& os, const TableAttr&) const
- void getData (AipsIO& os, uInt version, const TableAttr&)
- void reopenRW()
- void* get_pointer (Int whichField, DataType type) const
- void* get_pointer (Int whichField, DataType type, const String& recordType) const
- void mergeField (const TableRecordRep& other, Int whichFieldFromOther, RecordInterface::DuplicatesFlag)
- void merge (const TableRecordRep& other, RecordInterface::DuplicatesFlag)
- Protected Members
- void copy_other (const TableRecordRep& other)
- virtual Int fieldNumber (const String& name) const
- virtual void addFieldToDesc (const String& name, DataType type, const IPosition& shape, Bool fixedShape)
- virtual void removeData (Int whichField, void* ptr, void* vecptr)
- virtual void removeFieldFromDesc (Int whichField)
- void getTableKeySet (AipsIO& os, uInt version, const TableAttr&, uInt type)
Review Status
- Reviewed By:
- Mark Wieringa
- Date Reviewed:
- 1996/04/15
- Programs:
- Tests:
Prerequisite
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.
Member Description
Create a record with no fields.
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).
TableRecordRep (const TableRecordRep& other)
Create a copy of other using copy semantics.
TableRecordRep& operator= (const TableRecordRep& other)
Copy all the data over.
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.
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. After calling restructure, description() ==
newDescription.
Bool 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).
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.
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)
void addField (const String& name, const Table& 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 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.
void 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 renameTables (const String& newParentName, const String& oldParentName)
Rename the subtables with a path containing the old parent table name.
Are subtables used in other processes.
Put the description and data of the Record.
It also puts the fixedFlag attribute (of the mother object).
Get the description and data of the Record.
It also gets the fixedFlag attribute (of the mother object).
Put the data of a record.
This is used to write a subrecord, whose description has
already been written.
Read the data of a record.
This is used to read a subrecord, whose description has
already been read.
Reopen possible tables in keywords as read/write.
Tables are not reopened if they are not writable.
void* get_pointer (Int whichField, DataType type) const
void* get_pointer (Int whichField, DataType type, const String& recordType) const
Used by the RecordFieldPtr classes to attach in a type-safe way to the
correct field.
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 copy_other (const TableRecordRep& other)
Utility function to avoid code duplication in the public member
functions.
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.
Remove a field from the description.
Get a KeywordSet object as a TableRecord.
(type: 0=ScalarKeywordSet, 1=ArrayKeywordSet, 2=TableKeywordSet)