VirtColEng.h

Classes

VirtualColumnEngine -- Abstract base class for virtual column handling (full description)

class VirtualColumnEngine : public DataManager

Interface

Public Members
VirtualColumnEngine()
virtual ~VirtualColumnEngine()
Private Members
VirtualColumnEngine (const VirtualColumnEngine& that)
VirtualColumnEngine& operator= (const VirtualColumnEngine&)
Bool isStorageManager() const
virtual Bool flush (AipsIO&, Bool fsync)
virtual void resync (uInt nrrow)
virtual void create (uInt initialNrrow)
virtual void open (uInt nrrow, AipsIO& mainTableFile)
virtual void prepare()
virtual void deleteManager()
virtual DataManagerColumn* makeScalarColumn (const String& columnName, int dataType, const String& dataTypeId)
virtual DataManagerColumn* makeDirArrColumn (const String& columnName, int dataType, const String& dataTypeId)
virtual DataManagerColumn* makeIndArrColumn (const String& columnName, int dataType, const String& dataTypeId)

Description

Prerequisite

Etymology

VirtualColumnEngine is the abstract data manager class for specialized classes (engines) handling a group of virtual columns.

Synopsis

VirtualColumnEngine is the data manager for classes handling a group of virtual columns in tables. It is an abstract base class for the specialized virtual column engines. Each virtual column as such is represented by a class which has to be derived from the abstract base classes VirtualScalarColumn or VirtualArrayColumn. The engine has to create the various column objects via the functions makeXXXColumn.

Initialization of the virtual column engine is done by the functions create (for new tables), open (for existing tables) and prepare. The engine can be flushed by the function flush, which allows to write some data. The function open can read these data back. VirtualColumnEngine is closely related with the table system.

A number of (pure) virtual functions have been defined. The pure virtual functions must be implemented in the derived class. The non-pure virtual functions have a default implementation throwing a "not possible" exception. They need to be implemented if they are used for this engine (e.g. makeIndArrColumn does not need to be implemented if the engine does not handle arrays). Furthermore the pure virtual function dataManagerType (defined in DataManager.h) has to be implemented. This should return the name of the data manager, which is usually its class name. This name has to be unique; so if the engine is templated, the template parameter has to be part of the data manager name.

The engine has to be registered before it can be used by the table system. This means that a special makeObject function has to be made known to the table system, which allows the table system to reconstruct the engine using its name.

An example of a virtual column engine can be found in dVirtColEng.{h,cc} in the test directory of the Tables module. Another exanple is class ScaledArray.

Motivation

It is nice if a table column can be expressed as a function of other columns (maybe even in other tables). A virtual column provides this functionality in a very flexible way. A specialized class can calculate the data of a virtual column, but a common base class is required to interface it to the table system.

To Do

Member Description

VirtualColumnEngine()

Create the object.

virtual ~VirtualColumnEngine()

VirtualColumnEngine (const VirtualColumnEngine& that)

The copy constructor cannot be used for this base class. The clone function should be used instead. The private declaration of this constructor makes it unusable.

VirtualColumnEngine& operator= (const VirtualColumnEngine&)

Assignment cannot be used for this base class. The private declaration of this operator makes it unusable.

Bool isStorageManager() const

The data manager is not a storage manager?

virtual Bool flush (AipsIO&, Bool fsync)

Flush the data in the engine object. If the object contains persistent data, this is the place to write them. This can be done in two ways:

Another way of storing information is by storing it as a keyword in the table. In this case it is important to know that close is called AFTER the keywords are written. Thus, in this way the information has to be stored and read back in create, open and/or prepare. It returns a True status if it had to flush (i.e. if data have changed).
The default implementation does nothing and returns False.

virtual void resync (uInt nrrow)

Resync the storage manager with the new file contents. This is done by clearing the cache. The default implementation does nothing.

virtual void create (uInt initialNrrow)

Initialize the object for a new table containing initially nrrow rows. It can be used to initialize variables (possibly using data from other columns in the table). The default implementation does nothing.

virtual void open (uInt nrrow, AipsIO& mainTableFile)

Initialize the object for an existing table containing nrrow rows. It can be used to read values back (written by close) and/or to initialize variables (possibly using data from other columns in the table). The default implementation does nothing.

virtual void prepare()

Let the data manager initialize itself further. Prepare is called after create/open has been called for all columns. In this way one can be sure that referenced columns are read back and partly initialized. The default implementation does nothing.

virtual void deleteManager()

The data manager will be deleted (because all its columns are requested to be deleted). So clean up the things needed (e.g. delete files). By default it assumes that nothing has to be done.

virtual DataManagerColumn* makeScalarColumn (const String& columnName, int dataType, const String& dataTypeId)

Make a column object in the engine on behalf of a table column. This column object class is derived from VirtualScalarColumn or VirtualArrayColumn. It handles the gets and puts of data.

Create a scalar column. The default implementation throws an exception that it cannot do it for this column.

virtual DataManagerColumn* makeDirArrColumn (const String& columnName, int dataType, const String& dataTypeId)

Make a column object in the engine on behalf of a table column. This column object class is derived from VirtualScalarColumn or VirtualArrayColumn. It handles the gets and puts of data.

Create a direct array column. The default implementation calls makeIndArrColumn (when reading the user sees no difference between direct and indirect).

virtual DataManagerColumn* makeIndArrColumn (const String& columnName, int dataType, const String& dataTypeId)

Make a column object in the engine on behalf of a table column. This column object class is derived from VirtualScalarColumn or VirtualArrayColumn. It handles the gets and puts of data.

Create an indirect array column. The default implementation throws an exception that it cannot do it for this column.