casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Member Functions | Protected Member Functions | Protected Attributes
casa::TableVector< T > Class Template Reference

Templated readonly table column vectors. More...

#include <TableVector.h>

List of all members.

Public Member Functions

 TableVector ()
 The default constructor creates a null table vector.
 TableVector (const Table &, const String &columnName)
 Create a read/write table vector from the given table column name.
 TableVector (const TableColumn &column)
 Create a read/write table vector from the given table column.
 TableVector (const TableVector< T > &)
 Create a table vector from another one (reference semantics)
 TableVector (const Vector< T > &)
 Create a table vector containing the given Vector (reference semantics).
 TableVector (uInt leng)
 Create a table vector containing a Vector with the given length.
 ~TableVector ()
 Destruct the object.
TableVector< T > & operator= (const TableVector< T > &)
 Assign a table vector to another one (copy semantics).
Bool isNull () const
 Test if the table vector is null, i.e.
void throwIfNull () const
 Throw an exception if the table vector is null, i.e.
void reference (const TableVector< T > &)
 Make a reference to the table vector of the other TableVector.
Vector< T > makeVector () const
 Make a (normal) Vector from a TableVector (copy semantics).
operator() (uInt index) const
 Get the value of a single pixel.
TableVector< T > & operator= (const T &)
 Set all elements to a value.
void set (const T &value)
void set (uInt index, const T &value)
 Put a value into a single pixel.
uInt ndim () const
 Get nr of dimensions (is always 1).
