Loading...
Searching...
No Matches
casacore::TableVector< T > Class Template Reference
tables package (libcasa_tables) » Tables_module

More...

`#include <TableVector.h>`

## 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 (rownr_t 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).
T | operator() (rownr_t 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 (rownr_t index, const T &value)
| Put a value into a single pixel.
uInt | ndim () const
| Get nr of dimensions (is always 1).
rownr_t | 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 casacore::TableVector< T >

Templated readonly table column vectors

### Intended use:

Public interface

### Review Status

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

### Prerequisite

- Vector
- Table

### 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:

- A table vector representing a scalar column in a table. The data types of the vector and the column must conform. A temporary vector, which is held in memory. These are usually the result of operations on 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;
casacore::TableVector::TableVector
TableVector()
The default constructor creates a null table vector.
casacore::Table
Definition Table.h:157

### 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

- derive from Lattice one day
- support slicing
- support table array columns
- do we ever need Row vectors?

Definition at line 116 of file TableVector.h.

## Constructor & Destructor Documentation

## TableVector() [1/7]

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.

Referenced by conform(), makeVector(), operator=(), operator=(), reference(), TableVector(), and ~TableVector().

## TableVector() [2/7]

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.

## TableVector() [3/7]

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.

## TableVector() [4/7]

template<class T>

casacore::TableVector< T >::TableVector | ( | const TableVector< T > & |  | ) |

Create a table vector from another one (reference semantics).

References TableVector().

## TableVector() [5/7]

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.

## TableVector() [6/7]

template<class T>

casacore::TableVector< T >::TableVector | ( | rownr_t | leng | ) |

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

## ~TableVector()

template<class T>

casacore::TableVector< T >::~TableVector | ( |  | ) |

Destruct the object.

References TableVector().

## TableVector() [7/7]

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 257 of file TableVector.h.

References casacore::TabVecRep< T >::link(), and tabVecPtr_p.

## Member Function Documentation

## conform() [1/2]

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 235 of file TableVector.h.

References TableVector(), and tabVecPtr_p.

## conform() [2/2]

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 238 of file TableVector.h.

References tabVecPtr_p.

## destruct()

template<class T>

void casacore::TableVector< T >::destruct | ( |  | ) |

protected

Destruct the object.

It decreases the reference count in the underlying object.

## isNull()

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 222 of file TableVector.h.

References casacore::False, tabVecPtr_p, and casacore::True.

## makeVector()

template<class T>

Vector< T > casacore::TableVector< T >::makeVector | ( |  | ) | const

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

References casacore::NewDelAllocator< T >::value, and TableVector().

## ndim()

template<class T>

uInt casacore::TableVector< T >::ndim | ( |  | ) | const

inline

Get nr of dimensions (is always 1).

Definition at line 226 of file TableVector.h.

References tabVecPtr_p.

## nelements()

template<class T>

rownr_t casacore::TableVector< T >::nelements | ( |  | ) | const

inline

Get nr of elements (ie.

vector length).

Definition at line 230 of file TableVector.h.

References tabVecPtr_p.

## ok()

template<class T>

Bool casacore::TableVector< T >::ok | ( |  | ) | const

Test if internal state is correct.

## operator()()

template<class T>

T casacore::TableVector< T >::operator() | ( | rownr_t | index | ) | const

inline

Get the value of a single pixel.

Definition at line 243 of file TableVector.h.

References tabVecPtr_p.

## operator=() [1/2]

template<class T>

TableVector< T > & casacore::TableVector< T >::operator= | ( | const T & | value | ) |

inline

Set all elements to a value.

Definition at line 279 of file TableVector.h.

References casacore::NewDelAllocator< T >::value, TableVector(), and tabVecPtr_p.

## operator=() [2/2]

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 262 of file TableVector.h.

References TableVector(), tabVec(), and tabVecPtr_p.

## reference()

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.

References TableVector().

## set() [1/2]

template<class T>

void casacore::TableVector< T >::set | ( | const T & | value | ) |

inline

Definition at line 274 of file TableVector.h.

References casacore::NewDelAllocator< T >::value, and tabVecPtr_p.

## set() [2/2]

template<class T>

void casacore::TableVector< T >::set | ( | rownr_t | index,
|  | const T & | value )

inline

Put a value into a single pixel.

tabvec(i) = value;

Definition at line 269 of file TableVector.h.

References casacore::NewDelAllocator< T >::value, and tabVecPtr_p.

## tabVec() [1/2]

template<class T>

TabVecRep< T > & casacore::TableVector< T >::tabVec | ( |  | ) |

inline

Return the TabVecRep reference.

Definition at line 251 of file TableVector.h.

References tabVecPtr_p.

Referenced by casacore::crossProduct(), casacore::indgen(), casacore::indgen(), casacore::indgen(), casacore::innerProduct(), casacore::max(), casacore::min(), casacore::minMax(), casacore::norm(), operator=(), casacore::pow(), casacore::product(), and casacore::sum().

## tabVec() [2/2]

template<class T>

const TabVecRep< T > & casacore::TableVector< T >::tabVec | ( |  | ) | const

inline

Definition at line 248 of file TableVector.h.

References tabVecPtr_p.

## throwIfNull()

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

## tabVecPtr_p

template<class T>

TabVecRep<T>* casacore::TableVector< T >::tabVecPtr_p

protected

Definition at line 205 of file TableVector.h.

Referenced by conform(), conform(), isNull(), ndim(), nelements(), operator()(), operator=(), operator=(), set(), set(), TableVector(), tabVec(), and tabVec().

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

- tables/Tables/TableVector.h