casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | Private Member Functions | Static Private Member Functions | Static Private Attributes | Friends
casa::ColumnDesc Class Reference

Envelope class for the description of a table column. More...

#include <ColumnDesc.h>

List of all members.

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.

Public Member Functions

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

Static Public Member Functions

static ColumnDescCtorgetCtor (const String &name)
 Get a construction function for a XXColumnDesc object (thread-safe).
static void registerCtor (const String &name, ColumnDescCtor *)
 Register a "XXColumnDesc" constructor (thread-safe).
static void registerMainCtor ()
 Register the main data managers (if not done yet).

Protected Attributes

BaseColumnDesccolPtr_p
Bool allocated_p

Private Member Functions

 ColumnDesc (BaseColumnDesc *)
 Construct from a pointer (for class BaseColumn).
void checkAdd (const ColumnDescSet &cds) const
 Check if a column can be handled by ColumnDescSet.
void checkRename (const ColumnDescSet &cds, const String &newName) const
 Check when a column gets renamed in a table description.
void handleAdd (ColumnDescSet &cds)
 Take action after a column has been handled by ColumnDescSet.
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.
PlainColumnmakeColumn (ColumnSet *csp) const
 Create a PlainColumn column object out of this column description.
void putFile (AipsIO &ios, const TableAttr &) const
 Store the object in AipsIO.
void getFile (AipsIO &, const TableAttr &)
 Get the object from AipsIO.

Static Private Member Functions

static void unlockedRegisterCtor (const String &type, ColumnDescCtor *func)
 Register a constructor without doing a mutex lock.
static BaseColumnDescunknownColumnDesc (const String &name)
 Serve as default function for theirRegisterMap (see below), which catches all unknown XXColumnDesc class names.
static void doRegisterMainCtor (void *)
 Do the actual (thread-safe) registration of the main data managers.

Static Private Attributes

static MutexedInit theirMutexedInit
 Define a map which maps the name of the various XXColumnDesc classes to a static function constructing them.
static SimpleOrderedMap
< String, BaseColumnDesc
*(*)(const String &)> 
theirRegisterMap

Friends

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

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";

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 131 of file ColumnDesc.h.


Member Typedef Documentation

Define the type of a XXColumnDesc construction function.

Definition at line 351 of file ColumnDesc.h.


Member Enumeration Documentation

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 141 of file ColumnDesc.h.


Constructor & Destructor Documentation

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.

Copy constructor (copy semantics).

Default constructor (needed for ColumnDescSet).

Definition at line 161 of file ColumnDesc.h.

Construct from a pointer (for class BaseColumn).


Member Function Documentation

void casa::ColumnDesc::checkAdd ( const ColumnDescSet cds) const [inline, private]

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 400 of file ColumnDesc.h.

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

void casa::ColumnDesc::checkRename ( const ColumnDescSet cds,
const String newName 
) const [inline, private]

Check when a column gets renamed in a table description.

It is not used.

Definition at line 404 of file ColumnDesc.h.

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

const String& casa::ColumnDesc::comment ( ) const [inline]

Get comment string.

Definition at line 230 of file ColumnDesc.h.

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

Get comment string (allowing it to be changed).

Definition at line 234 of file ColumnDesc.h.

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

const String& casa::ColumnDesc::dataManagerGroup ( ) const [inline]

Get the data manager group.

Definition at line 217 of file ColumnDesc.h.

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

Get the data manager group.

(allowing it to be changed).

Definition at line 222 of file ColumnDesc.h.

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

const String& casa::ColumnDesc::dataManagerType ( ) const [inline]

Get the type name of the default data manager.

Definition at line 208 of file ColumnDesc.h.

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

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

Definition at line 213 of file ColumnDesc.h.

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

DataType casa::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 194 of file ColumnDesc.h.

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

const String& casa::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 204 of file ColumnDesc.h.

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

static void casa::ColumnDesc::doRegisterMainCtor ( void *  ) [static, private]

Do the actual (thread-safe) registration of the main data managers.

static ColumnDescCtor* casa::ColumnDesc::getCtor ( const String name) [static]

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

void casa::ColumnDesc::getFile ( AipsIO ,
const TableAttr  
) [private]

Get the object from AipsIO.

void casa::ColumnDesc::handleAdd ( ColumnDescSet cds) [inline, private]

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 413 of file ColumnDesc.h.

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

void casa::ColumnDesc::handleRemove ( ColumnDescSet cds) [inline, private]

Definition at line 417 of file ColumnDesc.h.

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

void casa::ColumnDesc::handleRename ( ColumnDescSet cds,
const String oldName 
) [inline, private]

Definition at line 415 of file ColumnDesc.h.

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

Bool casa::ColumnDesc::isArray ( ) const [inline]

Test if column is an array.

Definition at line 257 of file ColumnDesc.h.

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

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.

Bool casa::ColumnDesc::isScalar ( ) const [inline]

Test if column is a scalar.

Definition at line 254 of file ColumnDesc.h.

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

