casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
casacore::VSCEngine< T > Class Template Reference

Base virtual column for a scalar column with any type. More...

#include <VSCEngine.h>

Inheritance diagram for casacore::VSCEngine< T >:
casacore::VirtualColumnEngine casacore::VirtualScalarColumn< T > casacore::DataManager casacore::DataManagerColumn

Public Member Functions

 VSCEngine ()
 The default constructor is required for reconstruction of the engine when a table is read back. More...
 
 VSCEngine (const String &sourceColumnName)
 Construct an engine to handle a column with an arbitrary data type. More...
 
 ~VSCEngine ()
 Destructor is mandatory. More...
 
String dataManagerType () const
 Return the data manager type name. More...
 
const StringsourceColumnName () const
 Get the name of the source column. More...
 
- Public Member Functions inherited from casacore::VirtualColumnEngine
 VirtualColumnEngine ()
 Create the object. More...
 
virtual ~VirtualColumnEngine ()
 
- Public Member Functions inherited from casacore::DataManager
 DataManager ()
 Default constructor. More...
 
virtual ~DataManager ()
 
virtual DataManagerclone () const =0
 Make a clone of the derived object. More...
 
virtual String dataManagerName () const
 Return the name of the data manager. More...
 
void dataManagerInfo (Record &info) const
 Add SEQNR and SPEC (the DataManagerSpec subrecord) to the info. More...
 
virtual Record dataManagerSpec () const
 Return a record containing data manager specifications. More...
 
virtual Record getProperties () const
 Get data manager properties that can be modified. More...
 
virtual void setProperties (const Record &spec)
 Modify data manager properties given in record fields. More...
 
virtual Bool canReallocateColumns () const
 Tell if the data manager wants to reallocate the data manager column objects. More...
 
virtual DataManagerColumnreallocateColumn (DataManagerColumn *column)
 Reallocate the column object if it is part of this data manager. More...
 
uInt sequenceNr () const
 Get the (unique) sequence nr of this data manager. More...
 
uInt ncolumn () const
 Get the nr of columns in this data manager (can be zero). More...
 
Bool asBigEndian () const
 Have the data to be stored in big or little endian canonical format? More...
 
const TSMOptiontsmOption () const
 Get the TSM option. More...
 
MultiFileBasemultiFile ()
 Get the MultiFile pointer (can be 0). More...
 
