casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
casacore::TableVector< T > Class Template Reference

Templated readonly table column vectors. More...

#include <TableVector.h>

Public Member Functions

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

Protected Member Functions

void destruct ()
 Destruct the object. More...
 

Protected Attributes

TabVecRep< T > * tabVecPtr_p
 

Detailed Description

template<class T>
class casacore::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>
casacore::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>
casacore::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>
casacore::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>
casacore::TableVector< T >::TableVector ( const TableVector< T > &  )

Create a table vector from another one (reference semantics)

template<class T>
casacore::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>
casacore::TableVector< T >::TableVector ( uInt  leng)

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

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

Destruct the object.

template<class T >
casacore::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 casacore::TabVecRep< T >::link().

Member Function Documentation

template<class T >
Bool casacore::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 casacore::TableVector< T >::tabVecPtr_p.

template<class T >
Bool casacore::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 casacore::TableVector< T >::destruct ( )
protected

Destruct the object.

It decreases the reference count in the underlying object.

template<class T >
Bool casacore::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 casacore::False, and casacore::True.

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

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

template<class T >
uInt casacore::TableVector< T >::ndim ( ) const
inline

Get nr of dimensions (is always 1).

Definition at line 228 of file TableVector.h.

template<class T >
uInt casacore::TableVector< T >::nelements ( ) const
inline

Get nr of elements (ie.

vector length).

Definition at line 232 of file TableVector.h.

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

Test if internal state is correct.

template<class T >
T casacore::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 > & casacore::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 casacore::TableVector< T >::tabVec().

template<class T >
TableVector< T > & casacore::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 casacore::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 casacore::TableVector< T >::set ( const T &  value)
inline

Definition at line 276 of file TableVector.h.

template<class T >
void casacore::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 > & casacore::TableVector< T >::tabVec ( )
inline
template<class T >
const TabVecRep< T > & casacore::TableVector< T >::tabVec ( ) const
inline

Definition at line 250 of file TableVector.h.

template<class T>
void casacore::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>* casacore::TableVector< T >::tabVecPtr_p
protected

Definition at line 207 of file TableVector.h.

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


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