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

More...

`#include <RecordDescRep.h>`

## Public Member Functions

| RecordDescRep ()
| Create a description with no fields.
| RecordDescRep (const RecordDescRep &other)
| Create a description which is a copy of other.
RecordDescRep & | operator= (const RecordDescRep &other)
| Replace this description with other.
virtual | ~RecordDescRep ()
uInt | addField (const String &fieldName, DataType scalarOrArrayType)
| Add scalar or array field.
uInt | addArray (const String &fieldName, DataType scalarOrArrayType, const IPosition &shape)
| Add an array field of the indicated type.
uInt | addRecord (const String &fieldName, const RecordDesc &subDesc)
| Add a Record field to the description.
uInt | addTable (const String &fieldName, const String &tableDescName)
| Add a Table field to the description.
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.
void | setShape (Int whichField, const IPosition &shape)
| Set the shape for this field.
uInt | mergeField (const RecordDescRep &other, Int whichFieldFromOther, int duplicateAction)
| Merge a single field from other.
uInt | merge (const RecordDescRep &other, int duplicateAction)
| Add all the fields from another RecordDescRep to the current objects.
virtual uInt | removeField (Int whichField)
| Remove the given field from the description.
virtual void | renameField (const String &newName, Int whichField)
| Rename the given field.
Int | fieldNumber (const String &fieldName) const
| Returns the index of the field named fieldName.
uInt | nfields () const
| Number of fields in the description.
DataType | type (Int whichField) const
| What is the type of the given field.
const String & | name (Int whichField) const
| What is the name of the given field.
String | makeName (Int whichField) const
| Create a name for a field defined by index as *i (similar to glish).
String | uniqueName (const String &name) const
| Make the given name unique by adding a suffix _j when needed.
Bool | isArray (Int whichField) const
| Returns True if whichField is an array.
Bool | isScalar (Int whichField) const
| Returns True if whichField is a scalar.
Bool | isSubRecord (Int whichField) const
| Returns True if whichField is a sub-record.
Bool | isTable (Int whichField) const
| Returns True if whichField is a table.
const IPosition & | shape (Int whichField) const
| What is the shape of the given field.
const String & | tableDescName (Int whichField) const
| What is the name of the table description associated with a table.
const RecordDesc & | subRecord (Int whichField) const
| If whichField is a sub-record with a description, return its description.
RecordDesc & | subRecord (Int whichField)
Bool | operator== (const RecordDescRep &other) const
| This and other compare equal if the field types and shapes are identical (recursively if there are described sub-records or tables).
Bool | operator!= (const RecordDescRep &other) const
Bool | conform (const RecordDescRep &other) const
| Test if this description conforms the other.
Bool | isEqual (const RecordDescRep &other, Bool &equalDataTypes) const
| Test if this description equals another one.
Bool | isSubset (const RecordDescRep &other, Bool &equalDataTypes) const
| Test if this description is a subset of another one.
Bool | isStrictSubset (const RecordDescRep &other, Bool &equalDataTypes) const
| Test if this description is a strict subset of another one, thus if it is a subset and not equal.
Bool | isDisjoint (const RecordDescRep &other) const
| Test if the set of field names in this and other record description is disjoint (i.e.

## Protected Member Functions

void | addFieldName (const String &fieldName, DataType type)
| Add a field name and its type.
virtual void | addRepField (const RecordDescRep &other, const String &newName, Int whichField)
| Add a field from another Record description.
void | addFieldAny (DataType scalarOrArrayType)
| Add the field info.
void | addFieldArray (DataType scalarOrArrayType, const IPosition &shape)
void | setShape (const IPosition &shape, Int whichField)
| Set the shape (for a derived class).
virtual void | increment_length ()
| Helper functions.
void | copy_other (const RecordDescRep &other)

## Private Member Functions

Bool | allExist (const RecordDescRep &, Bool &equalDataTypes) const
| Test if all fields are part of the other description.

## Private Attributes

uInt | n_p
| Number of fields in the description.
Block< Int > | types_p
| The DataType of each field.
Block< String > | names_p
| The name of each field.
PtrBlock< RecordDesc * > | sub_records_p
| The description of the subrecords.
Block< IPosition > | shapes_p
| The shape of the field [1] for scalars and sub-records.
Block< Bool > | is_array_p
| True if the corresponding field is an array.
Block< String > | tableDescNames_p
| Table description name for table fields.
Block< String > | comments_p
| Comments for each field.
std::map< String, Int > | name_map_p
| Mapping of field name to field number.

## Detailed Description

Representation of a RecordDesc

### Intended use:

Internal

### Review Status

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

### Prerequisite

- DataType
- RecordDesc

### Etymology

Rep is an often used abbreviation for representation. Thus RecordDescRep is the representation of a RecordDesc.

### Synopsis

RecordDescRep is used by RecordDesc to implement its copy-on-write semantics. RecordDesc is the interface to the user, while RecordDescRep contains the actual implementation. See RecordDesc for a more detailed description of a record description.

### Example

See the example in the description of the Record class.

### Motivation

RecordDescRep is needed to make copy-on-write semantics possible in class RecordDesc.

### To Do

- Should the strategy wrt. field names be changed (not used in field description equality, must be unique at a given level?).
- Perhaps we should be able to more conveniently change the description of an existing field.

Definition at line 88 of file RecordDescRep.h.

## Constructor & Destructor Documentation

## RecordDescRep() [1/2]

casacore::RecordDescRep::RecordDescRep | ( |  | ) |

Create a description with no fields.

Referenced by addRepField(), allExist(), conform(), copy_other(), isDisjoint(), isEqual(), isStrictSubset(), isSubset(), merge(), mergeField(), operator!=(), operator=(), operator==(), RecordDescRep(), and subRecord().

## RecordDescRep() [2/2]

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

Create a description which is a copy of other.

References RecordDescRep().

## ~RecordDescRep()

virtual casacore::RecordDescRep::~RecordDescRep | ( |  | ) |

virtual

## Member Function Documentation

## addArray()

uInt casacore::RecordDescRep::addArray | ( | const String & | fieldName,
|  | DataType | scalarOrArrayType,
|  | const IPosition & | shape )

Add an array field of the indicated type.

The DataType is promoted from a scalar type to an array type if necessary, e.g., TpInt ->TpArrayInt. Returns the number of fields in the description.

References shape().

## addField()

uInt casacore::RecordDescRep::addField | ( | const String & | fieldName,
|  | DataType | scalarOrArrayType )

Add scalar or array field.

If of array type, the shape is set to [-1], which indicates a variable sized array. Returns the number of fields in the description.

## addFieldAny()

void casacore::RecordDescRep::addFieldAny | ( | DataType | scalarOrArrayType | ) |

protected

Add the field info.

These are helper functions for the add functions and can be used in derived classes too.

## addFieldArray()

void casacore::RecordDescRep::addFieldArray | ( | DataType | scalarOrArrayType,
|  | const IPosition & | shape )

protected

References shape().

## addFieldName()

void casacore::RecordDescRep::addFieldName | ( | const String & | fieldName,
|  | DataType | type )

protected

Add a field name and its type.

It checks if the name is unique and it extends the various blocks using increment_length.

References type().

## addRecord()

uInt casacore::RecordDescRep::addRecord | ( | const String & | fieldName,
|  | const RecordDesc & | subDesc )

Add a Record field to the description.

This allows hierarchical descriptions to be developed. Returns the number of fields in the description.

## addRepField()

virtual void casacore::RecordDescRep::addRepField | ( | const RecordDescRep & | other,
|  | const String & | newName,
|  | Int | whichField )

protected virtual

Add a field from another Record description.

This is used by the merge functions.

References RecordDescRep().

## addTable()

uInt casacore::RecordDescRep::addTable | ( | const String & | fieldName,
|  | const String & | tableDescName )

Add a Table field to the description.

The Table description has the given name. Returns the number of fields in the description.

References tableDescName().

## allExist()

Bool casacore::RecordDescRep::allExist | ( | const RecordDescRep & | ,
|  | Bool & | equalDataTypes ) const

private

Test if all fields are part of the other description.

The flag equalDataTypes is set to True if the data types of the fields in both descriptions are the same.

References RecordDescRep().

## comment()

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

Get the comment for this field.

Referenced by setComment().

## conform()

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

Test if this description conforms the other.

It is similar to operator==. However, a subrecord in that description always conforms an arbitrary (i.e. empty) subrecord in this description.
This is used by Record, to see if another record can be assigned to this record.

References RecordDescRep().

## copy_other()

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

protected

References RecordDescRep().

## fieldNumber()

Int casacore::RecordDescRep::fieldNumber | ( | const String & | fieldName | ) | const

Returns the index of the field named fieldName.

Returns -1 if fieldName does not exist.

## increment_length()

virtual void casacore::RecordDescRep::increment_length | ( |  | ) |

protected virtual

Helper functions.

## isArray()

Bool casacore::RecordDescRep::isArray | ( | Int | whichField | ) | const

inline

Returns True if whichField is an array.

Definition at line 314 of file RecordDescRep.h.

References is_array_p.

## isDisjoint()

Bool casacore::RecordDescRep::isDisjoint | ( | const RecordDescRep & | other | ) | const

Test if the set of field names in this and other record description is disjoint (i.e.

if they do not share names).

References RecordDescRep().

## isEqual()

Bool casacore::RecordDescRep::isEqual | ( | const RecordDescRep & | other,
|  | Bool & | equalDataTypes ) const

Test if this description equals another one.

It is equal if the number of fields is equal and all field names in this description occur in the other too. The order of the fields is not important.
The flag equalDataTypes is set to True if the data types of all fields match.
Use function operator== if order and types are important, but names are not.

References RecordDescRep().

## isScalar()

Bool casacore::RecordDescRep::isScalar | ( | Int | whichField | ) | const

inline

Returns True if whichField is a scalar.

Definition at line 319 of file RecordDescRep.h.

References types_p.

## isStrictSubset()

Bool casacore::RecordDescRep::isStrictSubset | ( | const RecordDescRep & | other,
|  | Bool & | equalDataTypes ) const

Test if this description is a strict subset of another one, thus if it is a subset and not equal.

References RecordDescRep().

## isSubRecord()

Bool casacore::RecordDescRep::isSubRecord | ( | Int | whichField | ) | const

inline

Returns True if whichField is a sub-record.

Definition at line 324 of file RecordDescRep.h.

References types_p.

## isSubset()

Bool casacore::RecordDescRep::isSubset | ( | const RecordDescRep & | other,
|  | Bool & | equalDataTypes ) const

Test if this description is a subset of another one.

It is similar to isEqual above.

References RecordDescRep().

## isTable()

Bool casacore::RecordDescRep::isTable | ( | Int | whichField | ) | const

inline

Returns True if whichField is a table.

Definition at line 329 of file RecordDescRep.h.

References types_p.

## makeName()

String casacore::RecordDescRep::makeName | ( | Int | whichField | ) | const

Create a name for a field defined by index as *i (similar to glish).

It takes care that the resulting name is unique by adding a suffix _j when needed.

## merge()

uInt casacore::RecordDescRep::merge | ( | const RecordDescRep & | other,
|  | int | duplicateAction )

Add all the fields from another RecordDescRep to the current objects.

References RecordDescRep().

## mergeField()

uInt casacore::RecordDescRep::mergeField | ( | const RecordDescRep & | other,
|  | Int | whichFieldFromOther,
|  | int | duplicateAction )

Merge a single field from other.

If allowDuplicates is True, silently throw away fields if one with the same name and type already exists, otherwise an exception is thrown. Conflicting types always cause an exception. Returns the number of fields in the description.

References RecordDescRep().

## name()

const String & casacore::RecordDescRep::name | ( | Int | whichField | ) | const

inline

What is the name of the given field.

Definition at line 304 of file RecordDescRep.h.

References names_p.

Referenced by uniqueName().

## nfields()

uInt casacore::RecordDescRep::nfields | ( |  | ) | const

inline

Number of fields in the description.

Definition at line 294 of file RecordDescRep.h.

References n_p.

## operator!=()

Bool casacore::RecordDescRep::operator!= | ( | const RecordDescRep & | other | ) | const

References RecordDescRep().

## operator=()

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

Replace this description with other.

References RecordDescRep().

## operator==()

Bool casacore::RecordDescRep::operator== | ( | const RecordDescRep & | other | ) | const

This and other compare equal if the field types and shapes are identical (recursively if there are described sub-records or tables).

The field names are not used.

References RecordDescRep().

## removeField()

virtual uInt casacore::RecordDescRep::removeField | ( | Int | whichField | ) |

virtual

Remove the given field from the description.

## renameField()

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

virtual

Rename the given field.

## setComment()

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

Set the comment for this field.

References comment().

## setShape() [1/2]

void casacore::RecordDescRep::setShape | ( | const IPosition & | shape,
|  | Int | whichField )

protected

Set the shape (for a derived class).

References shape().

## setShape() [2/2]

void casacore::RecordDescRep::setShape | ( | Int | whichField,
|  | const IPosition & | shape )

Set the shape for this field.

An exception will be thrown if the field is no array.

References shape().

## shape()

const IPosition & casacore::RecordDescRep::shape | ( | Int | whichField | ) | const

inline

What is the shape of the given field.

Returns [1] if the field is a scalar, table or, sub-record, [-1] if it is a variable length array, and the actual shape for a fixed length array.

Definition at line 309 of file RecordDescRep.h.

References shapes_p.

Referenced by addArray(), addFieldArray(), setShape(), and setShape().

## subRecord() [1/2]

RecordDesc & casacore::RecordDescRep::subRecord | ( | Int | whichField | ) |

## subRecord() [2/2]

const RecordDesc & casacore::RecordDescRep::subRecord | ( | Int | whichField | ) | const

inline

If whichField is a sub-record with a description, return its description.

Otherwise an exception is thrown.

Definition at line 334 of file RecordDescRep.h.

References RecordDescRep(), and casacore::RecordDesc::subRecord().

## tableDescName()

const String & casacore::RecordDescRep::tableDescName | ( | Int | whichField | ) | const

inline

What is the name of the table description associated with a table.

Definition at line 340 of file RecordDescRep.h.

References tableDescNames_p.

Referenced by addTable().

## type()

DataType casacore::RecordDescRep::type | ( | Int | whichField | ) | const

inline

What is the type of the given field.

Returns TpRecord if the field is a sub-Record.

Definition at line 299 of file RecordDescRep.h.

References types_p.

Referenced by addFieldName().

## uniqueName()

String casacore::RecordDescRep::uniqueName | ( | const String & | name | ) | const

Make the given name unique by adding a suffix _j when needed.

j is the minimal number needed to make it unique.

References name().

## Member Data Documentation

## comments_p

Block<String> casacore::RecordDescRep::comments_p

private

Comments for each field.

Definition at line 289 of file RecordDescRep.h.

## is_array_p

Block<Bool> casacore::RecordDescRep::is_array_p

private

True if the corresponding field is an array.

Definition at line 285 of file RecordDescRep.h.

Referenced by isArray().

## n_p

uInt casacore::RecordDescRep::n_p

private

Number of fields in the description.

Definition at line 272 of file RecordDescRep.h.

Referenced by nfields().

## name_map_p

std::map<String,Int> casacore::RecordDescRep::name_map_p

private

Mapping of field name to field number.

Definition at line 291 of file RecordDescRep.h.

## names_p

Block<String> casacore::RecordDescRep::names_p

private

The name of each field.

Definition at line 276 of file RecordDescRep.h.

Referenced by name().

## shapes_p

Block<IPosition> casacore::RecordDescRep::shapes_p

private

The shape of the field [1] for scalars and sub-records.

Definition at line 283 of file RecordDescRep.h.

Referenced by shape().

## sub_records_p

PtrBlock<RecordDesc*> casacore::RecordDescRep::sub_records_p

private

The description of the subrecords.

Null if the field is not a subrecord. This isn't the most efficient representation. If this is ever an issue we could calculate these, or store them in one Block, or implement copy-on-write semantics.

Definition at line 281 of file RecordDescRep.h.

## tableDescNames_p

Block<String> casacore::RecordDescRep::tableDescNames_p

private

Table description name for table fields.

Definition at line 287 of file RecordDescRep.h.

Referenced by tableDescName().

## types_p

Block<Int> casacore::RecordDescRep::types_p

private

The DataType of each field.

Definition at line 274 of file RecordDescRep.h.

Referenced by isScalar(), isSubRecord(), isTable(), and type().

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

- casa/Containers/RecordDescRep.h