Bool casa::ColumnDesc::isTable ( ) const [inline]

Test if column is a table.

Definition at line 260 of file ColumnDesc.h.

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

const TableRecord& casa::ColumnDesc::keywordSet ( ) const [inline]

Definition at line 183 of file ColumnDesc.h.

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

PlainColumn* casa::ColumnDesc::makeColumn ( ColumnSet csp) const [inline, private]

Create a PlainColumn column object out of this column description.

Definition at line 428 of file ColumnDesc.h.

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

Create a ConcatColumn column object out of this column description.

Definition at line 346 of file ColumnDesc.h.

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

RefColumn* casa::ColumnDesc::makeRefColumn ( RefTable rtp,
BaseColumn bcp 
) const [inline]

Create a RefColumn column object out of this column description.

Definition at line 342 of file ColumnDesc.h.

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

uInt casa::ColumnDesc::maxLength ( ) const [inline]

Get the maximum value length.

Definition at line 303 of file ColumnDesc.h.

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

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

Get the name of the column.

Int casa::ColumnDesc::ndim ( ) const [inline]

Get the number of dimensions.

Definition at line 264 of file ColumnDesc.h.

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

Bool casa::ColumnDesc::operator!= ( const ColumnDesc ) const
ColumnDesc& casa::ColumnDesc::operator= ( const ColumnDesc that)

Assignment (copy semantics).

Bool casa::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.

int casa::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
           }

Definition at line 245 of file ColumnDesc.h.

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

void casa::ColumnDesc::putFile ( AipsIO ios,
const TableAttr  
) const [private]

Store the object in AipsIO.

static void casa::ColumnDesc::registerCtor ( const String name,
ColumnDescCtor  
) [static]

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

static void casa::ColumnDesc::registerMainCtor ( ) [inline, static]

Register the main data managers (if not done yet).

It is fully thread-safe.

Definition at line 361 of file ColumnDesc.h.

References casa::MutexedInit::exec(), and theirMutexedInit.

void casa::ColumnDesc::renameAction ( const String newName,
const String oldName 
) [inline, private]

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 424 of file ColumnDesc.h.

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

Get access to the set of keywords.

Definition at line 181 of file ColumnDesc.h.

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

void casa::ColumnDesc::setDefaultDataManager ( Bool  always = True) [inline]

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

Definition at line 226 of file ColumnDesc.h.

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

void casa::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 311 of file ColumnDesc.h.

References colPtr_p, and casa::BaseColumnDesc::setMaxLength().

void casa::ColumnDesc::setName ( const String name) [inline]

Set the name of the column.

Definition at line 338 of file ColumnDesc.h.

References colPtr_p, and casa::BaseColumnDesc::setName().

void casa::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 278 of file ColumnDesc.h.

References colPtr_p, and casa::BaseColumnDesc::setNdim().

void casa::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 299 of file ColumnDesc.h.

References colPtr_p, and casa::BaseColumnDesc::setOptions().

void casa::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 289 of file ColumnDesc.h.

References colPtr_p, and casa::BaseColumnDesc::setShape().

void casa::ColumnDesc::setShape ( const IPosition shape,
Bool  directOption 
) [inline]

Definition at line 291 of file ColumnDesc.h.

References colPtr_p, and casa::BaseColumnDesc::setShape().

const IPosition& casa::ColumnDesc::shape ( ) const [inline]

Get the predefined shape.

If not defined, a zero shape will be returned.

Definition at line 269 of file ColumnDesc.h.

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

void casa::ColumnDesc::show ( ) const

Show the column on cout.

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

Show the column.

const TableDesc* casa::ColumnDesc::tableDesc ( ) const [inline]

Get table description (in case column contains subtables).

Definition at line 316 of file ColumnDesc.h.

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

Definition at line 318 of file ColumnDesc.h.

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

DataType casa::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.

static BaseColumnDesc* casa::ColumnDesc::unknownColumnDesc ( const String name) [static, private]

Serve as default function for theirRegisterMap (see below), which catches all unknown XXColumnDesc class names.

Thrown Exceptions

static void casa::ColumnDesc::unlockedRegisterCtor ( const String type,
ColumnDescCtor func 
) [inline, static, private]

Register a constructor without doing a mutex lock.

Definition at line 366 of file ColumnDesc.h.

References casa::SimpleOrderedMap< K, V >::define(), and theirRegisterMap.


Friends And Related Function Documentation

friend class BaseColumn [friend]

Definition at line 135 of file ColumnDesc.h.

friend class ColumnDescSet [friend]

Definition at line 133 of file ColumnDesc.h.

friend class ColumnSet [friend]

Definition at line 134 of file ColumnDesc.h.

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

Write into AipsIO.

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

Show on ostream.

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

Read from AipsIO.


Member Data Documentation

Definition at line 440 of file ColumnDesc.h.

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.

Definition at line 377 of file ColumnDesc.h.

Referenced by registerMainCtor().

Definition at line 378 of file ColumnDesc.h.

Referenced by unlockedRegisterCtor().


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