ColumnDesc.h

Classes

ColumnDesc -- Envelope class for the description of a table column (full description)

class ColumnDesc

Types

enum Option

Direct = 1
Undefined = 2
direct table or array

Interface

Public Members
ColumnDesc (const BaseColumnDesc&)
ColumnDesc (const ColumnDesc& that)
ColumnDesc() : colPtr_p(0)
~ColumnDesc()
ColumnDesc& operator= (const ColumnDesc& that)
ScalarKeywordSet& keywordSet()
const ScalarKeywordSet& keywordSet() const
const String& name() const
DataType dataType() const
const String& dataManagerName() const
const String& dataManagerGroup() const
const String& comment() const
String& comment()
int options() const
Bool isScalar() const
Bool isArray() const
Bool isTable() const
Int ndim() const
const TableDesc* tableDesc() const
TableDesc* tableDesc()
void show() const
friend AipsIO& operator<< (AipsIO& ios, const ColumnDesc& cd)
friend AipsIO& operator>> (AipsIO& ios, ColumnDesc& cd)
friend ostream& operator<< (ostream& ios, const ColumnDesc& cd)
static BaseColumnDesc* unknownColumnDesc (const String& name, AipsIO&)
Private Members
ColumnDesc (BaseColumnDesc*)
void checkAdd (const ColumnDescSet& cds) const
void checkRename (const ColumnDescSet& cds, const String& newName) const
void handleAdd (ColumnDescSet& cds)
void handleRename (ColumnDescSet& cds, const String& oldName)
void handleRemove (ColumnDescSet& cds)
void renameAction (const String& newName, const String& oldName)
PlainColumn* makeColumn (ColumnSet* csp)
RefColumn* makeRefColumn (RefTable* rtp, BaseColumn* bcp)
void setName (const String& name)
void putFile (AipsIO&) const
void getFile (AipsIO&)
void registerColumnDesc()

Description

Review Status

Reviewed By:
Paul Shannon
Date Reviewed:
1994/08/11
Programs:
Tests:

Prerequisite

Synopsis

Class ColumnDesc is an envelope around the letter class BaseColDesc and its derivations like ScalarColumnDesc. 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, 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. These options are:

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.

To Do

Member Description

enum Option

ColumnDesc (const BaseColumnDesc&)

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

ColumnDesc (const ColumnDesc& that)

Copy constructor (copy semantics).

ColumnDesc() : colPtr_p(0)

Default constructor (needed for ColumnDescSet).

~ColumnDesc()

ColumnDesc& operator= (const ColumnDesc& that)

Assignment (copy semantics).

ScalarKeywordSet& keywordSet()
const ScalarKeywordSet& keywordSet() const

Get access to the set of keywords.

const String& name() const

Get the name of the column.

DataType dataType() const

Get the data type of the column.

const String& dataManagerName() const

Get the name of the default data manager.

const String& dataManagerGroup() const

Get the data manager group.

const String& comment() const

Get comment string.

String& comment()

Get comment string (allowing it to be changed).

int options() const

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
    }

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 TableDesc* tableDesc() const
TableDesc* tableDesc()

Get table description (in case column contains subtables).

void show() const

Show the column on cout.

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

Write into AipsIO.

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

Read from AipsIO.

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

Show on ostream.

static BaseColumnDesc* unknownColumnDesc (const String& name, AipsIO&)

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

Thrown Exceptions

ColumnDesc (BaseColumnDesc*)

Construct from a pointer (for class BaseColumn).

void checkAdd (const ColumnDescSet& cds) const

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.

void checkRename (const ColumnDescSet& cds, const String& newName) const

Check if a column can be handled by ColumnDescSet. It is called before the column gets actually added, etc..

Check when a column gets renamed in a table description. It is not used.

void handleAdd (ColumnDescSet& cds)
void handleRename (ColumnDescSet& cds, const String& oldName)
void handleRemove (ColumnDescSet& cds)

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.

void renameAction (const String& newName, const String& oldName)

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.

PlainColumn* makeColumn (ColumnSet* csp)

Create a PlainColumn column object out of this column description.

RefColumn* makeRefColumn (RefTable* rtp, BaseColumn* bcp)

Create a RefColumn column object out of this column description.

void setName (const String& name)

Set the name of the column.

void putFile (AipsIO&) const

Store the object in AipsIO.

void getFile (AipsIO&)

Get the object from AipsIO. It uses the registerMap to construct the correct xxxColumnDesc object.

Thrown Exceptions

void registerColumnDesc()

Register all column types. In this way the getFile function can construct the correct xxxColumnDesc object.

Tip This function is implemented in ColumnReg.cc.

Copyright © 1995 Associated Universities Inc., Washington, D.C.