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);
542 { theirMutexedInit.
exec(); }
555 DataManagerCtor func)
556 { theirRegisterMap.
define (type, func); }
625 : isFixedShape_p(
False) {;}
632 { isFixedShape_p = isFixedShape; }
636 {
return isFixedShape_p; }
639 virtual int dataType()
const = 0;
645 virtual String dataTypeId()
const;
652 virtual Bool isWritable()
const;
656 virtual void setMaxLength (
uInt maxLength);
662 { setShapeColumn (shape); isFixedShape_p =
True; }
671 virtual void setShapeTiled (
uInt rownr,
const IPosition& shape,
676 virtual Bool isShapeDefined (
uInt rownr);
692 virtual Bool canChangeShape()
const;
703 virtual Bool canAccessScalarColumn (
Bool& reask)
const;
715 virtual Bool canAccessScalarColumnCells (
Bool& reask)
const;
726 virtual Bool canAccessArrayColumn (
Bool& reask)
const;
738 virtual Bool canAccessArrayColumnCells (
Bool& reask)
const;
749 virtual Bool canAccessSlice (
Bool& reask)
const;
760 virtual Bool canAccessColumnSlice (
Bool& reask)
const;
779 { getBoolV (rownr, dataPtr); }
781 { getuCharV (rownr, dataPtr); }
783 { getShortV (rownr, dataPtr); }
785 { getuShortV (rownr, dataPtr); }
787 { getIntV (rownr, dataPtr); }
789 { getuIntV (rownr, dataPtr); }
790 void get (
uInt rownr,
float* dataPtr)
791 { getfloatV (rownr, dataPtr); }
792 void get (
uInt rownr,
double* dataPtr)
793 { getdoubleV (rownr, dataPtr); }
795 { getComplexV (rownr, dataPtr); }
797 { getDComplexV (rownr, dataPtr); }
799 { getStringV (rownr, dataPtr); }
801 void get (
uInt rownr,
void* dataPtr)
802 { getOtherV (rownr, dataPtr); }
814 { putBoolV (rownr, dataPtr); }
816 { putuCharV (rownr, dataPtr); }
818 { putShortV (rownr, dataPtr); }
820 { putuShortV (rownr, dataPtr); }
822 { putIntV (rownr, dataPtr); }
824 { putuIntV (rownr, dataPtr); }
826 { putfloatV (rownr, dataPtr); }
828 { putdoubleV (rownr, dataPtr); }
830 { putComplexV (rownr, dataPtr); }
832 { putDComplexV (rownr, dataPtr); }
834 { putStringV (rownr, dataPtr); }
837 { putOtherV (rownr, dataPtr); }
846 virtual void getScalarColumnV (
void* dataPtr);
854 virtual void putScalarColumnV (
const void* dataPtr);
862 virtual void getScalarColumnCellsV (
const RefRows& rownrs,
871 virtual void putScalarColumnCellsV (
const RefRows& rownrs,
872 const void* dataPtr);
881 virtual uInt getBlockV (
uInt rownr,
uInt nrmax,
void* dataPtr);
890 virtual void putBlockV (
uInt rownr,
uInt nrmax,
const void* dataPtr);
898 virtual void getArrayV (
uInt rownr,
void* dataPtr);
906 virtual void putArrayV (
uInt rownr,
const void* dataPtr);
914 virtual void getArrayColumnV (
void* dataPtr);
922 virtual void putArrayColumnV (
const void* dataPtr);
930 virtual void getArrayColumnCellsV (
const RefRows& rownrs,
939 virtual void putArrayColumnCellsV (
const RefRows& rownrs,
940 const void* dataPtr);
948 virtual void getSliceV (
uInt rownr,
const Slicer& slicer,
void* dataPtr);
956 virtual void putSliceV (
uInt rownr,
const Slicer& slicer,
957 const void* dataPtr);
965 virtual void getColumnSliceV (
const Slicer& slicer,
void* dataPtr);
973 virtual void putColumnSliceV (
const Slicer& slicer,
const void* dataPtr);
981 virtual void getColumnSliceCellsV (
const RefRows& rownrs,
982 const Slicer& slicer,
void* dataPtr);
990 virtual void putColumnSliceCellsV (
const RefRows& rownrs,
992 const void* dataPtr);
996 void throwGet()
const;
1000 void throwPut()
const;
1004 { colName_p = colName; }
1008 {
return colName_p; }
1014 virtual void getBoolV (
uInt rownr,
Bool* dataPtr);
1015 virtual void getuCharV (
uInt rownr,
uChar* dataPtr);
1016 virtual void getShortV (
uInt rownr,
Short* dataPtr);
1017 virtual void getuShortV (
uInt rownr,
uShort* dataPtr);
1018 virtual void getIntV (
uInt rownr,
Int* dataPtr);
1019 virtual void getuIntV (
uInt rownr,
uInt* dataPtr);
1020 virtual void getfloatV (
uInt rownr,
float* dataPtr);
1021 virtual void getdoubleV (
uInt rownr,
double* dataPtr);
1022 virtual void getComplexV (
uInt rownr,
Complex* dataPtr);
1023 virtual void getDComplexV (
uInt rownr,
DComplex* dataPtr);
1024 virtual void getStringV (
uInt rownr,
String* dataPtr);
1026 virtual void getOtherV (
uInt rownr,
void* dataPtr);
1032 virtual void putBoolV (
uInt rownr,
const Bool* dataPtr);
1033 virtual void putuCharV (
uInt rownr,
const uChar* dataPtr);
1034 virtual void putShortV (
uInt rownr,
const Short* dataPtr);
1035 virtual void putuShortV (
uInt rownr,
const uShort* dataPtr);
1036 virtual void putIntV (
uInt rownr,
const Int* dataPtr);
1037 virtual void putuIntV (
uInt rownr,
const uInt* dataPtr);
1038 virtual void putfloatV (
uInt rownr,
const float* dataPtr);
1039 virtual void putdoubleV (
uInt rownr,
const double* dataPtr);
1040 virtual void putComplexV (
uInt rownr,
const Complex* dataPtr);
1041 virtual void putDComplexV (
uInt rownr,
const DComplex* dataPtr);
1042 virtual void putStringV (
uInt rownr,
const String* dataPtr);
1044 virtual void putOtherV (
uInt rownr,
const void* dataPtr);
1054 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.
Thread-safe initialization of global variables.
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.
static void registerMainCtor()
Register the main data managers (if not done yet).
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.
static void unlockedRegisterCtor(const String &type, DataManagerCtor func)
Register a data manager constructor.
DataManager * getClone() const
Has the object already been cloned?
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.
static MutexedInit theirMutexedInit
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.
void exec()
Execute the initialization function if not done yet.
Specify which elements to extract from an n-dimensional array.
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.
static void doRegisterMainCtor(void *)
Do the actual (thread-safe) registration of the main data managers.
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.
V & define(const K &, const V &)
Defines a mapping (ie.
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.