casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Member Functions | Static Public Member Functions | Private Member Functions
casa::MappedArrayEngine< VirtualType, StoredType > Class Template Reference

Templated virtual column engine to map the data type of a table array. More...

#include <MappedArrayEngine.h>

Inheritance diagram for casa::MappedArrayEngine< VirtualType, StoredType >:
casa::BaseMappedArrayEngine< VirtualType, StoredType > casa::VirtualColumnEngine casa::VirtualArrayColumn< VirtualType > casa::DataManager casa::DataManagerColumn

List of all members.

Public Member Functions

 MappedArrayEngine (const String &virtualColumnName, const String &storedColumnName)
 Construct an engine to map all arrays in a column.
 MappedArrayEngine (const Record &spec)
 Construct from a record specification as created by dataManagerSpec().
 ~MappedArrayEngine ()
 Destructor is mandatory.
virtual String dataManagerType () const
 Return the type name of the engine (i.e.
virtual String dataManagerName () const
 Get the name given to the engine (is the virtual column name).
virtual Record dataManagerSpec () const
 Record a record containing data manager specifications.

Static Public Member Functions

static String className ()
 Return the name of the class.
static void registerClass ()
 Register the class name and the static makeObject "constructor".
static DataManagermakeObject (const String &dataManagerType, const Record &spec)
 Define the "constructor" to construct this engine when a table is read back.

Private Member Functions

 MappedArrayEngine (const MappedArrayEngine< VirtualType, StoredType > &)
 Copy constructor is only used by clone().
MappedArrayEngine< VirtualType,
StoredType > & 
operator= (const MappedArrayEngine< VirtualType, StoredType > &)
 Assignment is not needed and therefore forbidden (so it is made private and not implemented).
DataManagerclone () const
 Clone the engine object.
virtual void mapOnGet (Array< VirtualType > &array, const Array< StoredType > &stored)
 Copy the stored array to the virtual array.
virtual void mapOnPut (const Array< VirtualType > &array, Array< StoredType > &stored)
 Copy the virtual array to the stored array.

Detailed Description

template<class VirtualType, class StoredType>
class casa::MappedArrayEngine< VirtualType, StoredType >

Templated virtual column engine to map the data type of a table array.

Intended use:

Public interface

Review Status

Reviewed By:
Gareth Hunt
Date Reviewed:
94Nov17

Prerequisite

Synopsis

MappedArrayEngine is a virtual column engine which maps an array of one type to another type (without any scaling).

An engine object should be used for one column only, because the stored column name is part of the engine. If it would be used for more than one column, they would all share the same stored column. When the engine is bound to a column, it is checked if the name of that column matches the given virtual column name.

The engine can be used for a column containing any kind of array (thus direct or indirect, fixed or variable shaped)) as long as the virtual array can be stored in the stored array. Thus a fixed shaped virtual can use a variable shaped stored, but not vice versa. A fixed shape indirect virtual can use a stored with direct arrays.

Motivation

For precision it is sometimes needed to store the visibility data in a MeasurementSet in double precision. To be able to use other applications on such data, it is needed to map them to single precision.

Because the engine can serve only one column, it was possible to combine the engine and the column functionality in one class. This has been achieved using multiple inheritance. The advantage of this is that only one templated class is used, so less template instantiations are needed.

Example

    // Create the table description and 2 columns with indirect arrays in it.
    // The Int column will be stored, while the double will be
    // used as virtual.
    TableDesc tableDesc ("", TableDesc::Scratch);
    tableDesc.addColumn (ArrayColumnDesc<Int> ("storedArray"));
    tableDesc.addColumn (ArrayColumnDesc<double> ("virtualArray"));
   
    // Create a new table using the table description.
    SetupNewTable newtab (tableDesc, "tab.data", Table::New);
   
    // Create the array mapping engine to map from double to Int
    // and bind it to the double column.
    // Create the table.
    MappedArrayEngine<double,Int> mappingEngine("virtualArray",
                                                "storedArray", 10);
    newtab.bindColumn ("virtualArray", mappingEngine);
    Table table (newtab);
   
    // Store a 3-D array (with dim. 2,3,4) into each row of the column.
    // The shape of each array in the column is implicitly set by the put
    // function. This will also set the shape of the underlying Int array.
    ArrayColumn data (table, "virtualArray");
    Array<double> someArray(IPosition(4,2,3,4));
    someArray = 0;
    for (uInt i=0, i<10; i++) {          // table will have 10 rows
        table.addRow();
        data.put (i, someArray)
    }

