Loading...
Searching...
No Matches
casacore::RecordRep Class Reference
casa package (libcasa_casa) » Containers_module » Containers_module_internal_classes

More...

`#include <RecordRep.h>`

## Public Member Functions

| 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 | delete_myself (uInt nfields)
| Utility functions to avoid code duplication in the public member functions.
void | copy_other (const RecordRep &other)
virtual Int | fieldNumber (const String &name) const
| Get the field number for a given name.
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.
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 * | 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 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 Record

### Intended use:

Internal

### Review Status

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

### Prerequisite

- Record.

### Etymology

RecordRep is the REPresentation of a Record.

### Synopsis

RecordRep is the actual implementation of a Record 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 RecordRep does not know anything about RecordFieldPtr objects pointing to its data. Only its mother class Record knows about them and handles all cases where the RecordFieldPtr's have to be notified.

### Example

RecordRep mirrors all functions in Record.

### Motivation

Having a separate RecordRep class makes copy-on-write possible. It also allows derivation of other RecordRep classes (like TableRecordRep), while their mother classes are not derived from each other.

### To Do

- An implementation where arrays are stored as T*'s would cut down on instantiations (the Arrayness would come back through the creation of the RecordFieldPtr<Array<T> >).

Definition at line 97 of file RecordRep.h.

## Constructor & Destructor Documentation

## RecordRep() [1/3]

casacore::RecordRep::RecordRep | ( |  | ) |

Create a record with no fields.

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

## RecordRep() [2/3]

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

## RecordRep() [3/3]

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

Create a copy of other using copy semantics.

References RecordRep().

## ~RecordRep()

virtual casacore::RecordRep::~RecordRep | ( |  | ) |

virtual

Delete all data.

References comment().

## Member Function Documentation

## addDataField()

void casacore::RecordRep::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.

The data type of the field is determined by the data type of the value. For arrays it is possible to define if the shape is fixed.

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

## addDataPtr()

void casacore::RecordRep::addDataPtr | ( | void * | ptr | ) |

protected

Add the data pointer to the data block.

The block is extended when needed.

## addField()

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

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

## addFieldToDesc()

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

protected virtual

Add a field to the description.

Reimplemented in casacore::TableRecordRep.

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

## checkShape()

void casacore::RecordRep::checkShape | ( | DataType | type,
|  | const IPosition & | shape,
|  | const void * | value,
|  | const String & | fieldName )

protected

Check if the shape of the data array matches the shape of a fixed-shaped array in the description.

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

## comment()

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

inline

Get the comment for this field.

Definition at line 310 of file RecordRep.h.

References desc_p.

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

## conform()