String keywordName (const String &keyword) const
 Compose a keyword name from the given keyword appended with the sequence number (e.g. More...
 
String fileName () const
 Compose a unique filename from the table name and sequence number. More...
 
ByteIO::OpenOption fileOption () const
 Get the AipsIO option of the underlying file. More...
 
virtual Bool isRegular () const
 Is this a regular storage manager? It is regular if it allows addition of rows and writing data in them. More...
 
Tabletable () const
 Get the table this object is associated with. More...
 
virtual void reopenRW ()
 Reopen the data manager for read/write access. More...
 
virtual Bool canAddColumn () const
 Does the data manager allow to add columns? (default no) More...
 
virtual Bool canRemoveColumn () const
 Does the data manager allow to delete columns? (default no) More...
 
virtual Bool canRenameColumn () const
 Does the data manager allow to rename columns? (default yes) More...
 
virtual void setMaximumCacheSize (uInt nbytes)
 Set the maximum cache size (in bytes) to be used by a storage manager. More...
 
virtual void showCacheStatistics (std::ostream &) const
 Show the data manager's IO statistics. More...
 
DataManagerColumncreateScalarColumn (const String &columnName, int dataType, const String &dataTypeId)
 Create a column in the data manager on behalf of a table column. More...
 
DataManagerColumncreateDirArrColumn (const String &columnName, int dataType, const String &dataTypeId)
 Create a direct array column. More...
 
DataManagerColumncreateIndArrColumn (const String &columnName, int dataType, const String &dataTypeId)
 Create an indirect array column. More...
 
DataManagergetClone () const
 Has the object already been cloned? More...
 
void setClone (DataManager *clone) const
 Set the pointer to the clone. More...
 
- Public Member Functions inherited from casacore::VirtualScalarColumn< T >
 VirtualScalarColumn ()
 Create a column. More...
 
virtual ~VirtualScalarColumn ()
 Frees up the storage. More...
 
int dataType () const
 Return the data type of the column. More...
 
String dataTypeId () const
 Return the data type Id of the column. More...
 
virtual void get (uInt rownr, T &data)=0
 Get the scalar value in the given row. More...
 
virtual void put (uInt rownr, const T &data)
 Put the scalar value into the given row. More...
 
- Public Member Functions inherited from casacore::DataManagerColumn
 DataManagerColumn ()
 Create a column. More...
 
virtual ~DataManagerColumn ()
 Frees up the storage. More...
 
void setIsFixedShape (Bool isFixedShape)
 Set the isFixedShape flag. More...
 
Bool isFixedShape () const
 Is this a fixed shape column? More...
 
virtual void setMaxLength (uInt maxLength)
 Set the maximum length of the value (can be used for strings). More...
 
void setFixedShapeColumn (const IPosition &shape)
 Set the shape of all (fixed-shaped) arrays in the column. More...
 
virtual void setShape (uInt rownr, const IPosition &shape)
 Set the shape of an (variable-shaped) array in the given row. More...
 
virtual void setShapeTiled (uInt rownr, const IPosition &shape, const IPosition &tileShape)
 Set the shape and tile shape of an (variable-shaped) array in the given row. More...
 
virtual Bool isShapeDefined (uInt rownr)
 Is the value shape defined in the given row? By default it returns True. More...
 
virtual uInt ndim (uInt rownr)
 Get the dimensionality of the item in the given row. More...
 
virtual IPosition shape (uInt rownr)
 Get the shape of the item in the given row. More...
 
virtual IPosition tileShape (uInt rownr)
 Get the tile shape of the item in the given row. More...
 
virtual Bool canChangeShape () const
 Can the data manager handle chaging the shape of an existing array? Default is no. More...
 
virtual Bool canAccessScalarColumnCells (Bool &reask) const
 Can the column data manager handle access to a clooection of cells in a scalar column? If not, the caller should access the column cells by looping through the cells in the column. More...
 
virtual Bool canAccessArrayColumn (Bool &reask) const
 Can the column data manager handle access to a scalar column? If not, the caller should access the column by looping through all cells in the column. More...
 
virtual Bool canAccessArrayColumnCells (Bool &reask) const
 Can the column data manager handle access to a collection of cells in an array column? If not, the caller should access the column cells by looping through the cells in the column. More...
 
virtual Bool canAccessSlice (Bool &reask) const
 Can the column data manager handle access to a cell slice? If not, the caller should do slicing itself (by accessing the entire array and slicing it). More...
 
virtual Bool canAccessColumnSlice (Bool &reask) const
 Can the column data manager handle access to a column slice? If not, the caller should access the column slice by looping through all cell slices in the column. More...
 
ColumnCachecolumnCache ()
 Get access to the ColumnCache object. More...
 
const ColumnCachecolumnCachePtr () const
 
void get (uInt rownr, Bool *dataPtr)
 Get the scalar value in the given row. More...
 
void get (uInt rownr, uChar *dataPtr)
 
void get (uInt rownr, Short *dataPtr)
 
void get (uInt rownr, uShort *dataPtr)
 
void get (uInt rownr, Int *dataPtr)
 
void get (uInt rownr, uInt *dataPtr)
 
void get (uInt rownr, Int64 *dataPtr)
 
void get (uInt rownr, float *dataPtr)
 
void get (uInt rownr, double *dataPtr)
 
void get (uInt rownr, Complex *dataPtr)
 
void get (uInt rownr, DComplex *dataPtr)
 
void get (uInt rownr, String *dataPtr)
 
void get (uInt rownr, void *dataPtr)
 This function is the get for all non-standard data types. More...
 
void put (uInt rownr, const Bool *dataPtr)
 Put the scalar value into the given row. More...
 
void put (uInt rownr, const uChar *dataPtr)
 
void put (uInt rownr, const Short *dataPtr)
 
void put (uInt rownr, const uShort *dataPtr)
 
void put (uInt rownr, const Int *dataPtr)
 
void put (uInt rownr, const uInt *dataPtr)
 
void put (uInt rownr, const Int64 *dataPtr)
 
void put (uInt rownr, const float *dataPtr)
 
void put (uInt rownr, const double *dataPtr)
 
void put (uInt rownr, const Complex *dataPtr)
 
void put (uInt rownr, const DComplex *dataPtr)
 
void put (uInt rownr, const String *dataPtr)
 
void put (uInt rownr, const void *dataPtr)
 This function is the put for all non-standard data types. More...
 
virtual void getScalarColumnCellsV (const RefRows &rownrs, void *dataPtr)
 Get some scalar values in the column. More...
 
virtual void putScalarColumnCellsV (const RefRows &rownrs, const void *dataPtr)
 Put some scalar values in the column. More...
 
virtual void getArrayV (uInt rownr, void *dataPtr)
 Get the array value in the given row. More...
 
virtual void putArrayV (uInt rownr, const void *dataPtr)
 Put the array value into the given row. More...
 
virtual void getArrayColumnV (void *dataPtr)
 Get all array values in the column. More...
 
virtual void putArrayColumnV (const void *dataPtr)
 Put all array values in the column. More...
 
virtual void getArrayColumnCellsV (const RefRows &rownrs, void *dataPtr)
 Get some array values in the column. More...
 
virtual void putArrayColumnCellsV (const RefRows &rownrs, const void *dataPtr)
 Put some array values in the column. More...
 
virtual void getSliceV (uInt rownr, const Slicer &slicer, void *dataPtr)
 Get a section of the array in the given row. More...
 
virtual void putSliceV (uInt rownr, const Slicer &slicer, const void *dataPtr)
 Put into a section of the array in the given row. More...
 
virtual void getColumnSliceV (const Slicer &slicer, void *dataPtr)
 Get a section of all arrays in the column. More...
 
virtual void putColumnSliceV (const Slicer &slicer, const void *dataPtr)
 Put into a section of all arrays in the column. More...
 
virtual void getColumnSliceCellsV (const RefRows &rownrs, const Slicer &slicer, void *dataPtr)
 Get a section of some arrays in the column. More...
 
virtual void putColumnSliceCellsV (const RefRows &rownrs, const Slicer &slicer, const void *dataPtr)
 Put into a section of some arrays in the column. More...
 
void throwGet () const
 Throw an "invalid operation" exception for the default implementation of get. More...
 
void throwPut () const
 Throw an "invalid operation" exception for the default implementation of put. More...
 
void setColumnName (const String &colName)
 Set the column name. More...
 
const StringcolumnName () const
 Get rhe column name. More...
 

Protected Member Functions

 VSCEngine (const VSCEngine< T > &)
 Copy constructor is only used by clone(). More...
 
- Protected Member Functions inherited from casacore::DataManager
void decrementNcolumn ()
 Decrement number of columns (in case a column is deleted). More...
 
void setEndian (Bool bigEndian)
 Tell the data manager if big or little endian format is needed. More...
 
void setTsmOption (const TSMOption &tsmOption)
 Tell the data manager which TSM option to use. More...
 
void setMultiFile (MultiFileBase *mfile)
 Tell the data manager that MultiFile can be used. More...
 
virtual Bool hasMultiFileSupport () const
 Does the data manager support use of MultiFile? A derived class has to return True if it can use the MultiFile. More...
 
void throwDataTypeOther (const String &columnName, int dataType) const
 Throw an exception in case data type is TpOther, because the storage managers (and maybe other data managers) do not support such columns. More...
 
- Protected Member Functions inherited from casacore::VirtualScalarColumn< T >
Bool canAccessScalarColumn (Bool &reask) const
 The class can handle a get/putScalarColumn. More...
 
virtual void getScalarColumn (Vector< T > &data)
 Get all scalar values in the column. More...
 
virtual void putScalarColumn (const Vector< T > &data)
 Put all scalar values in the column. More...
 
virtual uInt getBlock (uInt rownr, uInt nrmax, T *dataPtr)
 Get scalars from the given row on with a maximum of nrmax values. More...
 
virtual void putBlock (uInt rownr, uInt nrmax, const T *dataPtr)
 Put nrmax scalars from the given row on. More...
 

Private Member Functions

VSCEngine< T > & operator= (const VSCEngine< T > &)
 Assignment is not needed and therefore forbidden (so it is made private). More...
 
Bool isWritable () const
 The column is in principle writable. More...
 
DataManagerColumnmakeScalarColumn (const String &columnName, int dataType, const String &dataTypeID)
 Create the column object for the scalar column in this engine. More...
 

Private Attributes

String sourceName_p
 

Additional Inherited Members

- Static Public Member Functions inherited from casacore::DataManager
static void registerCtor (const String &type, DataManagerCtor func)
 Register a mapping of a data manager type to its static construction function. More...
 
static DataManagerCtor getCtor (const String &dataManagerType)
 Get the "constructor" of a data manager (thread-safe). More...
 
static Bool isRegistered (const String &dataManagerType)
 Test if a data manager is registered (thread-safe). More...
 
static DataManagerunknownDataManager (const String &dataManagerType, const Record &spec)
 Serve as default function for theirRegisterMap, which catches all unknown data manager types. More...
 

Detailed Description

template<class T>
class casacore::VSCEngine< T >

Base virtual column for a scalar column with any type.

Review Status

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

Intended use:

Public interface

Prerequisite

Etymology

VSCEngine stands for Virtual Scalar Column Engine, i.e. a class handling a virtual table column containing scalar values.

Synopsis

VSCEngine is a base virtual column engine to handle a column with an arbitrary type. Data of columns with standard data types can directly be stored in a Table using a storage manager, but data of column with non-standard types have to be stored in another way. The way to do this is to split the object with the non-standard type into its individual elements, which are subsequently put into the appropriate columns.

A virtual column engine has to be implemented for each non-standard data type, which has to be stored in a table. This engine has to get and put the individual parts the object. VSCEngine is the base class for such engines, so the actual engine quite simple to implement. The example shows the implementation of an engine AVSCEngine handling a data type A.

In principle the name of the engine class is free, but it is strongly recommended to use the name <dataTypeId>VSCEngine, where VSC stands for Virtual Scalar Column (e.g. AVSCEngine for class A). In this way the default data manager name supplied by the class and by class ScalarColumnDesc can be used.

Example

This example shows the implementation of an engine class AVSCEngine, which stores the data of a class A. The data objects A are stored in a column called the source column. The user has to associate two target columns with it. The engine stores the data parts x and y in the target columns. The names of the target columns are stored as keywords in the source column. In this way the engine can reconstruct itself when the table is read back.

In the example all AVSCEngine functions are shown inline, but they should be implemented out-of-line in a separate.cc file.

//# AVSCEngine.h: Example virtual column engine to handle data type A
#if !defined(AIPS_AVSCENGINE_H)
\#define AIPS_AVSCENGINE_H
//# Includes
// Define the class A.
class A
{
public:
A(): x_p(0), y_p(0) {}
A(Int x, float y) : x_p(x), y_p(y) {}
A(const A& that): x_p(that.x_p), y_p(that.y_p) {}
static String dataTypeId()
{ return "A"; }
Int x() const
{ return x_p; }
float y() const
{ return y_p; }
Int& x()
{ return x_p; }
float& y()
{ return y_p; }
int operator== (const A& that) const
{ return x_p==that.x_p && y_p==that.y_p; }
int operator< (const A& that) const
{ return x_p<that.x_p || (x_p==that.x_p && y_p<that.y_p); }
private:
Int x_p;
float y_p;
};
// Now define the engine to handle objects of type A.
class AVSCEngine : public VSCEngine<A>
{
public:
// The default constructor is required for reconstruction of the
// engine when a table is read back.
AVSCEngine()
{}
// Construct the engine for the given source column and storing
// the result in the given target columns for the data members
// x and y of class A.
AVSCEngine (const String& sourceColumnName,
const String& xTargetColumnName,
const String& yTargetColumnname)
: VSCEngine<A> (sourceColumnName),
xTargetName_p (xTargetColumnName),
yTargetName_p (yTargetColumnName)
{}
// Destructor is mandatory.
virtual ~AVSCEngine()
{}
// Clone the object.
virtual DataManager* clone() const
{
DataManager* dmPtr = new AVSCEngine (sourceColumnName(),
xTargetName_p, yTargetName_p);
return dmPtr;
}
// Store the target column names in the source column keywords.
virtual void create (uInt)
{
TableColumn src (table(), sourceColumnName());
src.keywordSet().keysString()("_xTargetName") = xTargetName_p;
src.keywordSet().keysString()("_yTargetName") = yTargetName_p;
}
// Prepare the engine by allocating column objects
// for the target columns.
virtual void prepare()
{
TableColumn src (table(), sourceColumnName());
xTargetName_p = src.keywordSet().asString ("_xTargetName");
yTargetName_p = src.keywordSet().asString ("_yTargetName");
rocolx.attach (table(), xTargetName_p);
rocoly.attach (table(), yTargetName_p);
if (table().isWritable()) {
colx.attach (table(), xTargetName_p);
coly.attach (table(), yTargetName_p);
}
}
// Get the data from a row.
virtual void get (uInt rownr, A& value)
{
rocolx.get (rownr, value.x());
rocoly.get (rownr, value.y());
}
// Put the data in a row.
virtual void put (uInt rownr, const A& value)
{
colx.put (rownr, value.x());
coly.put (rownr, value.y());
}
// Register the class name and the static makeObject "constructor".
// This will make the engine known to the table system.
static void registerClass()
{
DataManager::registerCtor ("AVSCEngine", makeObject);
}
private:
// Copy constructor is only used by clone().
// (so it is made private).
AVSCEngine (const AVSCEngine&)
: VSCEngine<A> (that),
xTargetName_p (that.xTargetName_p),
yTargetName_p (that.yTargetName_p)
{}
// Assignment is not needed and therefore forbidden
// (so it is made private and is not implemented).
AVSCEngine& operator= (const AVSCEngine&);
// The target column names.
String xTargetName_p;
String yTargetName_p;
// Objects for the target columns.
ScalarColumn<Int> colx; // used by put
ScalarColumn<Int> rocolx; // used by get
ScalarColumn<float> coly; // used by put
ScalarColumn<float> rocoly; // used by get
public:
// 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.
// Function registerClass() is doing that.
static DataManager* makeObject (const String& dataManagerType)
{
DataManager* dmPtr = new AVSCEngine();
return dmPtr;
}
};
#endif

User code using this engine to create a new table could look like:

// Register the engine.
// This is not needed if the engine is registered as part
// of the general DataManager::registerAllCtor function.
AVSCEngine::registerClass();
// Create the table description.
TableDesc td;
td.addColumn (ScalarColumnDesc<A>("source"));
td.addColumn (ScalarColumnDesc<Int>("xTarget"));
td.addColumn (ScalarColumnDesc<Int>("yTarget"));
SetupNewTable setup ("table.name", td, Table::New);
// Define the engine for column "source".
AVSCEngine engine ("source", "xTarget", "yTarget");
Table tab (setup, 10);
// Put data into column "source".
ScalarColumn<A> col (tab, "source");
for (uInt i=0; i<10; i++) {
col.put (i, someA); // writes indirectly xTarget and yTarget
}

Motivation

This class makes it easier for the user to implement the engine. It supplies several default functions.

Template Type Argument Requirements (T)

Definition at line 288 of file VSCEngine.h.

Constructor & Destructor Documentation

template<class T>
casacore::VSCEngine< T >::VSCEngine ( )

The default constructor is required for reconstruction of the engine when a table is read back.

It is also used to construct an engine, which does not check the source column name.

template<class T>
casacore::VSCEngine< T >::VSCEngine ( const String sourceColumnName)

Construct an engine to handle a column with an arbitrary data type.

Later it will check if the source column name is correct.

template<class T>
casacore::VSCEngine< T >::~VSCEngine ( )

Destructor is mandatory.

template<class T>
casacore::VSCEngine< T >::VSCEngine ( const VSCEngine< T > &  )
protected

Copy constructor is only used by clone().

(so it is made protected).

Member Function Documentation

template<class T>
String casacore::VSCEngine< T >::dataManagerType ( ) const
virtual

Return the data manager type name.

This defaults to the data type ID followed by VSCEngine (meaning Virtual Scalar Column Engine).

Implements casacore::DataManager.

template<class T>
Bool casacore::VSCEngine< T >::isWritable ( ) const
privatevirtual

The column is in principle writable.

This does not mean it is actually writable, because that depends on the fact if the table is writable.

Reimplemented from casacore::VirtualScalarColumn< T >.

template<class T>
DataManagerColumn* casacore::VSCEngine< T >::makeScalarColumn ( const String columnName,
int  dataType,
const String dataTypeID 
)
privatevirtual

Create the column object for the scalar column in this engine.

It will check if the given column name matches the source column name. This assures that the engine is bound to the correct column.

Reimplemented from casacore::VirtualColumnEngine.

template<class T>
VSCEngine<T>& casacore::VSCEngine< T >::operator= ( const VSCEngine< T > &  )
private

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

template<class T>
const String& casacore::VSCEngine< T >::sourceColumnName ( ) const
inline

Get the name of the source column.

Definition at line 315 of file VSCEngine.h.

References casacore::VSCEngine< T >::sourceName_p.

Member Data Documentation

template<class T>
String casacore::VSCEngine< T >::sourceName_p
private

Definition at line 344 of file VSCEngine.h.

Referenced by casacore::VSCEngine< T >::sourceColumnName().


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