uInt nelements () const
 Get nr of elements (ie.
Bool conform (const TableVector< T > &) const
 Test if the shape of the given table vector conforms.
Bool conform (const Vector< T > &) const
 Test if the shape of the given vector conforms.
Bool ok () const
 Test if internal state is correct.
TabVecRep< T > & tabVec ()
 Return the TabVecRep reference.
const TabVecRep< T > & tabVec () const
 TableVector (TabVecRep< T > &)
 Create a TableVector from a TabVecRep as result of an operation.

Protected Member Functions

void destruct ()
 Destruct the object.

Protected Attributes

TabVecRep< T > * tabVecPtr_p

Detailed Description

template<class T>
class casa::TableVector< T >

Templated readonly table column vectors.

Intended use:

Public interface

Review Status

Reviewed By:
UNKNOWN
Date Reviewed:
before2004/08/25

Prerequisite

Etymology

TableVector allows to operate on a column in a readonly table as a vector.

Synopsis

A TableVector object is a read/write view of data in a Table. This means that the vector data can be changed if the underlying column is writable.

Table vectors can be used in the same way as the normal vectors. They allow to handle a column in a table as a vector. Many mathematical and logical operations are defined for them in TabVecMath.h and TabVecLogic.h. In fact, constructors exist to convert a TableColumn or a Vector object to a TableVector, so they can often directly be used in a table vector expression. There are 2 kinds of table vectors:

TableVector is implemented by referencing the counted TabVecRep object. A default constructor is defined to allow construction of an array of TableVector objects. However, it constructs an object not referencing anything. Functions like operator() 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.

Example

       // Create a table vector for column COL1.
       Table tab ("Table.data");
       TableVector<Int> tabvec(tab, "COL1");
       // Multiply it by a constant.
       // The result has to be stored in a TableVector,
       // since a TableVector cannot be written.
       TableVector<Int> temp = 2 * tabvec;

Motivation

It is very useful to be able to handle a column as a vector. To handle a column in a readonly table, a TableVector class is needed, otherwise output operations could not be forbidden.

To Do

Definition at line 118 of file TableVector.h.


Constructor & Destructor Documentation

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

The default constructor creates a null table vector.

This does not contain an actual vector and cannot be used until it references an actual vector (using function reference). Its sole purpose is to be able to construct an array of TableVectors. Note that operator(), 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::TableVector< T >::TableVector ( const Table ,
const String columnName 
)

Create a read/write table vector from the given table column name.

Only scalar columns are supported.

template<class T>
casa::TableVector< T >::TableVector ( const TableColumn column)

Create a read/write table vector from the given table column.

Only scalar columns are supported. This constructor converts a TableColumn to a TableVector and allows the use of TableColumn objects in table vector expressions.

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

Create a table vector from another one (reference semantics)

template<class T>
casa::TableVector< T >::TableVector ( const Vector< T > &  )

Create a table vector containing the given Vector (reference semantics).

This constructor converts a Vector to a TableVector and allows the use of Vector objects in table vector expressions.

template<class T>
casa::TableVector< T >::TableVector ( uInt  leng)

Create a table vector containing a Vector with the given length.

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

Destruct the object.

template<class T >
casa::TableVector< T >::TableVector ( TabVecRep< T > &  vec) [inline]

Create a TableVector from a TabVecRep as result of an operation.

Definition at line 259 of file TableVector.h.

References casa::TabVecRep< T >::link().


Member Function Documentation

template<class T >
Bool casa::TableVector< T >::conform ( const TableVector< T > &  vec) const [inline]

Test if the shape of the given table vector conforms.

Definition at line 237 of file TableVector.h.

References casa::TableVector< T >::tabVecPtr_p.

template<class T >
Bool casa::TableVector< T >::conform ( const Vector< T > &  vec) const [inline]

Test if the shape of the given vector conforms.

Definition at line 240 of file TableVector.h.

template<class T>
void casa::TableVector< T >::destruct ( ) [protected]

Destruct the object.

It decreases the reference count in the underlying object.

template<class T >
Bool casa::TableVector< T >::isNull ( ) const [inline]

Test if the table vector is null, i.e.

has no actual vector. This is the case if the default constructor has been used.

Definition at line 224 of file TableVector.h.

References casa::False, and casa::True.

template<class T>
Vector<T> casa::TableVector< T >::makeVector ( ) const

Make a (normal) Vector from a TableVector (copy semantics).

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

Get nr of dimensions (is always 1).

Definition at line 228 of file TableVector.h.

template<class T >
uInt casa::TableVector< T >::nelements ( ) const [inline]

Get nr of elements (ie.

vector length).

Definition at line 232 of file TableVector.h.

template<class T>
Bool casa::TableVector< T >::ok ( ) const

Test if internal state is correct.

template<class T >
T casa::TableVector< T >::operator() ( uInt  index) const [inline]

Get the value of a single pixel.

Definition at line 245 of file TableVector.h.

template<class T >
TableVector< T > & casa::TableVector< T >::operator= ( const TableVector< T > &  that) [inline]

Assign a table vector to another one (copy semantics).

The vectors must have equal length.

Definition at line 264 of file TableVector.h.

References casa::TableVector< T >::tabVec().

template<class T >
TableVector< T > & casa::TableVector< T >::operator= ( const T &  value) [inline]

Set all elements to a value.

Definition at line 281 of file TableVector.h.

template<class T>
void casa::TableVector< T >::reference ( const TableVector< T > &  )

Make a reference to the table vector of the other TableVector.

It will replace an already existing reference. It handles null objects correctly.

template<class T >
void casa::TableVector< T >::set ( const T &  value) [inline]

Definition at line 276 of file TableVector.h.

template<class T >
void casa::TableVector< T >::set ( uInt  index,
const T &  value 
) [inline]

Put a value into a single pixel.


tabvec(i) = value;

Definition at line 271 of file TableVector.h.

template<class T >
TabVecRep< T > & casa::TableVector< T >::tabVec ( ) [inline]
template<class T >
const TabVecRep< T > & casa::TableVector< T >::tabVec ( ) const [inline]

Definition at line 250 of file TableVector.h.

template<class T>
void casa::TableVector< T >::throwIfNull ( ) const

Throw an exception if the table vector is null, i.e.

if function isNull() is true.


Member Data Documentation

template<class T>
TabVecRep<T>* casa::TableVector< T >::tabVecPtr_p [protected]

Definition at line 207 of file TableVector.h.

Referenced by casa::TableVector< T >::conform().


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