casa  $Rev:20696$
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions
casa::ROArrayColumn< T > Class Template Reference

Readonly access to an array table column with arbitrary data type. More...

#include <ArrayColumn.h>

Inheritance diagram for casa::ROArrayColumn< T >:
casa::ROTableColumn casa::ArrayColumn< T >

List of all members.

Public Member Functions

 ROArrayColumn ()
 The default constructor creates a null object, i.e.
 ROArrayColumn (const Table &, const String &columnName)
 Construct for the given column in the given table.
 ROArrayColumn (const ROTableColumn &)
 Construct from the given table column.
 ROArrayColumn (const ROArrayColumn< T > &)
 Copy constructor (reference semantics).
 ~ROArrayColumn ()
virtual ROTableColumnclone () const
 Clone the object.
void reference (const ROArrayColumn< T > &)
 Change the reference to another column.
void attach (const Table &table, const String &columnName)
 Attach a column to the object.
uInt ndim (uInt rownr) const
 Get the #dimensions of an array in a particular cell.
IPosition shape (uInt rownr) const
 Get the shape of an array in a particular cell.
void get (uInt rownr, Array< T > &array, Bool resize=False) const
 Get the array value in a particular cell (i.e.
Array< T > operator() (uInt rownr) const
void getSlice (uInt rownr, const Slicer &arraySection, Array< T > &array, Bool resize=False) const
 Get a slice of an N-dimensional array in a particular cell (i.e.
Array< T > getSlice (uInt rownr, const Slicer &arraySection) const
void getSlice (uInt rownr, const Vector< Vector< Slice > > &arraySlices, Array< T > &arr, Bool resize=False) const
 Get an irregular slice of an N-dimensional array in a particular cell (i.e.
Array< T > getSlice (uInt rownr, const Vector< Vector< Slice > > &arraySlices) const
void getColumn (Array< T > &array, Bool resize=False) const
 Get the array of all values in a column.
Array< T > getColumn () const
void getColumn (const Slicer &arraySection, Array< T > &array, Bool resize=False) const
 Get regular slices from all arrays in the column.
Array< T > getColumn (const Slicer &arraySection) const
void getColumn (const Vector< Vector< Slice > > &arraySection, Array< T > &array, Bool resize=False) const
 Get irregular slices from all arrays in the column as given by the vectors of Slice objects.
Array< T > getColumn (const Vector< Vector< Slice > > &arraySection) const
void getColumnRange (const Slicer &rowRange, Array< T > &arr, Bool resize=False) const
 Get the array of some values in a column.
Array< T > getColumnRange (const Slicer &rowRange) const
void getColumnCells (const RefRows &rownrs, Array< T > &arr, Bool resize=False) const
Array< T > getColumnCells (const RefRows &rownrs) const
void getColumnRange (const Slicer &rowRange, const Slicer &arraySection, Array< T > &arr, Bool resize=False) const
 Get slices from some arrays in a column.
Array< T > getColumnRange (const Slicer &rowRange, const Slicer &arraySection) const
void getColumnCells (const RefRows &rownrs, const Slicer &arraySection, Array< T > &arr, Bool resize=False) const
Array< T > getColumnCells (const RefRows &rownrs, const Slicer &arraySection) const
void baseGet (uInt rownr, Array< T > &array) const
 The get() function like above which does not check shapes, etc.

Protected Member Functions

void handleSlices (const Vector< Vector< Slice > > &slices, BaseSlicesFunctor< T > &functor, const Slicer &slicer, IPosition &arrEnd, Array< T > &array) const
 A common function used by all functions that can get or put irregular array slices.

Protected Attributes

Bool canAccessSlice_p
 Keep switches to determine if a slice or an entire column can be accessed or the change of an array can be changed.
Bool canAccessColumn_p
Bool canAccessColumnSlice_p
Bool reaskAccessSlice_p
 Keep switches to know if access knowledge is permanent or has to be asked again the next time.
Bool reaskAccessColumn_p
Bool reaskAccessColumnSlice_p

Private Member Functions

ROArrayColumn< T > & operator= (const ROArrayColumn< 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.
void checkShape (const IPosition &shp, Array< T > &arr, Bool resize, const String &where) const
 Check the shape of the array.

Detailed Description

template<class T>
class casa::ROArrayColumn< T >

Readonly access to an array table column with arbitrary data type.

Intended use:

Public interface

Review Status

Reviewed By:
dschieb
Date Reviewed:
1994/08/10
Test programs:
none

Prerequisite

Etymology

ROArrayColumn<T> gives readonly access to an column in a table containing an array with data type T.

Synopsis

The class ROArrayColumn allows readonly access to a column containing arrays with an arbitrary data type. It can handle direct as well as indirect arrays. It is possible to get the data in an individual cell (i.e. table row); either the whole array or a slice of the array can be accessed. It is also possible to get the column as a whole if the arrays in all cells of the column have the same shape (which is always true for direct arrays). As in the case of individual cells it is possible to get the entire arrays or a slice of the arrays.

A default constructor is defined to allow construction of an array of ROArrayColumn 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.

Template Type Argument Requirements (T)

Example

See module Tables .

Definition at line 103 of file ArrayColumn.h.


Constructor & Destructor Documentation

template<class T>
casa::ROArrayColumn< T >::ROArrayColumn ( )

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 ROArrayColumn 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.

template<class T>
casa::ROArrayColumn< T >::ROArrayColumn ( const Table ,
const String columnName 
)

Construct for the given column in the given table.

template<class T>
casa::ROArrayColumn< T >::ROArrayColumn ( 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.

template<class T>
casa::ROArrayColumn< T >::ROArrayColumn ( const ROArrayColumn< T > &  )

Copy constructor (reference semantics).

template<class T>
casa::ROArrayColumn< T >::~ROArrayColumn ( )

Member Function Documentation

template<class T>
void casa::ROArrayColumn< T >::attach ( const Table table,
const String columnName 
) [inline]

Attach a column to the object.

This is in fact only a shorthand for
reference (ROArrayColumn<T> (table, columnName));

Reimplemented from casa::ROTableColumn.

Reimplemented in casa::ArrayColumn< T >, casa::ArrayColumn< Float >, casa::ArrayColumn< Double >, casa::ArrayColumn< String >, casa::ArrayColumn< Short >, casa::ArrayColumn< Int >, casa::ArrayColumn< StoredType >, casa::ArrayColumn< Bool >, and casa::ArrayColumn< Complex >.

Definition at line 146 of file ArrayColumn.h.

template<class T>
void casa::ROArrayColumn< T >::baseGet ( uInt  rownr,
Array< T > &  array 
) const [inline]

The get() function like above which does not check shapes, etc.

It is faster and can be used for performance reasons if one knows for sure that the arguments are correct. E.g. it is used internally in virtual column engines.

Definition at line 329 of file ArrayColumn.h.

template<class T>
void casa::ROArrayColumn< T >::checkDataType ( ) const [private]

Check if the data type matches the column data type.

template<class T>
void casa::ROArrayColumn< T >::checkShape ( const IPosition shp,
Array< T > &  arr,
Bool  resize,
const String where 
) const [private]

Check the shape of the array.

If the array is empty or if resize=True, the array is resized if needed. An exception is thrown if not conforming.

template<class T>
virtual ROTableColumn* casa::ROArrayColumn< T >::clone ( ) const [virtual]
template<class T>
void casa::ROArrayColumn< T >::get ( uInt  rownr,
Array< T > &  array,
Bool  resize = False 
) const

Get the array value in a particular cell (i.e.

table row). The row numbers count from 0 until #rows-1.

According to the assignment rules of class Array, the destination array must be empty or its shape must conform the table array shape. However, if the resize flag is set the destination array will be resized if not conforming.

Referenced by casa::areEQ().

template<class T>
void casa::ROArrayColumn< T >::getColumn ( Array< T > &  array,
Bool  resize = False 
) const

Get the array of all values in a column.

If the column contains n-dim arrays, the resulting array is (n+1)-dim with the last dimension representing the number of rows. The arrays in the column must have the same shape in all cells.

According to the assignment rules of class Array, the destination array must be empty or its shape must conform the resulting (n+1)-dim array. However, if the resize flag is set the destination array will be resized if not conforming.

template<class T>
Array<T> casa::ROArrayColumn< T >::getColumn ( ) const
template<class T>
void casa::ROArrayColumn< T >::getColumn ( const Slicer arraySection,
Array< T > &  array,
Bool  resize = False 
) const

Get regular slices from all arrays in the column.

If the column contains n-dim arrays, the resulting array is (n+1)-dim. with the last dimension representing the number of rows and the other dimensions representing the shape of the slice. The arrays in the column must have the same shape in all cells.

According to the assignment rules of class Array, the destination array must be empty or its shape must conform the resulting (n+1)-dim array. However, if the resize flag is set the destination array will be resized if not conforming.

template<class T>
Array<T> casa::ROArrayColumn< T >::getColumn ( const Slicer arraySection) const
template<class T>
void casa::ROArrayColumn< T >::getColumn ( const Vector< Vector< Slice > > &  arraySection,
Array< T > &  array,
Bool  resize = False 
) const

Get irregular slices from all arrays in the column as given by the vectors of Slice objects.

The outer vector represents the array axes. A missing or empty axis means the entire axis. The inner vector represents the slices to take for each axis. For example, to get slices from 2-dim arrays:

        Vector<Vector<Slice> > slices(2);      // 2-dim
        slices[1].resize (3);                  // 3 slices in 2nd dim
        slices[1][0] = Slice(100,20);
        slices[1][1] = Slice(200,18);
        slices[1][2] = Slice(538,30,2);
        // Get data. Vector of first axis is empty, thus entire axis is read.
        Array<Complex> data = dataCol.getColumn (slices);

If the column contains n-dim arrays, the resulting array is (n+1)-dim. with the last dimension representing the number of rows and the other dimensions representing the shape of the slice. The arrays in the column must have the same shape in all cells.

According to the assignment rules of class Array, the destination array must be empty or its shape must conform the resulting (n+1)-dim array. However, if the resize flag is set the destination array will be resized if not conforming.

template<class T>
Array<T> casa::ROArrayColumn< T >::getColumn ( const Vector< Vector< Slice > > &  arraySection) const
template<class T>
void casa::ROArrayColumn< T >::getColumnCells ( const RefRows rownrs,
Array< T > &  arr,
Bool  resize = False 
) const
template<class T>
Array<T> casa::ROArrayColumn< T >::getColumnCells ( const RefRows rownrs) const
template<class T>
void casa::ROArrayColumn< T >::getColumnCells ( const RefRows rownrs,
const Slicer arraySection,
Array< T > &  arr,
Bool  resize = False 
) const
template<class T>
Array<T> casa::ROArrayColumn< T >::getColumnCells ( const RefRows rownrs,
const Slicer arraySection 
) const
template<class T>
void casa::ROArrayColumn< T >::getColumnRange ( const Slicer rowRange,
Array< T > &  arr,
Bool  resize = False 
) const

Get the array of some values in a column.

The Slicer object can be used to specify start, end (or length), and stride of the rows to get. If the column contains n-dim arrays, the resulting array is (n+1)-dim with the last dimension representing the number of rows in the slicer. The arrays in the column must have the same shape in all those cells. According to the assignment rules of class Array, the destination array must be empty or its shape must conform the resulting (n+1)-dim array. However, if the resize flag is set the destination array will be resized if not conforming.

template<class T>
Array<T> casa::ROArrayColumn< T >::getColumnRange ( const Slicer rowRange) const
template<class T>
void casa::ROArrayColumn< T >::getColumnRange ( const Slicer rowRange,
const Slicer arraySection,
Array< T > &  arr,
Bool  resize = False 
) const

Get slices from some arrays in a column.

The first Slicer object can be used to specify start, end (or length), and stride of the rows to get. The second Slicer object can be used to specify the slice to take from each array. If the column contains n-dim arrays, the resulting array is (n+1)-dim with the last dimension representing the number of rows in the slicer. The arrays in the column must have the same shape in all those cells. According to the assignment rules of class Array, the destination array must be empty or its shape must conform the resulting (n+1)-dim array. However, if the resize flag is set the destination array will be resized if not conforming.

template<class T>
Array<T> casa::ROArrayColumn< T >::getColumnRange ( const Slicer rowRange,
const Slicer arraySection 
) const
template<class T>
void casa::ROArrayColumn< T >::getSlice ( uInt  rownr,
const Slicer arraySection,
Array< T > &  array,
Bool  resize = False 
) const

Get a slice of an N-dimensional array in a particular cell (i.e.

table row). The row numbers count from 0 until #rows-1. The dimensionality of the slice must match the dimensionality of the table array and the slice definition should not exceed the shape of the table array.

According to the assignment rules of class Array, the destination array must be empty or its shape must conform the shape of the table array slice. However, if the resize flag is set the destination array will be resized if not conforming.

template<class T>
Array<T> casa::ROArrayColumn< T >::getSlice ( uInt  rownr,
const Slicer arraySection 
) const
template<class T>
void casa::ROArrayColumn< T >::getSlice ( uInt  rownr,
const Vector< Vector< Slice > > &  arraySlices,
Array< T > &  arr,
Bool  resize = False 
) const

Get an irregular slice of an N-dimensional array in a particular cell (i.e.

table row) as given by the vectors of Slice objects. The outer vector represents the array axes. A missing or empty axis means the entire axis. The inner vector represents the slices to take for each axis. For example, to get slices from 2-dim arrays:

        Vector<Vector<Slice> > slices(2);      // 2-dim
        slices[1].resize (3);                  // 3 slices in 2nd dim
        slices[1][0] = Slice(100,20);
        slices[1][1] = Slice(200,18);
        slices[1][2] = Slice(538,30,2);
        // Get data. Vector of first axis is empty, thus entire axis is read.
        Array<Complex> data = dataCol.getColumn (slices);

If the column contains n-dim arrays, the resulting array is (n+1)-dim. with the last dimension representing the number of rows and the other dimensions representing the shape of the slice. The arrays in the column must have the same shape in all cells.

According to the assignment rules of class Array, the destination array must be empty or its shape must conform the resulting (n+1)-dim array. However, if the resize flag is set the destination array will be resized if not conforming.

template<class T>
Array<T> casa::ROArrayColumn< T >::getSlice ( uInt  rownr,
const Vector< Vector< Slice > > &  arraySlices 
) const
template<class T>
void casa::ROArrayColumn< T >::handleSlices ( const Vector< Vector< Slice > > &  slices,
BaseSlicesFunctor< T > &  functor,
const Slicer slicer,
IPosition arrEnd,
Array< T > &  array 
) const [protected]

A common function used by all functions that can get or put irregular array slices.

The functor performs the get or put operation.

template<class T>
uInt casa::ROArrayColumn< T >::ndim ( uInt  rownr) const [inline]

Get the #dimensions of an array in a particular cell.

If the cell does not contain an array, 0 is returned. Use the function isDefined to test if the cell contains an array.

Reimplemented from casa::ROTableColumn.

Definition at line 152 of file ArrayColumn.h.

template<class T>
Array<T> casa::ROArrayColumn< T >::operator() ( uInt  rownr) const
template<class T>
ROArrayColumn<T>& casa::ROArrayColumn< T >::operator= ( const ROArrayColumn< T > &  ) [private]

Assignment makes no sense for a readonly class.

Declaring this operator private, makes it unusable.

template<class T>
void casa::ROArrayColumn< T >::reference ( const ROArrayColumn< 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::ROArrayColumn< uInt >::attach().

template<class T>
void casa::ROArrayColumn< T >::reference ( const ROTableColumn ) [private]

Referencing any other typed column cannot be done.

If we do not put this function here, the conversion constructor ROArrayColumn (const ROTableColumn&) will be used and no compile error is given.

Reimplemented from casa::ROTableColumn.

template<class T>
IPosition casa::ROArrayColumn< T >::shape ( uInt  rownr) const [inline]

Get the shape of an array in a particular cell.

If the cell does not contain an array, a 0-dim shape is returned. Use the function isDefined to test if the cell contains an array.

Reimplemented from casa::ROTableColumn.

Definition at line 158 of file ArrayColumn.h.


Member Data Documentation

template<class T>
Bool casa::ROArrayColumn< T >::canAccessColumn_p [mutable, protected]

Definition at line 366 of file ArrayColumn.h.

template<class T>
Bool casa::ROArrayColumn< T >::canAccessColumnSlice_p [mutable, protected]

Definition at line 367 of file ArrayColumn.h.

template<class T>
Bool casa::ROArrayColumn< T >::canAccessSlice_p [mutable, protected]

Keep switches to determine if a slice or an entire column can be accessed or the change of an array can be changed.

True = yes; False = no.

Definition at line 365 of file ArrayColumn.h.

template<class T>
Bool casa::ROArrayColumn< T >::reaskAccessColumn_p [mutable, protected]

Definition at line 371 of file ArrayColumn.h.

template<class T>
Bool casa::ROArrayColumn< T >::reaskAccessColumnSlice_p [mutable, protected]

Definition at line 372 of file ArrayColumn.h.

template<class T>
Bool casa::ROArrayColumn< T >::reaskAccessSlice_p [mutable, protected]

Keep switches to know if access knowledge is permanent or has to be asked again the next time.

Definition at line 370 of file ArrayColumn.h.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines