casacore
|
#include <ColumnDesc.h>
Public Types | |
enum | Option { Direct , Undefined , FixedShape } |
Enumerate the possible column options. More... | |
typedef BaseColumnDesc * | ColumnDescCtor(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 () | |
ColumnDesc & | operator= (const ColumnDesc &that) |
Assignment (copy semantics). | |
Bool | operator== (const ColumnDesc &) const |
Comparison. | |
Bool | operator!= (const ColumnDesc &) const |
TableRecord & | rwKeywordSet () |
Get access to the set of keywords. | |
const TableRecord & | keywordSet () const |
const String & | name () 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 String & | dataTypeId () const |
Get the type id for non-standard data types (i.e. | |
const String & | dataManagerType () const |
Get the type name of the default data manager. | |
String & | dataManagerType () |
Get the type name of the default data manager (allowing it to be changed). | |
const String & | dataManagerGroup () const |
Get the data manager group. | |
String & | dataManagerGroup () |
Get the data manager group. | |
void | setDefaultDataManager (Bool always=True) |
If always==True they are always set, otherwise only if empty. | |
const String & | comment () const |
Get comment string. | |
String & | comment () |
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 IPosition & | shape () 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 TableDesc * | tableDesc () const |
Get table description (in case column contains subtables). | |
TableDesc * | tableDesc () |
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. | |
RefColumn * | makeRefColumn (RefTable *rtp, BaseColumn *bcp) const |
Create a RefColumn column object out of this column description. | |
ConcatColumn * | makeConcatColumn (ConcatTable *rtp) const |
Create a ConcatColumn column object out of this column description. | |
Static Public Member Functions | |
static ColumnDescCtor * | getCtor (const String &name) |
Get a construction function for a XXColumnDesc object (thread-safe). | |
static void | registerCtor (const String &name, ColumnDescCtor *func) |
Register a "XXColumnDesc" constructor (thread-safe). | |
Protected Attributes | |
BaseColumnDesc * | colPtr_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. | |
PlainColumn * | makeColumn (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 std::map< String, ColumnDescCtor * > & | getRegisterMap () |
Define a map which maps the name of the various XXColumnDesc classes to a static function constructing them. | |
static std::map< String, ColumnDescCtor * > | initRegisterMap () |
Register the main data managers. | |
Static Private Attributes | |
static std::mutex | theirMutex |
A mutex for additions to the constructor map. | |
Friends | |
class | ColumnDescSet |
class | ColumnSet |
class | BaseColumn |
AipsIO & | operator<< (AipsIO &ios, const ColumnDesc &cd) |
Write into AipsIO. | |
AipsIO & | operator>> (AipsIO &ios, ColumnDesc &cd) |
Read from AipsIO. | |
ostream & | operator<< (ostream &ios, const ColumnDesc &cd) |
Show on ostream. | |
Envelope class for the description of a table column
Public interface
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:
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 130 of file ColumnDesc.h.
typedef BaseColumnDesc * casacore::ColumnDesc::ColumnDescCtor(const String &className) |
Define the type of a XXColumnDesc construction function.
Definition at line 350 of file ColumnDesc.h.
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 140 of file ColumnDesc.h.
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.
casacore::ColumnDesc::ColumnDesc | ( | const ColumnDesc & | that | ) |
Copy constructor (copy semantics).
|
inline |
Default constructor (needed for ColumnDescSet).
Definition at line 160 of file ColumnDesc.h.
casacore::ColumnDesc::~ColumnDesc | ( | ) |
|
private |
Construct from a pointer (for class BaseColumn).
|
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 384 of file ColumnDesc.h.
References casacore::BaseColumnDesc::checkAdd(), and colPtr_p.
|
inlineprivate |
Check when a column gets renamed in a table description.
It is not used.
Definition at line 388 of file ColumnDesc.h.
References casacore::BaseColumnDesc::checkRename(), and colPtr_p.
|
inline |
Get comment string (allowing it to be changed).
Definition at line 233 of file ColumnDesc.h.
References colPtr_p, and casacore::BaseColumnDesc::comment().
|
inline |
Get comment string.
Definition at line 229 of file ColumnDesc.h.
References colPtr_p, and casacore::BaseColumnDesc::comment().
|
inline |
Get the data manager group.
(allowing it to be changed).
Definition at line 221 of file ColumnDesc.h.
References colPtr_p, and casacore::BaseColumnDesc::dataManagerGroup().
|
inline |
Get the data manager group.
Definition at line 216 of file ColumnDesc.h.
References colPtr_p, and casacore::BaseColumnDesc::dataManagerGroup().
|
inline |
Get the type name of the default data manager (allowing it to be changed).
Definition at line 212 of file ColumnDesc.h.
References colPtr_p, and casacore::BaseColumnDesc::dataManagerType().
|
inline |
Get the type name of the default data manager.
Definition at line 207 of file ColumnDesc.h.
References colPtr_p, and casacore::BaseColumnDesc::dataManagerType().
|
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 193 of file ColumnDesc.h.
References colPtr_p, and casacore::BaseColumnDesc::dataType().
|
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 203 of file ColumnDesc.h.
References colPtr_p, and casacore::BaseColumnDesc::dataTypeId().
|
static |
Get a construction function for a XXColumnDesc object (thread-safe).
Get the object from AipsIO.
|
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
.
|
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 397 of file ColumnDesc.h.
References colPtr_p, and casacore::BaseColumnDesc::handleAdd().
|
inlineprivate |
Definition at line 401 of file ColumnDesc.h.
References colPtr_p, and casacore::BaseColumnDesc::handleRemove().
|
inlineprivate |
Definition at line 399 of file ColumnDesc.h.
References colPtr_p, and casacore::BaseColumnDesc::handleRename().
|
staticprivate |
Register the main data managers.
|
inline |
Test if column is an array.
Definition at line 256 of file ColumnDesc.h.
References colPtr_p, and casacore::BaseColumnDesc::isArray().
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.
|
inline |
Test if column is a scalar.
Definition at line 253 of file ColumnDesc.h.
References colPtr_p, and casacore::BaseColumnDesc::isScalar().
|
inline |
Test if column is a table.
Definition at line 259 of file ColumnDesc.h.
References colPtr_p, and casacore::BaseColumnDesc::isTable().
|
inline |
Definition at line 182 of file ColumnDesc.h.
References colPtr_p, and casacore::BaseColumnDesc::keywordSet().
|
inlineprivate |
Create a PlainColumn column object out of this column description.
Definition at line 412 of file ColumnDesc.h.
References colPtr_p, and casacore::BaseColumnDesc::makeColumn().
|
inline |
Create a ConcatColumn column object out of this column description.
Definition at line 345 of file ColumnDesc.h.
References colPtr_p, and casacore::BaseColumnDesc::makeConcatColumn().
|
inline |
Create a RefColumn column object out of this column description.
Definition at line 341 of file ColumnDesc.h.
References colPtr_p, and casacore::BaseColumnDesc::makeRefColumn().
|
inline |
Get the maximum value length.
Definition at line 302 of file ColumnDesc.h.
References colPtr_p, and casacore::BaseColumnDesc::maxLength().
Referenced by setMaxLength().
const String & casacore::ColumnDesc::name | ( | ) | const |
Get the name of the column.
Referenced by setName().
|
inline |
Get the number of dimensions.
Definition at line 263 of file ColumnDesc.h.
References colPtr_p, and casacore::BaseColumnDesc::ndim().
Referenced by setNdim().
Bool casacore::ColumnDesc::operator!= | ( | const ColumnDesc & | ) | const |
ColumnDesc & casacore::ColumnDesc::operator= | ( | const ColumnDesc & | that | ) |
Assignment (copy semantics).
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.
|
inline |
Get the options.
The possible options are defined by the enum Option. E.g.
Definition at line 244 of file ColumnDesc.h.
References colPtr_p, and casacore::BaseColumnDesc::options().
Referenced by setOptions().
Store the object in AipsIO.
|
static |
Register a "XXColumnDesc" constructor (thread-safe).
|
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 408 of file ColumnDesc.h.
References colPtr_p, and casacore::BaseColumnDesc::renameAction().
|
inline |
Get access to the set of keywords.
Definition at line 180 of file ColumnDesc.h.
References colPtr_p, and casacore::BaseColumnDesc::rwKeywordSet().
If always==True
they are always set, otherwise only if empty.
Definition at line 225 of file ColumnDesc.h.
References colPtr_p, and casacore::BaseColumnDesc::setDefaultDataManager().
|
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 310 of file ColumnDesc.h.
References colPtr_p, maxLength(), and casacore::BaseColumnDesc::setMaxLength().
|
inline |
Set the name of the column.
Definition at line 337 of file ColumnDesc.h.
References colPtr_p, name(), and casacore::BaseColumnDesc::setName().
|
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 277 of file ColumnDesc.h.
References colPtr_p, ndim(), and casacore::BaseColumnDesc::setNdim().
|
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 298 of file ColumnDesc.h.
References colPtr_p, options(), and casacore::BaseColumnDesc::setOptions().
|
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 288 of file ColumnDesc.h.
References colPtr_p, casacore::BaseColumnDesc::setShape(), and shape().
Definition at line 290 of file ColumnDesc.h.
References colPtr_p, casacore::BaseColumnDesc::setShape(), and shape().
|
inline |
Get the predefined shape.
If not defined, a zero shape will be returned.
Definition at line 268 of file ColumnDesc.h.
References colPtr_p, and casacore::BaseColumnDesc::shape().
Referenced by setShape(), and setShape().
void casacore::ColumnDesc::show | ( | ) | const |
Show the column on cout.
void casacore::ColumnDesc::show | ( | ostream & | os | ) | const |
Show the column.
|
inline |
Definition at line 317 of file ColumnDesc.h.
References colPtr_p, and casacore::BaseColumnDesc::tableDesc().
|
inline |
Get table description (in case column contains subtables).
Definition at line 315 of file ColumnDesc.h.
References colPtr_p, and casacore::BaseColumnDesc::tableDesc().
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.
|
friend |
Definition at line 134 of file ColumnDesc.h.
|
friend |
Definition at line 132 of file ColumnDesc.h.
|
friend |
Definition at line 133 of file ColumnDesc.h.
|
friend |
Write into AipsIO.
|
friend |
Show on ostream.
|
friend |
Read from AipsIO.
|
protected |
Definition at line 424 of file ColumnDesc.h.
|
protected |
Definition at line 423 of file ColumnDesc.h.
Referenced by checkAdd(), checkRename(), comment(), comment(), dataManagerGroup(), dataManagerGroup(), dataManagerType(), dataManagerType(), dataType(), dataTypeId(), handleAdd(), handleRemove(), handleRename(), isArray(), isScalar(), isTable(), keywordSet(), makeColumn(), makeConcatColumn(), makeRefColumn(), maxLength(), ndim(), options(), renameAction(), rwKeywordSet(), setDefaultDataManager(), setMaxLength(), setName(), setNdim(), setOptions(), setShape(), setShape(), shape(), tableDesc(), and tableDesc().
|
staticprivate |
A mutex for additions to the constructor map.
Definition at line 360 of file ColumnDesc.h.