PlainTable.h

Classes

PlainTable -- Class defining a plain regular table (full description)

class PlainTable : public BaseTable

Interface

Public Members
PlainTable (SetupNewTable&, uInt nrrow, Bool initialize, const TableLock& lockOptions, int endianFormat)
PlainTable (AipsIO&, uInt version, const String& name, const String& type, uInt nrrow, int option, const TableLock& lockOptions, Bool addToCache, uInt locknr)
virtual ~PlainTable()
static void getLayout (TableDesc& desc, AipsIO& ios)
virtual void reopenRW()
virtual Bool asBigEndian() const
virtual Bool isMultiUsed (Bool checkSubTables) const
virtual const TableLock& lockOptions() const
virtual void mergeLock (const TableLock& lockOptions)
virtual Bool hasLock (FileLocker::LockType) const
virtual Bool lock (FileLocker::LockType, uInt nattempts)
virtual void unlock()
void autoReleaseLock (Bool always = False)
virtual void flush (Bool fsync, Bool recursive)
virtual void resync()
virtual uInt getModifyCounter() const
virtual void setTableChanged()
static ByteIO::OpenOption toAipsIOFoption (int tableOption)
virtual Bool isWritable() const
virtual TableDesc actualTableDesc() const
virtual Record dataManagerInfo() const
virtual TableRecord& keywordSet()
virtual TableRecord& rwKeywordSet()
virtual BaseColumn* getColumn (uInt columnIndex) const
virtual BaseColumn* getColumn (const String& columnName) const
virtual Bool canAddRow() const
virtual void addRow (uInt nrrow, Bool initialize)
virtual Bool canRemoveRow() const
virtual void removeRow (uInt rownr)
virtual void addColumn (const ColumnDesc& columnDesc)
virtual void addColumn (const ColumnDesc& columnDesc, const String& dataManager, Bool byName)
virtual void addColumn (const ColumnDesc& columnDesc, const DataManager& dataManager)
virtual void addColumn (const TableDesc& tableDesc, const DataManager& dataManager)
virtual Bool canRemoveColumn (const Vector<String>& columnNames) const
virtual void removeColumn (const Vector<String>& columnNames)
virtual Bool canRenameColumn (const String& columnName) const
virtual void renameColumn (const String& newName, const String& oldName)
virtual DataManager* findDataManager (const String& dataManagerName) const
Private Members
PlainTable (const PlainTable&)
PlainTable& operator= (const PlainTable&)
virtual void renameSubTables (const String& newName, const String& oldName)
static MemoryIO* releaseCallBack (void* plainTableObject, Bool always)
MemoryIO* doReleaseCallBack (Bool always)
Bool putFile (Bool always)
void syncTable()
void setEndian (int endianFormat)

Description

Review Status

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

Prerequisite

Etymology

PlainTable represents a plain regular table. This is opposed to a RefTable, which is a view on a PlainTable.

Synopsis

PlainTable is a table consisting of a keyword set and a number of filled and virtual columns. The table control information and the keyword set is stored in an AipsIO file. The data in the filled columns are stored separately by storage managers.

To Do

Member Description

PlainTable (SetupNewTable&, uInt nrrow, Bool initialize, const TableLock& lockOptions, int endianFormat)

Construct the object for a new table. It creates storage manager(s) for unbound columns and initializes all storage managers. The given number of rows is stored in the table and initialized if the flag is set.

PlainTable (AipsIO&, uInt version, const String& name, const String& type, uInt nrrow, int option, const TableLock& lockOptions, Bool addToCache, uInt locknr)

Construct the object for an existing table. It opens the table file, reads the table control information and creates and initializes the required storage managers.

virtual ~PlainTable()

The destructor flushes (i.e. writes) the table if it is opened for output and not marked for delete.

static void getLayout (TableDesc& desc, AipsIO& ios)

