casacore
Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | Private Member Functions | Static Private Member Functions | Static Private Attributes | Friends | List of all members
casacore::ColumnDesc Class Reference

More...

#include <ColumnDesc.h>

Public Types

enum  Option {
  Direct ,
  Undefined ,
  FixedShape
}
 Enumerate the possible column options. More...
 
typedef BaseColumnDescColumnDescCtor(const String &className)
 Define the type of a XXColumnDesc construction function. More...
 

Public Member Functions

 ColumnDesc (const BaseColumnDesc &)
 Construct from a column description. More...
 
 ColumnDesc (const ColumnDesc &that)
 Copy constructor (copy semantics). More...
 
 ColumnDesc ()
 Default constructor (needed for ColumnDescSet). More...
 
 ~ColumnDesc ()
 
ColumnDescoperator= (const ColumnDesc &that)
 Assignment (copy semantics). More...
 
Bool operator== (const ColumnDesc &) const
 Comparison. More...
 
Bool operator!= (const ColumnDesc &) const
 
TableRecordrwKeywordSet ()
 Get access to the set of keywords. More...
 
const TableRecordkeywordSet () const
 
const Stringname () const
 Get the name of the column. More...
 
DataType dataType () const
 Get the data type of the column. More...
 
DataType trueDataType () const
 Get the true data type of the column. More...
 
