TableVector.h

Classes

ROTableVector -- Templated readonly table column vectors (full description)
TableVector -- Templated read/write table column vectors (full description)

class ROTableVector

Interface

Public Members
ROTableVector()
ROTableVector (const Table&, const String& columnName)
ROTableVector (const ROTableColumn& column)
ROTableVector (const ROTableVector<T>&)
ROTableVector (const Vector<T>&)
~ROTableVector()
inline Bool isNull() const
void throwIfNull() const
void reference (const ROTableVector<T>&)
Vector<T> makeVector() const
inline T operator() (uInt index) const
inline uInt ndim() const
inline uInt nelements() const
inline Bool conform (const ROTableVector<T>&) const
inline Bool conform (const Vector<T>&) const
Bool ok() const
Protected Members
void checkLink()
void destruct()
Private Members
ROTableVector<T>& operator=(const ROTableVector<T>&)
Public Members
inline const TabVecRep<T>& tabVec() const

Description

Review Status

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

Prerequisite

Etymology

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

Synopsis

A ROTableVector object is a readonly view of data in a Table. This means that the vector data is readonly and cannot be changed.

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 ROTableColumn or a Vector object to a ROTableVector, so they can often directly be used in a table vector expression. There are 2 kinds of table vectors:

ROTableVector is implemented by referencing the counted TabVecRep object. A default constructor is defined to allow construction of an array of ROTableVector objects. However, this 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");
    ROTableVector<Int> tabvec(tab, "COL1");
    // Multiply it by a constant.
    // The result has to be stored in a TableVector,
    // since a ROTableVector 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 ROTableVector class is needed, otherwise output operations could not be forbidden.

To Do

Member Description

ROTableVector()

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

ROTableVector (const Table&, const String& columnName)

Create a readonly table vector from the given table column name. Only scalar columns are supported.

ROTableVector (const ROTableColumn& column)

Create a readonly table vector from the given table column. Only scalar columns are supported. This constructor converts a ROTableColumn to a ROTableVector and allows the use of ROTableColumn objects in table vector expressions.

ROTableVector (const ROTableVector<T>&)

Create a table vector from another one (reference semantics)

ROTableVector (const Vector<T>&)

Create table vector containing given Vector (reference semantics) This constructor converts a Vector to a ROTableVector and allows the use of Vector objects in table vector expressions.

~ROTableVector()

Destruct the object.

inline Bool isNull() const

Test if the table vector is null, i.e. has no actual vector. This is the case if the default constructor has been used.

void throwIfNull() const

Throw an exception if the table vector is null, i.e. if function isNull() is true.

void reference (const ROTableVector<T>&)

Make a reference to the table vector of the other ROTableVector. It will replace an already existing reference. It handles null objects correctly.

Vector<T> makeVector() const

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

inline T operator() (uInt index) const

Get the value of a single pixel.

inline uInt ndim() const

Get nr of dimensions (is always 1).

inline uInt nelements() const

Get nr of elements (ie. vector length).

inline Bool conform (const ROTableVector<T>&) const

Test if the shape of the given table vector conforms.

inline Bool conform (const Vector<T>&) const

Test if the shape of the given vector conforms.

Bool ok() const

Test if internal state is correct.

void checkLink()

Check if a new TabxxxVec succeeded; if so, link to it.

void destruct()

Destruct the object. It decreases the reference count in the underlying object.

ROTableVector<T>& operator=(const ROTableVector<T>&)

Assigning to a ROTableVector is impossible, because the vector is readonly.

inline const TabVecRep<T>& tabVec() const

Return the TabVecRep reference.

class TableVector : public ROTableVector<T>

Interface

TableVector()
TableVector (const Table&, const String&)
TableVector (const TableColumn&)
TableVector (const TableVector<T>&)
TableVector (const Vector<T>&)
TableVector (uInt leng)
~TableVector()
void reference (const TableVector<T>&)
inline TableVector<T>& operator= (const TableVector<T>&)
inline TableVector<T>& operator= (const ROTableVector<T>&)
inline TableVector<T>& operator= (const T&)
inline void set (const T& value)
inline void set (uInt index, const T& value)
inline TabVecRep<T>& tabVec()
inline TableVector (TabVecRep<T>&)

Description

Review Status

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

Prerequisite

Etymology

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

Synopsis

TableVector is similar to class ROTableVector. The only difference is that it references a column in a Table object, so it can be written.

Example

    // Create a table vector for column COL1.
    Table tab ("Table.data");
    TableVector<Int> tabvec(tab, "COL1");
    // Multiply it by a constant.
    // The result is stored back in the vector, thus in the
    // underlying column.
    tabvec *= 2;

Motivation

It is very useful to be able to handle a column as a vector. It allows to manipulate the data in a very convenient way.

Template Type Argument Requirements (T)

To Do

Member Description

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

TableVector (const Table&, const String&)

Create a table vector from the given table column name. Only scalar columns are supported.

TableVector (const TableColumn&)

Create a table vector from the given table column. Only scalar columns are supported.

TableVector (const TableVector<T>&)

Create a table vector from another one (reference semantics)

TableVector (const Vector<T>&)

Create table vector containing given Vector (reference semantics)

TableVector (uInt leng)

Create table vector containing a Vector with given length.

~TableVector()

Destruct the object.

void reference (const TableVector<T>&)

Make a reference to another TableVector.

inline TableVector<T>& operator= (const TableVector<T>&)
inline TableVector<T>& operator= (const ROTableVector<T>&)

Assign a table vector to another one (copy semantics)

inline TableVector<T>& operator= (const T&)
inline void set (const T& value)

Set all elements to a value.

inline void set (uInt index, const T& value)

Put a value into a single pixel.
tabvec(i) = value;

inline TabVecRep<T>& tabVec()

Return the TabVecRep reference.

inline TableVector (TabVecRep<T>&)

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