28 #ifndef TABLES_DATAMANAGER_H 29 #define TABLES_DATAMANAGER_H 33 #include <casacore/casa/aips.h> 34 #include <casacore/tables/Tables/ColumnCache.h> 35 #include <casacore/tables/DataMan/TSMOption.h> 36 #include <casacore/casa/BasicSL/String.h> 37 #include <casacore/casa/BasicSL/Complex.h> 38 #include <casacore/casa/Containers/SimOrdMap.h> 39 #include <casacore/casa/IO/ByteIO.h> 40 #include <casacore/casa/OS/Mutex.h> 47 class DataManagerColumn;
55 template<
class T>
class Array;
362 const String& dataTypeId);
366 const String& dataTypeId);
370 const String& dataTypeId);
433 const String& dataTypeId) = 0;
437 const String& dataTypeId) = 0;
441 const String& dataTypeId) = 0;
447 int dataType,
const String& dataTypeId)
const;
534 static DataManagerCtor
getCtor (
const String& dataManagerType);
615 : isFixedShape_p(
False) {;}
622 { isFixedShape_p = isFixedShape; }
626 {
return isFixedShape_p; }
629 virtual int dataType()
const = 0;
635 virtual String dataTypeId()
const;
642 virtual Bool isWritable()
const;
646 virtual void setMaxLength (
uInt maxLength);
652 { setShapeColumn (shape); isFixedShape_p =
True; }
661 virtual void setShapeTiled (
uInt rownr,
const IPosition& shape,
666 virtual Bool isShapeDefined (
uInt rownr);
682 virtual Bool canChangeShape()
const;
693 virtual Bool canAccessScalarColumn (
Bool& reask)
const;
705 virtual Bool canAccessScalarColumnCells (
Bool& reask)
const;
716 virtual Bool canAccessArrayColumn (
Bool& reask)
const;
728 virtual Bool canAccessArrayColumnCells (
Bool& reask)
const;
739 virtual Bool canAccessSlice (
Bool& reask)
const;
750 virtual Bool canAccessColumnSlice (
Bool& reask)
const;
769 { getBoolV (rownr, dataPtr); }
771 { getuCharV (rownr, dataPtr); }
773 { getShortV (rownr, dataPtr); }
775 { getuShortV (rownr, dataPtr); }
777 { getIntV (rownr, dataPtr); }
779 { getuIntV (rownr, dataPtr); }
780 void get (
uInt rownr,
float* dataPtr)
781 { getfloatV (rownr, dataPtr); }
782 void get (
uInt rownr,
double* dataPtr)
783 { getdoubleV (rownr, dataPtr); }
785 { getComplexV (rownr, dataPtr); }
787 { getDComplexV (rownr, dataPtr); }
789 { getStringV (rownr, dataPtr); }
791 void get (
uInt rownr,
void* dataPtr)
792 { getOtherV (rownr, dataPtr); }
804 { putBoolV (rownr, dataPtr); }
806 { putuCharV (rownr, dataPtr); }
808 { putShortV (rownr, dataPtr); }
810 { putuShortV (rownr, dataPtr); }
812 { putIntV (rownr, dataPtr); }
814 { putuIntV (rownr, dataPtr); }
816 { putfloatV (rownr, dataPtr); }
818 { putdoubleV (rownr, dataPtr); }
820 { putComplexV (rownr, dataPtr); }
822 { putDComplexV (rownr, dataPtr); }
824 { putStringV (rownr, dataPtr); }
827 { putOtherV (rownr, dataPtr); }
836 virtual void getScalarColumnV (
void* dataPtr);
844 virtual void putScalarColumnV (
const void* dataPtr);
852 virtual void getScalarColumnCellsV (
const RefRows& rownrs,
861 virtual void putScalarColumnCellsV (
const RefRows& rownrs,
862 const void* dataPtr);
871 virtual uInt getBlockV (
uInt rownr,
uInt nrmax,
void* dataPtr);
880 virtual void putBlockV (
uInt rownr,
uInt nrmax,
const void* dataPtr);
888 virtual void getArrayV (
uInt rownr,
void* dataPtr);
896 virtual void putArrayV (
uInt rownr,
const void* dataPtr);
904 virtual void getArrayColumnV (
void* dataPtr);
912 virtual void putArrayColumnV (
const void* dataPtr);
920 virtual void getArrayColumnCellsV (
const RefRows& rownrs,
929 virtual void putArrayColumnCellsV (
const RefRows& rownrs,
930 const void* dataPtr);
938 virtual void getSliceV (
uInt rownr,
const Slicer& slicer,
void* dataPtr);
946 virtual void putSliceV (
uInt rownr,
const Slicer& slicer,
947 const void* dataPtr);
955 virtual void getColumnSliceV (
const Slicer& slicer,
void* dataPtr);
963 virtual void putColumnSliceV (
const Slicer& slicer,
const void* dataPtr);
971 virtual void getColumnSliceCellsV (
const RefRows& rownrs,
972 const Slicer& slicer,
void* dataPtr);
980 virtual void putColumnSliceCellsV (
const RefRows& rownrs,
982 const void* dataPtr);
986 void throwGet()
const;
990 void throwPut()
const;
994 { colName_p = colName; }
998 {
return colName_p; }
1004 virtual void getBoolV (
uInt rownr,
Bool* dataPtr);
1005 virtual void getuCharV (
uInt rownr,
uChar* dataPtr);
1006 virtual void getShortV (
uInt rownr,
Short* dataPtr);
1007 virtual void getuShortV (
uInt rownr,
uShort* dataPtr);
1008 virtual void getIntV (
uInt rownr,
Int* dataPtr);
1009 virtual void getuIntV (
uInt rownr,
uInt* dataPtr);
1010 virtual void getfloatV (
uInt rownr,
float* dataPtr);
1011 virtual void getdoubleV (
uInt rownr,
double* dataPtr);
1012 virtual void getComplexV (
uInt rownr,
Complex* dataPtr);
1013 virtual void getDComplexV (
uInt rownr,
DComplex* dataPtr);
1014 virtual void getStringV (
uInt rownr,
String* dataPtr);
1016 virtual void getOtherV (
uInt rownr,
void* dataPtr);
1022 virtual void putBoolV (
uInt rownr,
const Bool* dataPtr);
1023 virtual void putuCharV (
uInt rownr,
const uChar* dataPtr);
1024 virtual void putShortV (
uInt rownr,
const Short* dataPtr);
1025 virtual void putuShortV (
uInt rownr,
const uShort* dataPtr);
1026 virtual void putIntV (
uInt rownr,
const Int* dataPtr);
1027 virtual void putuIntV (
uInt rownr,
const uInt* dataPtr);
1028 virtual void putfloatV (
uInt rownr,
const float* dataPtr);
1029 virtual void putdoubleV (
uInt rownr,
const double* dataPtr);
1030 virtual void putComplexV (
uInt rownr,
const Complex* dataPtr);
1031 virtual void putDComplexV (
uInt rownr,
const DComplex* dataPtr);
1032 virtual void putStringV (
uInt rownr,
const String* dataPtr);
1034 virtual void putOtherV (
uInt rownr,
const void* dataPtr);
1044 virtual void setShapeColumn (
const IPosition& shape);
void put(uInt rownr, const uInt *dataPtr)
A Vector of integers, for indexing into Array<T> objects.
void setMultiFile(MultiFileBase *mfile)
Tell the data manager that MultiFile can be used.
void setColumnName(const String &colName)
Set the column name.
virtual Bool canRenameColumn() const
Does the data manager allow to rename columns? (default yes)
const TSMOption & tsmOption() const
Get the TSM option.
static void registerCtor(const String &type, DataManagerCtor func)
Register a mapping of a data manager type to its static construction function.
void setFixedShapeColumn(const IPosition &shape)
Set the shape of all (fixed-shaped) arrays in the column.
Create a new table - define shapes, data managers, etc.
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 m...
Bool isFixedShape() const
Is this a fixed shape column?
std::complex< Float > Complex
Main interface class to a read/write table.
void put(uInt rownr, const double *dataPtr)
void decrementNcolumn()
Decrement number of columns (in case a column is deleted).
const ColumnCache * columnCachePtr() const
virtual uInt open1(uInt nrrow, AipsIO &ios)
Open as above.
virtual Bool flush(AipsIO &ios, Bool fsync)=0
Flush and optionally fsync the data.
virtual Record getProperties() const
Get data manager properties that can be modified.
Abstract base class to combine multiple files in a single one.
virtual Bool isRegular() const
Is this a regular storage manager? It is regular if it allows addition of rows and writing data in th...
AipsIO is the object persistency mechanism of Casacore.
virtual void removeRow(uInt rownr)
Delete a row from all columns.
virtual void showCacheStatistics(std::ostream &) const
Show the data manager's IO statistics.
Abstract base class for a column in a data manager.
void put(uInt rownr, const Int *dataPtr)
virtual void open(uInt nrrow, AipsIO &ios)=0
Let the data manager initialize itself for an existing table.
virtual void reopenRW()
Reopen the data manager for read/write access.
virtual Bool canRemoveColumn() const
Does the data manager allow to delete columns? (default no)
void put(uInt rownr, const void *dataPtr)
This function is the put for all non-standard data types.
static DataManagerCtor getCtor(const String &dataManagerType)
Get the "constructor" of a data manager (thread-safe).
const String & columnName() const
Get rhe column name.
virtual void deleteManager()=0
The data manager will be deleted (because all its columns are requested to be deleted).
virtual Bool canRemoveRow() const
Does the data manager allow to delete rows? (default no)
virtual void setMaximumCacheSize(uInt nbytes)
Set the maximum cache size (in bytes) to be used by a storage manager.
virtual Bool canAddColumn() const
Does the data manager allow to add columns? (default no)
virtual void addRow(uInt nrrow)
Add rows to all columns.
MultiFileBase * multiFile()
Get the MultiFile pointer (can be 0).
void put(uInt rownr, const Bool *dataPtr)
Put the scalar value into the given row.
uInt ncolumn() const
Get the nr of columns in this data manager (can be zero).
Class to manage a set of table columns.
DataManagerColumn * createIndArrColumn(const String &columnName, int dataType, const String &dataTypeId)
Create an indirect array column.
ColumnCache & columnCache()
Get access to the ColumnCache object.
uInt sequenceNr() const
Get the (unique) sequence nr of this data manager.
Bool asBigEndian() const
Have the data to be stored in big or little endian canonical format?
Table & table() const
Get the table this object is associated with.
void dataManagerInfo(Record &info) const
Add SEQNR and SPEC (the DataManagerSpec subrecord) to the info.
DataManager * getClone() const
Has the object already been cloned?
static SimpleOrderedMap< String, DataManagerCtor > initRegisterMap()
Register the main data managers.
static Bool isRegistered(const String &dataManagerType)
Test if a data manager is registered (thread-safe).
Simple map with keys ordered.
DataManagerColumn()
Create a column.
void put(uInt rownr, const DComplex *dataPtr)
ByteIO::OpenOption fileOption() const
Get the AipsIO option of the underlying file.
std::complex< Double > DComplex
virtual DataManagerColumn * makeScalarColumn(const String &columnName, int dataType, const String &dataTypeId)=0
Create a column in the data manager on behalf of a table column.
virtual void resync(uInt nrrow)=0
Resync the data by rereading cached data from the file.
void checkDataType(const DataManagerColumn *colPtr, const String &columnName, int dataType, const String &dataTypeId) const
Check if the data type of the created data manager column is correct.
Class holding the row numbers in a RefTable.
LatticeExprNode ndim(const LatticeExprNode &expr)
1-argument function to get the dimensionality of a lattice.
void put(uInt rownr, const float *dataPtr)
virtual DataManagerColumn * makeIndArrColumn(const String &columnName, int dataType, const String &dataTypeId)=0
Create an indirect array column.
virtual void setProperties(const Record &spec)
Modify data manager properties given in record fields.
void setTsmOption(const TSMOption &tsmOption)
Tell the data manager which TSM option to use.
virtual void prepare()
Let the data manager initialize itself further.
DataManager & operator=(const DataManager &)
Assignment cannot be used for this base class.
Options for the Tiled Storage Manager Access.
static SimpleOrderedMap< String, DataManagerCtor > theirRegisterMap
Declare the mapping of the data manager type name to a static "makeObject" function.
A hierarchical collection of named fields of various types.
bool Bool
Define the standard types used by Casacore.
void setClone(DataManager *clone) const
Set the pointer to the clone.
void linkToTable(Table &tab)
Link the data manager to the Table object.
void put(uInt rownr, const uChar *dataPtr)
virtual void removeColumn(DataManagerColumn *)
Delete a column.
A caching object for a table column.
virtual Bool isStorageManager() const
Is the data manager a storage manager? The default is yes.
virtual DataManagerColumn * reallocateColumn(DataManagerColumn *column)
Reallocate the column object if it is part of this data manager.
TableExprNode shape(const TableExprNode &array)
Function operating on any scalar or array resulting in a Double array containing the shape...
void put(uInt rownr, const Short *dataPtr)
virtual Bool hasMultiFileSupport() const
Does the data manager support use of MultiFile? A derived class has to return True if it can use the ...
virtual DataManagerColumn * makeDirArrColumn(const String &columnName, int dataType, const String &dataTypeId)=0
Create a direct array column.
virtual void create(uInt nrrow)=0
Let the data manager initialize itself for a new table.
Specify which elements to extract from an n-dimensional array.
Wrapper around a pthreads mutex.
DataManager()
Default constructor.
virtual String dataManagerType() const =0
Return the type name of the data manager (in fact its class name).
virtual DataManager * clone() const =0
Make a clone of the derived object.
virtual void addColumn(DataManagerColumn *)
Add a column.
void put(uInt rownr, const uShort *dataPtr)
OpenOption
Define the possible ByteIO open options.
Abstract base class for a data manager.
virtual Bool canAddRow() const
Does the data manager allow to add rows? (default no)
void setIsFixedShape(Bool isFixedShape)
Set the isFixedShape flag.
virtual uInt resync1(uInt nrrow)
Resync as above.
String fileName() const
Compose a unique filename from the table name and sequence number.
void setEndian(Bool bigEndian)
Tell the data manager if big or little endian format is needed.
void put(uInt rownr, const String *dataPtr)
void put(uInt rownr, const Complex *dataPtr)
String: the storage and methods of handling collections of characters.
virtual Record dataManagerSpec() const
Return a record containing data manager specifications.
MultiFileBase * multiFile_p
DataManagerColumn * createDirArrColumn(const String &columnName, int dataType, const String &dataTypeId)
Create a direct array column.
DataManagerColumn * createScalarColumn(const String &columnName, int dataType, const String &dataTypeId)
Create a column in the data manager on behalf of a table column.
virtual String dataManagerName() const
Return the name of the data manager.
void setSeqnr(uInt nr)
Set the sequence number of this data manager.
this file contains all the compiler specific defines
virtual Bool canReallocateColumns() const
Tell if the data manager wants to reallocate the data manager column objects.
static DataManager * unknownDataManager(const String &dataManagerType, const Record &spec)
Serve as default function for theirRegisterMap, which catches all unknown data manager types...
String keywordName(const String &keyword) const
Compose a keyword name from the given keyword appended with the sequence number (e.g.