const StringdataTypeId () const
 Get the type id for non-standard data types (i.e. More...
 
const StringdataManagerType () const
 Get the type name of the default data manager. More...
 
StringdataManagerType ()
 Get the type name of the default data manager (allowing it to be changed). More...
 
const StringdataManagerGroup () const
 Get the data manager group. More...
 
StringdataManagerGroup ()
 Get the data manager group. More...
 
void setDefaultDataManager (Bool always=True)
 If always==True they are always set, otherwise only if empty. More...
 
const Stringcomment () const
 Get comment string. More...
 
Stringcomment ()
 Get comment string (allowing it to be changed). More...
 
int options () const
 Get the options. More...
 
Bool isFixedShape () const
 Check if the column is defined with a fixed shape. More...
 
Bool isScalar () const
 Test if column is a scalar. More...
 
Bool isArray () const
 Test if column is an array. More...
 
Bool isTable () const
 Test if column is a table. More...
 
Int ndim () const
 Get the number of dimensions. More...
 
const IPositionshape () const
 Get the predefined shape. More...
 
void setNdim (uInt ndim)
 Set the number of dimensions. More...
 
void setShape (const IPosition &shape)
 Set the predefined shape. More...
 
void setShape (const IPosition &shape, Bool directOption)
 
void setOptions (int options)
 Set the options to the given value. More...
 
uInt maxLength () const
 Get the maximum value length. More...
 
void setMaxLength (uInt maxLength)
 Set the maximum value length. More...
 
const TableDesctableDesc () const
 Get table description (in case column contains subtables). More...
 
TableDesctableDesc ()
 
void show () const
 Show the column on cout. More...
 
void show (ostream &os) const
 Show the column. More...
 
void setName (const String &name)
 Set the name of the column. More...
 
RefColumnmakeRefColumn (RefTable *rtp, BaseColumn *bcp) const
 Create a RefColumn column object out of this column description. More...
 
ConcatColumnmakeConcatColumn (ConcatTable *rtp) const
 Create a ConcatColumn column object out of this column description. More...
 

Static Public Member Functions

static ColumnDescCtorgetCtor (const String &name)
 Get a construction function for a XXColumnDesc object (thread-safe). More...
 
static void registerCtor (const String &name, ColumnDescCtor *func)
 Register a "XXColumnDesc" constructor (thread-safe). More...
 

Protected Attributes

BaseColumnDesccolPtr_p
 
Bool allocated_p
 

Private Member Functions

 ColumnDesc (BaseColumnDesc *)
 Construct from a pointer (for class BaseColumn). More...
 
void checkAdd (const ColumnDescSet &cds) const
 Check if a column can be handled by ColumnDescSet. More...
 
void checkRename (const ColumnDescSet &cds, const String &newName) const
 Check when a column gets renamed in a table description. More...
 
void handleAdd (ColumnDescSet &cds)
 Take action after a column has been handled by ColumnDescSet. More...
 
void handleRename (ColumnDescSet &cds, const String &oldName)
 
void handleRemove (ColumnDescSet &cds)
 
void renameAction (const String &newName, const String &oldName)
 This function allows each column to act upon a rename of another column. More...
 
PlainColumnmakeColumn (ColumnSet *csp) const
 Create a PlainColumn column object out of this column description. More...
 
void putFile (AipsIO &ios, const TableAttr &) const
 Store the object in AipsIO. More...
 
void getFile (AipsIO &, const TableAttr &)
 Get the object from AipsIO. More...
 

Static Private Member Functions

static std::map< String, ColumnDescCtor * > & getRegisterMap ()
 Define a map which maps the name of the various XXColumnDesc classes to a static function constructing them. More...
 
static std::map< String, ColumnDescCtor * > initRegisterMap ()
 Register the main data managers. More...
 

Static Private Attributes

static std::mutex theirMutex
 A mutex for additions to the constructor map. More...
 

Friends

class ColumnDescSet
 
class ColumnSet
 
class BaseColumn
 
AipsIOoperator<< (AipsIO &ios, const ColumnDesc &cd)
 Write into AipsIO. More...
 
AipsIOoperator>> (AipsIO &ios, ColumnDesc &cd)
 Read from AipsIO. More...
 
ostream & operator<< (ostream &ios, const ColumnDesc &cd)
 Show on ostream. More...
 

Detailed Description

Envelope class for the description of a table column

Intended use:

Public interface

Review Status

Reviewed By:
Paul Shannon
Date Reviewed:
1994/08/11
Test programs:
none

Prerequisite

Synopsis

Class ColumnDesc is an envelope for the letter class BaseColDesc and its derivations like ScalarColumnDesc,

ScalarRecordColumnDesc. ArrayColumnDesc, and SubTableDesc. ColumnDesc is meant to examine or slightly modify already existing column descriptions. It allows the retrieval of attributes like name, data type, etc.. For non-const ColumnDesc objects it is possible to modify the attributes comment and keyword set.

Since there are several types of columns, the class ColumnDesc cannot handle all details of those column types. Therefore, to create a column description, an instance of the specialized classes ArrayColumnDesc<T>, etc. has to be constructed. In there column type dependent things like array shape and default value can be defined.

This class also enumerates the possible options which can be used when defining a column via classes like ScalarColumnDesc<T>. These options are:

FixedShape
This is only useful for columns containing arrays and tables. FixedShape means that the shape of the array or table must be the same in each cell of the column. If not given, the array or table shape may vary. Option Direct forces FixedShape.
Direct
This is only useful for columns containing arrays and tables. Direct means that the data is directly stored in the table. Direct forces option FixedShape. If not given, the array or table is indirect, which implies that the data will be stored in a separate file.
Undefined
Undefined is only useful for scalars. If not given, all possible values of the scalar have a meaning. If given, a value equal to the default value in the column description is an undefined value. The function TableColumn::isDefined will return False for such values.

Example

TableDesc tableDesc("theTableDesc", TableDesc::New);
// Add a float scalar column.
tableDesc.addColumn (ScalarColumnDesc<float> ("NAME");
// Get the description of a column and change the comments.
// In order to change the comments, a reference must be used
// (because the ColumnDesc copy constructor and assign have copy
// semantics).
ColumnDesc& myColDesc = tableDesc.columnDesc ("aName");
myColDesc.comment() += "some more comments";
ColumnDesc()
Default constructor (needed for ColumnDescSet).
Definition: ColumnDesc.h:162
const TableDesc * tableDesc() const
Get table description (in case column contains subtables).
Definition: ColumnDesc.h:317
const String & comment() const
Get comment string.
Definition: ColumnDesc.h:231
ColumnDesc & addColumn(const ColumnDesc &)
Add a column to the table description.
Definition: TableDesc.h:571
const ColumnDesc & columnDesc(const String &name) const
Get the column description by name or by index.
Definition: TableDesc.h:536

Motivation

When getting the description of an arbitrary column, a pointer to that description is needed to allow proper execution of virtual functions. An envelope class is needed to hide this from the user.

Definition at line 132 of file ColumnDesc.h.

Member Typedef Documentation

◆ ColumnDescCtor

typedef BaseColumnDesc* casacore::ColumnDesc::ColumnDescCtor(const String &className)

Define the type of a XXColumnDesc construction function.

Definition at line 352 of file ColumnDesc.h.

Member Enumeration Documentation

◆ Option

Enumerate the possible column options.

They can be combined by adding (logical or-ing) them.

Enumerator
Direct 

direct table or array

Undefined 

undefined values are possible

FixedShape 

fixed array/table shape

Definition at line 142 of file ColumnDesc.h.

Constructor & Destructor Documentation

◆ ColumnDesc() [1/4]

casacore::ColumnDesc::ColumnDesc ( const BaseColumnDesc )

Construct from a column description.

This constructor is merely for the purpose of the automatic conversion of an object like ScalarColumnDesc<T> to ColumnDesc when adding a column to the table description using the function TableDesc::addColumn.

◆ ColumnDesc() [2/4]

casacore::ColumnDesc::ColumnDesc ( const ColumnDesc that)

Copy constructor (copy semantics).

◆ ColumnDesc() [3/4]

casacore::ColumnDesc::ColumnDesc ( )
inline

Default constructor (needed for ColumnDescSet).

Definition at line 162 of file ColumnDesc.h.

◆ ~ColumnDesc()

casacore::ColumnDesc::~ColumnDesc ( )

◆ ColumnDesc() [4/4]

casacore::ColumnDesc::ColumnDesc ( BaseColumnDesc )
private

Construct from a pointer (for class BaseColumn).

Member Function Documentation

◆ checkAdd()

void casacore::ColumnDesc::checkAdd ( const ColumnDescSet cds) const
inlineprivate

Check if a column can be handled by ColumnDescSet.

It is called before the column gets actually added, etc..

Check if the column can be added to the table description. It is implemented for a virtual column to check if the columns it uses really exist.

Definition at line 386 of file ColumnDesc.h.

References casacore::BaseColumnDesc::checkAdd(), and colPtr_p.

◆ checkRename()

void casacore::ColumnDesc::checkRename ( const ColumnDescSet cds,
const String newName 
) const
inlineprivate

Check when a column gets renamed in a table description.

It is not used.

Definition at line 390 of file ColumnDesc.h.

References casacore::BaseColumnDesc::checkRename(), and colPtr_p.

◆ comment() [1/2]

String& casacore::ColumnDesc::comment ( )
inline

Get comment string (allowing it to be changed).

Definition at line 235 of file ColumnDesc.h.

References colPtr_p, and casacore::BaseColumnDesc::comment().

◆ comment() [2/2]

const String& casacore::ColumnDesc::comment ( ) const
inline

Get comment string.

Definition at line 231 of file ColumnDesc.h.

References colPtr_p, and casacore::BaseColumnDesc::comment().

◆ dataManagerGroup() [1/2]

String& casacore::ColumnDesc::dataManagerGroup ( )
inline

Get the data manager group.

(allowing it to be changed).

Definition at line 223 of file ColumnDesc.h.

References colPtr_p, and casacore::BaseColumnDesc::dataManagerGroup().

◆ dataManagerGroup() [2/2]

const String& casacore::ColumnDesc::dataManagerGroup ( ) const
inline

Get the data manager group.

Definition at line 218 of file ColumnDesc.h.

References colPtr_p, and casacore::BaseColumnDesc::dataManagerGroup().

◆ dataManagerType() [1/2]

String& casacore::ColumnDesc::dataManagerType ( )
inline

Get the type name of the default data manager (allowing it to be changed).

Definition at line 214 of file ColumnDesc.h.

References colPtr_p, and casacore::BaseColumnDesc::dataManagerType().

◆ dataManagerType() [2/2]

const String& casacore::ColumnDesc::dataManagerType ( ) const
inline

Get the type name of the default data manager.

Definition at line 209 of file ColumnDesc.h.

References colPtr_p, and casacore::BaseColumnDesc::dataManagerType().

◆ dataType()

DataType casacore::ColumnDesc::dataType ( ) const
inline

Get the data type of the column.

This always returns the type of a scalar, even when the column contains arrays.

Definition at line 195 of file ColumnDesc.h.

References colPtr_p, and casacore::BaseColumnDesc::dataType().

◆ dataTypeId()

const String& casacore::ColumnDesc::dataTypeId ( ) const
inline

Get the type id for non-standard data types (i.e.

for TpOther). For standard data types the returned string is empty.

Definition at line 205 of file ColumnDesc.h.

References colPtr_p, and casacore::BaseColumnDesc::dataTypeId().

◆ getCtor()

static ColumnDescCtor* casacore::ColumnDesc::getCtor ( const String name)
static

Get a construction function for a XXColumnDesc object (thread-safe).

◆ getFile()

void casacore::ColumnDesc::getFile ( AipsIO ,
const TableAttr  
)
private

Get the object from AipsIO.

◆ getRegisterMap()

static std::map<String, ColumnDescCtor*>& casacore::ColumnDesc::getRegisterMap ( )
staticprivate

Define a map which maps the name of the various XXColumnDesc classes to a static function constructing them.

This is used when reading a column description back; it in fact determines the exact column type and is an easier thing to do than an enormous switch statement. The map is filled with the main XXColumnDesc construction functions by the function registerColumnDesc upon the first call of ColumnDesc::getFile.

◆ handleAdd()

void casacore::ColumnDesc::handleAdd ( ColumnDescSet cds)
inlineprivate

Take action after a column has been handled by ColumnDescSet.

It is called after the column has been actually added, etc.. This gives, for instance, the virtual column class the opportunity to update the virtual column list.

Definition at line 399 of file ColumnDesc.h.

References colPtr_p, and casacore::BaseColumnDesc::handleAdd().

◆ handleRemove()

void casacore::ColumnDesc::handleRemove ( ColumnDescSet cds)
inlineprivate

Definition at line 403 of file ColumnDesc.h.

References colPtr_p, and casacore::BaseColumnDesc::handleRemove().

◆ handleRename()

void casacore::ColumnDesc::handleRename ( ColumnDescSet cds,
const String oldName 
)
inlineprivate

Definition at line 401 of file ColumnDesc.h.

References colPtr_p, and casacore::BaseColumnDesc::handleRename().

◆ initRegisterMap()

static std::map<String, ColumnDescCtor*> casacore::ColumnDesc::initRegisterMap ( )
staticprivate

Register the main data managers.

◆ isArray()

Bool casacore::ColumnDesc::isArray ( ) const
inline

Test if column is an array.

Definition at line 258 of file ColumnDesc.h.

References colPtr_p, and casacore::BaseColumnDesc::isArray().

◆ isFixedShape()

Bool casacore::ColumnDesc::isFixedShape ( ) const

Check if the column is defined with a fixed shape.

This is always true for scalars. For arrays it is true when the FixedShape flag was set when the column was defined.

◆ isScalar()

Bool casacore::ColumnDesc::isScalar ( ) const
inline

Test if column is a scalar.

Definition at line 255 of file ColumnDesc.h.

References colPtr_p, and casacore::BaseColumnDesc::isScalar().

◆ isTable()

Bool casacore::ColumnDesc::isTable ( ) const
inline

Test if column is a table.

Definition at line 261 of file ColumnDesc.h.

References colPtr_p, and casacore::BaseColumnDesc::isTable().

◆ keywordSet()

const TableRecord& casacore::ColumnDesc::keywordSet ( ) const
inline

Definition at line 184 of file ColumnDesc.h.

References colPtr_p, and casacore::BaseColumnDesc::keywordSet().

◆ makeColumn()

PlainColumn* casacore::ColumnDesc::makeColumn ( ColumnSet csp) const
inlineprivate

Create a PlainColumn column object out of this column description.

Definition at line 414 of file ColumnDesc.h.

References colPtr_p, and casacore::BaseColumnDesc::makeColumn().

◆ makeConcatColumn()

ConcatColumn* casacore::ColumnDesc::makeConcatColumn ( ConcatTable rtp) const
inline

Create a ConcatColumn column object out of this column description.

Definition at line 347 of file ColumnDesc.h.

References colPtr_p, and casacore::BaseColumnDesc::makeConcatColumn().

◆ makeRefColumn()

RefColumn* casacore::ColumnDesc::makeRefColumn ( RefTable rtp,
BaseColumn bcp 
) const
inline

Create a RefColumn column object out of this column description.

Definition at line 343 of file ColumnDesc.h.

References colPtr_p, and casacore::BaseColumnDesc::makeRefColumn().

◆ maxLength()

uInt casacore::ColumnDesc::maxLength ( ) const
inline

Get the maximum value length.

Definition at line 304 of file ColumnDesc.h.

References colPtr_p, and casacore::BaseColumnDesc::maxLength().

Referenced by setMaxLength().

◆ name()

const String& casacore::ColumnDesc::name ( ) const

Get the name of the column.

Referenced by setName().

◆ ndim()

Int casacore::ColumnDesc::ndim ( ) const
inline

Get the number of dimensions.

Definition at line 265 of file ColumnDesc.h.

References colPtr_p, and casacore::BaseColumnDesc::ndim().

Referenced by setNdim().

◆ operator!=()

Bool casacore::ColumnDesc::operator!= ( const ColumnDesc ) const

◆ operator=()

ColumnDesc& casacore::ColumnDesc::operator= ( const ColumnDesc that)

Assignment (copy semantics).

◆ operator==()

Bool casacore::ColumnDesc::operator== ( const ColumnDesc ) const

Comparison.

Two descriptions are equal when their data types, value types (scalar, array or table) and possible dimensionalities are equal.

◆ options()

int casacore::ColumnDesc::options ( ) const
inline

Get the options.

The possible options are defined by the enum Option. E.g.

const ColumnDesc& coldesc = tableDesc.getColumn ("column_name");
if (coldesc.option() & ColumnDesc::Direct == ColumnDesc::Direct) {
// the column has the Direct flag set
}
@ Direct
direct table or array
Definition: ColumnDesc.h:144

Definition at line 246 of file ColumnDesc.h.

References colPtr_p, and casacore::BaseColumnDesc::options().

Referenced by setOptions().

◆ putFile()

void casacore::ColumnDesc::putFile ( AipsIO ios,
const TableAttr  
) const
private

Store the object in AipsIO.

◆ registerCtor()

static void casacore::ColumnDesc::registerCtor ( const String name,
ColumnDescCtor func 
)
static

Register a "XXColumnDesc" constructor (thread-safe).

◆ renameAction()

void casacore::ColumnDesc::renameAction ( const String newName,
const String oldName 
)
inlineprivate

This function allows each column to act upon a rename of another column.

If the old name is used internally, the column can update itself. It is called after handleRename has been called.

Definition at line 410 of file ColumnDesc.h.

References colPtr_p, and casacore::BaseColumnDesc::renameAction().

◆ rwKeywordSet()

TableRecord& casacore::ColumnDesc::rwKeywordSet ( )
inline

Get access to the set of keywords.

Definition at line 182 of file ColumnDesc.h.

References colPtr_p, and casacore::BaseColumnDesc::rwKeywordSet().

◆ setDefaultDataManager()

void casacore::ColumnDesc::setDefaultDataManager ( Bool  always = True)
inline

If always==True they are always set, otherwise only if empty.

Definition at line 227 of file ColumnDesc.h.

References colPtr_p, and casacore::BaseColumnDesc::setDefaultDataManager().

◆ setMaxLength()

void casacore::ColumnDesc::setMaxLength ( uInt  maxLength)
inline

Set the maximum value length.

So far, this is only possible for columns containing String values. An exception is thrown if the column data type is not TpString. Some storage managers support fixed length strings and can store them more efficiently than variable length strings.

Definition at line 312 of file ColumnDesc.h.

References colPtr_p, maxLength(), and casacore::BaseColumnDesc::setMaxLength().

◆ setName()

void casacore::ColumnDesc::setName ( const String name)
inline

Set the name of the column.

Definition at line 339 of file ColumnDesc.h.

References colPtr_p, name(), and casacore::BaseColumnDesc::setName().

◆ setNdim()

void casacore::ColumnDesc::setNdim ( uInt  ndim)
inline

Set the number of dimensions.

This is only allowed for arrays. ndim can be zero to clear the number of dimensions and the shape. Otherwise it can only be used if the dimensionality has not been defined yet.

Definition at line 279 of file ColumnDesc.h.

References colPtr_p, ndim(), and casacore::BaseColumnDesc::setNdim().

◆ setOptions()

void casacore::ColumnDesc::setOptions ( int  options)
inline

Set the options to the given value.

Option ColumnDesc::Direct forces FixedShape. If FixedShape is not given (implicitly or explicitly), the column can have no shape, so its shape is cleared.

Definition at line 300 of file ColumnDesc.h.

References colPtr_p, options(), and casacore::BaseColumnDesc::setOptions().

◆ setShape() [1/2]

void casacore::ColumnDesc::setShape ( const IPosition shape)
inline

Set the predefined shape.

This is only allowed for arrays, for which the shape has not been defined yet. If the dimensionality has already been defined, it must match. It will set the option FixedShape if not set yet.
The first version leaves the Direct option as is. The second version sets the Direct option as given.

Definition at line 290 of file ColumnDesc.h.

References colPtr_p, casacore::BaseColumnDesc::setShape(), and shape().

◆ setShape() [2/2]

void casacore::ColumnDesc::setShape ( const IPosition shape,
Bool  directOption 
)
inline

Definition at line 292 of file ColumnDesc.h.

References colPtr_p, casacore::BaseColumnDesc::setShape(), and shape().

◆ shape()

const IPosition& casacore::ColumnDesc::shape ( ) const
inline

Get the predefined shape.

If not defined, a zero shape will be returned.

Definition at line 270 of file ColumnDesc.h.

References colPtr_p, and casacore::BaseColumnDesc::shape().

Referenced by setShape().

◆ show() [1/2]

void casacore::ColumnDesc::show ( ) const

Show the column on cout.

◆ show() [2/2]

void casacore::ColumnDesc::show ( ostream &  os) const

Show the column.

◆ tableDesc() [1/2]

TableDesc* casacore::ColumnDesc::tableDesc ( )
inline

Definition at line 319 of file ColumnDesc.h.

References colPtr_p, and casacore::BaseColumnDesc::tableDesc().

◆ tableDesc() [2/2]

const TableDesc* casacore::ColumnDesc::tableDesc ( ) const
inline

Get table description (in case column contains subtables).

Definition at line 317 of file ColumnDesc.h.

References colPtr_p, and casacore::BaseColumnDesc::tableDesc().

◆ trueDataType()

DataType casacore::ColumnDesc::trueDataType ( ) const

Get the true data type of the column.

Unlike dataType, it returns an array data type (e.g. TpArrayInt) when the column contains arrays.

Friends And Related Function Documentation

◆ BaseColumn

friend class BaseColumn
friend

Definition at line 136 of file ColumnDesc.h.

◆ ColumnDescSet

friend class ColumnDescSet
friend

Definition at line 134 of file ColumnDesc.h.

◆ ColumnSet

friend class ColumnSet
friend

Definition at line 135 of file ColumnDesc.h.

◆ operator<< [1/2]

AipsIO& operator<< ( AipsIO ios,
const ColumnDesc cd 
)
friend

Write into AipsIO.

◆ operator<< [2/2]

ostream& operator<< ( ostream &  ios,
const ColumnDesc cd 
)
friend

Show on ostream.

◆ operator>>

AipsIO& operator>> ( AipsIO ios,
ColumnDesc cd 
)
friend

Read from AipsIO.

Member Data Documentation

◆ allocated_p

Bool casacore::ColumnDesc::allocated_p
protected

Definition at line 426 of file ColumnDesc.h.

◆ colPtr_p

BaseColumnDesc* casacore::ColumnDesc::colPtr_p
protected

◆ theirMutex

std::mutex casacore::ColumnDesc::theirMutex
staticprivate

A mutex for additions to the constructor map.

Definition at line 362 of file ColumnDesc.h.


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