Bool casacore::RecordRep::conform | ( | const RecordRep & | 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 RecordRep().

## copy_other()

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

protected

References RecordRep().

## copyData()

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

Copy all data of the Record.

References RecordRep().

## copyDataField() [1/2]

void casacore::RecordRep::copyDataField | ( | DataType | type,
|  | Int | whichField,
|  | const void * | that ) const

Copy a data field.

This can only handle scalars and arrays.

## copyDataField() [2/2]

void casacore::RecordRep::copyDataField | ( | DataType | type,
|  | void * | ptr,
|  | const void * | that ) const

protected

Copy a data field.

This can only handle scalars and arrays.

## createDataField()

void * casacore::RecordRep::createDataField | ( | DataType | type,
|  | const IPosition & | shape )

protected

Create a data field for the given type and shape.

This can only handle scalars and arrays.

References casacore::shape().

## defineDataField()

void casacore::RecordRep::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.

## delete_myself()

void casacore::RecordRep::delete_myself | ( | uInt | nfields | ) |

protected

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

References casacore::nfields().

## deleteDataField()

void casacore::RecordRep::deleteDataField | ( | DataType | type,
|  | void * | ptr,
|  | void * | vecptr )

protected

Delete a data field.

This can only handle scalars and arrays.

## description()

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

inline

Describes the current structure of this Record.

Definition at line 305 of file RecordRep.h.

References desc_p.

Referenced by RecordRep().

## fieldNumber()

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

protected virtual

Get the field number for a given name.

Reimplemented in casacore::TableRecordRep.

References casacore::name().

## get_pointer() [1/2]

void * casacore::RecordRep::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::RecordRep::get_pointer | ( | Int | whichField,
|  | DataType | type,
|  | const String & | recordType ) const

References casacore::recordType().

## getArrayKeys()

void casacore::RecordRep::getArrayKeys | ( | AipsIO & | os | ) |

protected

Get the array values of a keyword set.

## getData()

void casacore::RecordRep::getData | ( | AipsIO & | os,
|  | uInt | version )

Read the data of a record.

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

## getDataField()

void casacore::RecordRep::getDataField | ( | AipsIO & | os,
|  | DataType | type,
|  | void * | ptr )

protected

Get a data field.

This can only handle scalars and arrays.

## getKeyDesc()

void casacore::RecordRep::getKeyDesc | ( | AipsIO & | os,
|  | RecordDesc & | desc )

protected

Get the description of a keyword set as a RecordDesc.

## getKeySet()

void casacore::RecordRep::getKeySet | ( | AipsIO & | os,
|  | uInt | version,
|  | uInt | type )

protected

Get a Scalar/ArrayKeywordSet object as a Record.

(type 0 = ScalarKeywordSet; type 1 = ArrayKeywordSet).

## getRecord()

void casacore::RecordRep::getRecord | ( | AipsIO & | os,
|  | Int & | recordType )

Get the description and data of the Record.

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

References casacore::recordType().

## getScalarKeys()

void casacore::RecordRep::getScalarKeys | ( | AipsIO & | os | ) |

protected

Get the scalar values of a keyword set.

## makeDataVec()

void casacore::RecordRep::makeDataVec | ( | Int | whichField,
|  | DataType | type )

protected

Make an array for a scalar data field.

It shares the data, so a change in the data is reflected in the array. It is used to be able to access a scalar as an 1D array.

## merge()

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

Merge all fields from the other record into this record.

References RecordRep().

## mergeField()

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

Merge a field from another record into this record.

References RecordRep().

## operator=()

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

Copy all the data over.

References RecordRep().

## print()

void casacore::RecordRep::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.

## printDataField()

void casacore::RecordRep::printDataField | ( | std::ostream & | os,
|  | DataType | type,
|  | const String & | indent,
|  | Int | maxNrValues,
|  | const void * | ptr ) const

protected

Print a data field.

This can only handle scalars and arrays.

## putData()

void casacore::RecordRep::putData | ( | AipsIO & | os | ) | const

Put the data of a record.

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

## putDataField()

void casacore::RecordRep::putDataField | ( | AipsIO & | os,
|  | DataType | type,
|  | const void * | ptr ) const

protected

Put a data field.

This can only handle scalars and arrays.

## putRecord()

void casacore::RecordRep::putRecord | ( | AipsIO & | os,
|  | int | recordType ) 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::RecordRep::removeData | ( | Int | whichField,
|  | void * | ptr,
|  | void * | vecptr )

protected virtual

Remove a data field.

Reimplemented in casacore::TableRecordRep.

## removeDataPtr()

void casacore::RecordRep::removeDataPtr | ( | Int | index | ) |

protected

Remove a data pointer add the given index.

## removeField()

void casacore::RecordRep::removeField | ( | Int | whichField | ) |

Remove a field from the record.

## removeFieldFromDesc()

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

protected virtual

Remove a field from the description.

Reimplemented in casacore::TableRecordRep.

## renameField()

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

inline

Rename the given field.

Definition at line 320 of file RecordRep.h.

References desc_p.

## restructure()

void casacore::RecordRep::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::RecordRep::setComment | ( | Int | whichField,
|  | const String & | comment )

inline

Set the comment for this field.

Definition at line 315 of file RecordRep.h.

References comment(), and desc_p.

## Member Data Documentation

## data_p

Block<void*> casacore::RecordRep::data_p

protected

Pointers to data values.

Definition at line 297 of file RecordRep.h.

## datavec_p

Block<void*> casacore::RecordRep::datavec_p

protected

Pointers to a vector of a scalar (to access a scalar as an array).

Definition at line 299 of file RecordRep.h.

## desc_p

RecordDesc casacore::RecordRep::desc_p

protected

Holds the structure of this Record.

Definition at line 295 of file RecordRep.h.

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

## nused_p

uInt casacore::RecordRep::nused_p

protected

#Entries used in data_p.

Definition at line 301 of file RecordRep.h.

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

- casa/Containers/RecordRep.h