Template Type Argument Requirements (VirtualType)

Template Type Argument Requirements (StoredType)

Definition at line 121 of file MappedArrayEngine.h.


Constructor & Destructor Documentation

template<class VirtualType , class StoredType >
casa::MappedArrayEngine< VirtualType, StoredType >::MappedArrayEngine ( const String virtualColumnName,
const String storedColumnName 
)

Construct an engine to map all arrays in a column.

StoredColumnName is the name of the column where the mapped data will be put and must have data type StoredType. The virtual column using this engine must have data type VirtualType.

template<class VirtualType , class StoredType >
casa::MappedArrayEngine< VirtualType, StoredType >::MappedArrayEngine ( const Record spec)

Construct from a record specification as created by dataManagerSpec().

template<class VirtualType , class StoredType >
casa::MappedArrayEngine< VirtualType, StoredType >::~MappedArrayEngine ( )

Destructor is mandatory.

template<class VirtualType , class StoredType >
casa::MappedArrayEngine< VirtualType, StoredType >::MappedArrayEngine ( const MappedArrayEngine< VirtualType, StoredType > &  ) [private]

Copy constructor is only used by clone().

(so it is made private).


Member Function Documentation

template<class VirtualType , class StoredType >
static String casa::MappedArrayEngine< VirtualType, StoredType >::className ( ) [static]

Return the name of the class.

This includes the names of the template arguments.

template<class VirtualType , class StoredType >
DataManager* casa::MappedArrayEngine< VirtualType, StoredType >::clone ( ) const [private, virtual]

Clone the engine object.

Implements casa::DataManager.

template<class VirtualType , class StoredType >
virtual String casa::MappedArrayEngine< VirtualType, StoredType >::dataManagerName ( ) const [virtual]

Get the name given to the engine (is the virtual column name).

Reimplemented from casa::DataManager.

template<class VirtualType , class StoredType >
virtual Record casa::MappedArrayEngine< VirtualType, StoredType >::dataManagerSpec ( ) const [virtual]

Record a record containing data manager specifications.

Reimplemented from casa::DataManager.

template<class VirtualType , class StoredType >
virtual String casa::MappedArrayEngine< VirtualType, StoredType >::dataManagerType ( ) const [virtual]

Return the type name of the engine (i.e.

its class name).

Implements casa::DataManager.

template<class VirtualType , class StoredType >
static DataManager* casa::MappedArrayEngine< VirtualType, StoredType >::makeObject ( const String dataManagerType,
const Record spec 
) [static]

Define the "constructor" to construct this engine when a table is read back.

This "constructor" has to be registered by the user of the engine. If the engine is commonly used, its registration can be added to the registerAllCtor function in DataManReg.cc. That function gets automatically invoked by the table system.

template<class VirtualType , class StoredType >
virtual void casa::MappedArrayEngine< VirtualType, StoredType >::mapOnGet ( Array< VirtualType > &  array,
const Array< StoredType > &  stored 
) [private, virtual]

Copy the stored array to the virtual array.

Reimplemented from casa::BaseMappedArrayEngine< VirtualType, StoredType >.

template<class VirtualType , class StoredType >
virtual void casa::MappedArrayEngine< VirtualType, StoredType >::mapOnPut ( const Array< VirtualType > &  array,
Array< StoredType > &  stored 
) [private, virtual]

Copy the virtual array to the stored array.

Reimplemented from casa::BaseMappedArrayEngine< VirtualType, StoredType >.

template<class VirtualType , class StoredType >
MappedArrayEngine<VirtualType,StoredType>& casa::MappedArrayEngine< VirtualType, StoredType >::operator= ( const MappedArrayEngine< VirtualType, StoredType > &  ) [private]

Assignment is not needed and therefore forbidden (so it is made private and not implemented).

template<class VirtualType , class StoredType >
static void casa::MappedArrayEngine< VirtualType, StoredType >::registerClass ( ) [static]

Register the class name and the static makeObject "constructor".

This will make the engine known to the table system. The automatically invoked registration function in DataManReg.cc contains MappedArrayEngine<double,Int>. Any other instantiation of this class must be registered "manually" (or added to DataManReg.cc).


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