TVec.h

Classes

Global Functions -- Enumeration of possible table vectors (full description)
TabVecRep -- Templated base class for table vectors (full description)

Enumeration of possible table vectors (source)

Types

enum TabVecTag

TagScaCol = 1
Table Vector is a scalar column
TagTemp = 2
Table Vector is a temporary vector (i.e. a regular vector).

Interface

Description

Synopsis

Define the type of table vectors. Alas, this enum has to be defined outside the class, because some compilers do not support an enum in a templated class.

Member Description

enum TabVecTag


class TabVecRep

Interface

Public Members
TabVecRep()
virtual ~TabVecRep()
inline uInt ndim() const
inline uInt nelements() const
inline Bool conform(const TabVecRep<T>&) const
inline Bool conform(const Vector<T>&) const
Bool ok() const
inline TabVecRep<T>* link()
inline uInt unlink()
inline TabVecTag getTag() const
virtual T value (uInt index) const = 0
virtual void getVal (uInt index, T&) const = 0
virtual void putVal (uInt index, const T&) = 0
virtual void set (const T&) = 0
virtual void assign (const TabVecRep<T>&)
Protected Members
virtual uInt nelem() const
Public Members
void validateConformance (uInt) const
void* newVec() const

Description

Prerequisite

Etymology

TabVecRep is the representation of a table vector.

Synopsis

TabVecRep is the counted referenced letter class for the envelope class TableVector. It is an abstract base class for the actual table vector classes TabVecScaCol and TabVecTemp.

All operations defined for TableVector are immediately passed to the corresponding virtual TabVecRep function. The header files TVecMath.h and TVecLogic.h declare all the mathematical and logical functions for TabVecRep.

Motivation

A virtual function call only works when used with an object pointer or reference. To allow the use of virtual functions in value objects, an extra level of indirection is used. This is called the letter/envelope idiom and is described in "Advanced C++" by J. Coplien. Class TableVector is the envelope to the letters TabVecRep and its derivations.

To Do

Member Description

TabVecRep()

Create empty table vector. TabVecRep cannot be contructed by the user, because it is an abstract base class (it contains pure virtual functions).

virtual ~TabVecRep()

Destruct the object.

inline uInt ndim() const

Get nr of dimensions.

inline uInt nelements() const

Get nr of elements (ie. vector length).

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

Test if vector shape conforms another table vector.

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

Test if vector shape conforms another vector.

Bool ok() const

Check internal consistency.

inline TabVecRep<T>* link()

Increments the reference count.

inline uInt unlink()

Decrements the reference count and returns the resulting count.

inline TabVecTag getTag() const

Get the tag (the type of vector).

virtual T value (uInt index) const = 0

Get a value.

virtual void getVal (uInt index, T&) const = 0

Get a value.

virtual void putVal (uInt index, const T&) = 0

Put a value.

virtual void set (const T&) = 0

Set entire vector to a value.

virtual void assign (const TabVecRep<T>&)

Set to another table vector.

virtual uInt nelem() const

Get nr of elements.

void validateConformance (uInt) const

Check if vectors are comformant.

void* newVec() const

Create a new temporary vector (for result of math operations). TabVecTemp& cannot be used, because the template instantiation mechanism instantiates TabVecTemp, which depends on TabVecRep and therefore gives errors.