Return the layout of a table (i.e. description and #rows). This function has the advantage that only the minimal amount of information required is read from the table, thus it is much faster than a normal table open.
The number of rows is returned. The description of the table is stored in desc (its contents will be overwritten).

virtual void reopenRW()

Try to reopen the table for read/write access. An exception is thrown if the table is not writable. Nothing is done if the table is already open for read/write.

virtual Bool asBigEndian() const

Is the table stored in big or little endian format?

virtual Bool isMultiUsed (Bool checkSubTables) const

Is the table in use (i.e. open) in another process? If checkSubTables is set, it is also checked if a subtable is used in another process.

virtual const TableLock& lockOptions() const

Get the locking info.

virtual void mergeLock (const TableLock& lockOptions)

Merge the given lock info with the existing one.

virtual Bool hasLock (FileLocker::LockType) const

Has this process the read or write lock, thus can the table be read or written safely?

virtual Bool lock (FileLocker::LockType, uInt nattempts)

Try to lock the table for read or write access.

virtual void unlock()

Unlock the table. This will also synchronize the table data, thus force the data to be written to disk.

void autoReleaseLock (Bool always = False)

Do a release of an AutoLock when the inspection interval has expired. always=True means that the inspection is always done, thus not every 25th call or so.

virtual void flush (Bool fsync, Bool recursive)

Flush the table, i.e. write it to disk. Nothing will be done if the table is not writable. A flush can be executed at any time. When a table is marked for delete, the destructor will remove files written by intermediate flushes. Note that if necessary the destructor will do an implicit flush, unless it is executed due to an exception.

virtual void resync()

Resync the Table object with the table file.

virtual uInt getModifyCounter() const

Get the modify counter.

virtual void setTableChanged()

Set the table to being changed.

static ByteIO::OpenOption toAipsIOFoption (int tableOption)

Convert a Table option to an AipsIO file option. This is used by storage managers.

virtual Bool isWritable() const

Test if the table is opened as writable.

virtual TableDesc actualTableDesc() const

Get the actual table description.

virtual Record dataManagerInfo() const

Get the data manager info.

virtual TableRecord& keywordSet()

Get readonly access to the table keyword set.

virtual TableRecord& rwKeywordSet()

Get read/write access to the table keyword set. This requires that the table is locked (or it gets locked when using AutoLocking mode).

virtual BaseColumn* getColumn (uInt columnIndex) const

Get a column object using its index.

virtual BaseColumn* getColumn (const String& columnName) const

Get a column object using its name.

virtual Bool canAddRow() const

Test if it is possible to add a row to this table.

virtual void addRow (uInt nrrow, Bool initialize)

Add one or more rows and possibly initialize them. This will fail for tables not supporting addition of rows.

virtual Bool canRemoveRow() const

Test if it is possible to remove a row from this table.

virtual void removeRow (uInt rownr)

Remove the given row. This will fail for tables not supporting removal of rows.

virtual void addColumn (const ColumnDesc& columnDesc)
virtual void addColumn (const ColumnDesc& columnDesc, const String& dataManager, Bool byName)
virtual void addColumn (const ColumnDesc& columnDesc, const DataManager& dataManager)
virtual void addColumn (const TableDesc& tableDesc, const DataManager& dataManager)

Add a column to the table. The default implementation throws an "invalid operation" exception.

virtual Bool canRemoveColumn (const Vector<String>& columnNames) const

Test if columns can be removed.

virtual void removeColumn (const Vector<String>& columnNames)

Remove columns.

virtual Bool canRenameColumn (const String& columnName) const

Test if a column can be renamed (yes).

virtual void renameColumn (const String& newName, const String& oldName)

Rename a column.

virtual DataManager* findDataManager (const String& dataManagerName) const

Find the data manager with the given name.

PlainTable (const PlainTable&)

Copy constructor is forbidden, because copying a table requires some more knowledge (like table name of result). Declaring it private, makes it unusable.

PlainTable& operator= (const PlainTable&)

Assignment is forbidden, because copying a table requires some more knowledge (like table name of result). Declaring it private, makes it unusable.

virtual void renameSubTables (const String& newName, const String& oldName)

Rename the subtables (used by rename function).

static MemoryIO* releaseCallBack (void* plainTableObject, Bool always)
MemoryIO* doReleaseCallBack (Bool always)

The callback function when a lock is released. This flushes the table data, writes the synchronization data into the MemoryIO object, and returns a pointer to it.

Bool putFile (Bool always)

When needed, write the table control information in an AipsIO file. Tell the storage managers to flush and close their files. It returns a switch to tell if the table control information has been written.

void syncTable()

Synchronize the table after having acquired a lock which says that main table data has changed. It check if the columns did not change. It updates the table and column keywords.

void setEndian (int endianFormat)

Determine and set the endian format (big or little).