casa
$Rev:20696$
|
Readonly access to a scalar table column with arbitrary data type. More...
#include <ScalarColumn.h>
Public Member Functions | |
ROScalarColumn () | |
The default constructor creates a null object, i.e. | |
ROScalarColumn (const Table &, const String &columnName) | |
Construct for the given column in the given table. | |
ROScalarColumn (const ROTableColumn &) | |
Construct from the given table column. | |
ROScalarColumn (const ROScalarColumn< T > &) | |
Copy constructor (reference semantics). | |
~ROScalarColumn () | |
virtual ROTableColumn * | clone () const |
Clone the object. | |
void | reference (const ROScalarColumn< T > &) |
Change the reference to another column. | |
void | attach (const Table &table, const String &columnName) |
Attach a column to the object. | |
void | get (uInt rownr, T &value) const |
Get the data from a particular cell (i.e. | |
T | operator() (uInt rownr) const |
void | getColumn (Vector< T > &vec, Bool resize=False) const |
Get the vector of all values in the column. | |
Vector< T > | getColumn () const |
Get the vector of all values in the column. | |
void | getColumnRange (const Slicer &rowRange, Vector< T > &vec, Bool resize=False) const |
Get the vector of a range of values in the column. | |
Vector< T > | getColumnRange (const Slicer &rowRange) const |
Get the vector of a range of values in the column. | |
void | getColumnCells (const RefRows &rownrs, Vector< T > &vec, Bool resize=False) const |
Get the vector of some values in the column. | |
Vector< T > | getColumnCells (const RefRows &rownrs) const |
Get the vector of some values in the column. | |
Protected Attributes | |
Bool | canAccessColumn_p |
Keep a switch to determine if an entire column can be accessed. | |
Bool | reaskAccessColumn_p |
Keep a switch to know if access knowledge is permanent or has to be asked again the next time. | |
Private Member Functions | |
ROScalarColumn< T > & | operator= (const ROScalarColumn< T > &) |
Assignment makes no sense for a readonly class. | |
void | reference (const ROTableColumn &) |
Referencing any other typed column cannot be done. | |
void | checkDataType () const |
Check if the data type matches the column data type. |
Readonly access to a scalar table column with arbitrary data type.
Public interface
ROScalarColumn<T> gives readonly access to an column in a table containing a scalar with data type T.
The class ROScalarColumn allows readonly access to a column containing scalar values with an arbitrary data type. It is possible to get the data in an individual cell (i.e. table row) and to get the column as a whole.
A default constructor is defined to allow construction of an array of ROScalarColumn objects. However, this constructs an object not referencing a column. Functions like get, etc. will fail (i.e. result in a segmentation fault) when used on such objects. The functions isNull and throwIfNull can be used to test on this. The functions attach and reference can fill in the object.
The assignment operator is not defined for this class, because it was felt it would be too confusing. Instead the function reference can be used to do assignment with reference semantics. An assignment with copy semantics makes no sense for a readonly column.
See module Tables .
Definition at line 90 of file ScalarColumn.h.
casa::ROScalarColumn< T >::ROScalarColumn | ( | ) |
The default constructor creates a null object, i.e.
it does not reference a table column. The sole purpose of this constructor is to allow construction of an array of ROScalarColumn objects. The functions reference and attach can be used to make a null object reference a column. Note that get functions, etc. will cause a segmentation fault when operating on a null object. It was felt it was too expensive to test on null over and over again. The user should use the isNull or throwIfNull function in case of doubt.
casa::ROScalarColumn< T >::ROScalarColumn | ( | const Table & | , |
const String & | columnName | ||
) |
Construct for the given column in the given table.
casa::ROScalarColumn< T >::ROScalarColumn | ( | const ROTableColumn & | ) |
Construct from the given table column.
This constructor is useful if first a table column was constructed, its type is determined and thereafter used to construct the correct column object.
casa::ROScalarColumn< T >::ROScalarColumn | ( | const ROScalarColumn< T > & | ) |
Copy constructor (reference semantics).
casa::ROScalarColumn< T >::~ROScalarColumn | ( | ) |
void casa::ROScalarColumn< T >::attach | ( | const Table & | table, |
const String & | columnName | ||
) | [inline] |
Attach a column to the object.
This is in fact only a shorthand for
reference (ROScalarColumn<T> (table, columnName));
Reimplemented from casa::ROTableColumn.
Reimplemented in casa::ScalarColumn< T >, casa::ScalarColumn< Float >, casa::ScalarColumn< Double >, casa::ScalarColumn< String >, casa::ScalarColumn< Int >, casa::ScalarColumn< Bool >, casa::ScalarColumn< TableRecord >, and casa::ScalarColumn< Complex >.
Definition at line 133 of file ScalarColumn.h.
void casa::ROScalarColumn< T >::checkDataType | ( | ) | const [private] |
Check if the data type matches the column data type.
virtual ROTableColumn* casa::ROScalarColumn< T >::clone | ( | ) | const [virtual] |
Clone the object.
Reimplemented from casa::ROTableColumn.
Reimplemented in casa::ScalarColumn< T >, casa::ScalarColumn< Float >, casa::ScalarColumn< Double >, casa::ScalarColumn< String >, casa::ScalarColumn< Int >, casa::ScalarColumn< Bool >, casa::ScalarColumn< TableRecord >, and casa::ScalarColumn< Complex >.
void casa::ROScalarColumn< T >::get | ( | uInt | rownr, |
T & | value | ||
) | const [inline] |
Get the data from a particular cell (i.e.
table row). The row numbers count from 0 until #rows-1.
Definition at line 139 of file ScalarColumn.h.
Referenced by casa::areEQ().
void casa::ROScalarColumn< T >::getColumn | ( | Vector< T > & | vec, |
Bool | resize = False |
||
) | const |
Get the vector of all values in the column.
According to the assignment rules of class Array, the destination vector must be empty or its length must be the number of cells in the column (i.e. the number of rows in the table).
Referenced by casa::MSPlotConvertAzimuth::findValue(), casa::MSPlotConvertElevation::findValue(), casa::MSPlotConvertHourangle::findValue(), casa::MSPlotConvertParallacticangle::findValue(), casa::MSPlotConvertAzimuth::MSPlotConvertAzimuth(), casa::MSPlotConvertChanToVelocity::MSPlotConvertChanToVelocity(), casa::MSPlotConvertElevation::MSPlotConvertElevation(), casa::MSPlotConvertHourangle::MSPlotConvertHourangle(), and casa::MSPlotConvertParallacticangle::MSPlotConvertParallacticangle().
Vector<T> casa::ROScalarColumn< T >::getColumn | ( | ) | const |
Get the vector of all values in the column.
void casa::ROScalarColumn< T >::getColumnCells | ( | const RefRows & | rownrs, |
Vector< T > & | vec, | ||
Bool | resize = False |
||
) | const |
Get the vector of some values in the column.
The Slicer object can be used to specify start, end (or length), and stride of the rows to get. According to the assignment rules of class Array, the destination vector must be empty or its length must be the number of cells in the column (i.e. the number of rows in the RefRows object).
Vector<T> casa::ROScalarColumn< T >::getColumnCells | ( | const RefRows & | rownrs | ) | const |
Get the vector of some values in the column.
void casa::ROScalarColumn< T >::getColumnRange | ( | const Slicer & | rowRange, |
Vector< T > & | vec, | ||
Bool | resize = False |
||
) | const |
Get the vector of a range of values in the column.
The Slicer object can be used to specify start, end (or length), and stride of the rows to get. According to the assignment rules of class Array, the destination vector must be empty or its length must be the number of cells in the column (i.e. the number of rows in the slicer).
Vector<T> casa::ROScalarColumn< T >::getColumnRange | ( | const Slicer & | rowRange | ) | const |
Get the vector of a range of values in the column.
The Slicer object can be used to specify start, end (or length), and stride of the rows to get.\.
T casa::ROScalarColumn< T >::operator() | ( | uInt | rownr | ) | const [inline] |
Definition at line 149 of file ScalarColumn.h.
ROScalarColumn<T>& casa::ROScalarColumn< T >::operator= | ( | const ROScalarColumn< T > & | ) | [private] |
Assignment makes no sense for a readonly class.
Declaring this operator private, makes it unusable.
void casa::ROScalarColumn< T >::reference | ( | const ROScalarColumn< T > & | ) |
Change the reference to another column.
This is in fact an assignment operator with reference semantics. It removes the reference to the current column and creates a reference to the column referenced in the other object. It will handle null objects correctly.
Referenced by casa::ROScalarColumn< uInt >::attach().
void casa::ROScalarColumn< T >::reference | ( | const ROTableColumn & | ) | [private] |
Referencing any other typed column cannot be done.
If we do not put this function here, the conversion constructor ROScalarColumn (const ROTableColumn&) will be used and no compile error is given.
Reimplemented from casa::ROTableColumn.
Bool casa::ROScalarColumn< T >::canAccessColumn_p [mutable, protected] |
Keep a switch to determine if an entire column can be accessed.
True = yes; False = no.
Definition at line 209 of file ScalarColumn.h.
Bool casa::ROScalarColumn< T >::reaskAccessColumn_p [mutable, protected] |
Keep a switch to know if access knowledge is permanent or has to be asked again the next time.
Definition at line 212 of file ScalarColumn.h.