Loading...
Searching...
No Matches
casacore::TableCache Class Reference
tables package (libcasa_tables) » Tables_module » Tables_module_internal_classes

More...

`#include <TableCache.h>`

## Public Member Functions

| TableCache ()
| Construct an empty cache of open tables.
| ~TableCache ()
| TableCache (const TableCache &)=delete
| The copy constructor is forbidden.
TableCache & | operator= (const TableCache &)=delete
| The assignment operator is forbidden.
PlainTable * | operator() (const String &tableName) const
| Try to find a table with the given name in the cache.
void | define (const String &tableName, PlainTable *)
| Add an open table to the cache.
void | remove (const String &tableName)
| Remove an open table.
void | rename (const String &newName, const String &oldName)
| Rename an open table.
uInt | nAutoLocks ()
| Determine the number of locked tables opened with the AutoLock option (Locked table means locked for read and/or write).
void | relinquishAutoLocks (Bool all)
| Unlock locked tables opened with the AutoLock option.
Vector< String > | getTableNames () const
| Get the names of the tables in the cache.
Vector< String > | getLockedTables (FileLocker::LockType, int lockOption)
| Get the names of tables locked in this process.
void | flushTable (const String &tableName, Bool fsync, Bool recursive)
| Flush a possibly cached Table.
PlainTable * | lookCache (const String &name, int tableOption, const TableLock &tableInfo)
| Look in the cache if the table is already open.

## Private Member Functions

PlainTable * | getTable (const String &tableName) const
| Get the table without doing a mutex lock (for operator()).

## Private Attributes

std::map< String, void * > | tableMap_p
std::mutex | itsMutex

## Detailed Description

Cache of open tables

### Intended use:

Internal

### Review Status

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

### Etymology

TableCache represents a cache of open tables.

### Synopsis

A TableCache object keeps track of the tables which have already been opened in a program. It maps the name of a table to its PlainTable object. In principle only one TableCache object (statically defined in class PlainTable) exists in a process. The cache is used to prevent a table from being opened more than once, which is not only a waste of space, but more importantly, may give rise to synchronization problems. Synchronization between the same table in multiple processes must be done by a locking mechanism.

TableCache is used by class Table and PlainTable. Before opening a table, Table will first look in the cache. Newly opened or created tables will be added to the cache. When a table is actually closed, it will be removed from the cache.

### Motivation

When a RefTable is read back, it will also read back the table it references. However, that table may have been opened before and it is bad to have a table open more than once in the same program. The TableCache class catches this and will not reopen the table.

### To Do

- Currently only PlainTables are taken into account. Maybe RefTables should be too.

Definition at line 92 of file TableCache.h.

## Constructor & Destructor Documentation

## TableCache() [1/2]

casacore::TableCache::TableCache | ( |  | ) |

Construct an empty cache of open tables.

Referenced by operator=(), and TableCache().

## ~TableCache()

casacore::TableCache::~TableCache | ( |  | ) |

## TableCache() [2/2]

casacore::TableCache::TableCache | ( | const TableCache & |  | ) |

delete

The copy constructor is forbidden.

References TableCache().

## Member Function Documentation

## define()

void casacore::TableCache::define | ( | const String & | tableName,
|  | PlainTable * | )

Add an open table to the cache.

## flushTable()

void casacore::TableCache::flushTable | ( | const String & | tableName,
|  | Bool | fsync,
|  | Bool | recursive )

Flush a possibly cached Table.

## getLockedTables()

Vector< String > casacore::TableCache::getLockedTables | ( | FileLocker::LockType | ,
|  | int | lockOption )

Get the names of tables locked in this process.

By default all locked tables are given (note that a write lock implies a read lock), but it is possible to select on lock type FileLocker::Write and on option (TableLock::AutoLocking, TableLock::ReadLocking, or TableLock::PermanentLocking).

## getTable()

PlainTable * casacore::TableCache::getTable | ( | const String & | tableName | ) | const

private

Get the table without doing a mutex lock (for operator()).

## getTableNames()

Vector< String > casacore::TableCache::getTableNames | ( |  | ) | const

Get the names of the tables in the cache.

## lookCache()

PlainTable * casacore::TableCache::lookCache | ( | const String & | name,
|  | int | tableOption,
|  | const TableLock & | tableInfo )

Look in the cache if the table is already open.

If so, check if table option matches. If needed reopen the table for read/write and merge the lock options.

References casacore::name().

## nAutoLocks()

uInt casacore::TableCache::nAutoLocks | ( |  | ) |

Determine the number of locked tables opened with the AutoLock option (Locked table means locked for read and/or write).

## operator()()

PlainTable * casacore::TableCache::operator() | ( | const String & | tableName | ) | const

Try to find a table with the given name in the cache.

Return a pointer to a table if found (thus if already open). Return a zero pointer if not found.

## operator=()

TableCache & casacore::TableCache::operator= | ( | const TableCache & |  | ) |

delete

The assignment operator is forbidden.

References TableCache().

## relinquishAutoLocks()

void casacore::TableCache::relinquishAutoLocks | ( | Bool | all | ) |

Unlock locked tables opened with the AutoLock option.

If all=True all such tables will be unlocked. If all=False only tables requested by another process will be unlocked.

References casacore::all().

## remove()

void casacore::TableCache::remove | ( | const String & | tableName | ) |

Remove an open table.

## rename()

void casacore::TableCache::rename | ( | const String & | newName,
|  | const String & | oldName )

Rename an open table.

If oldName is not in the cache, nothing will be done.

## Member Data Documentation

## itsMutex

std::mutex casacore::TableCache::itsMutex

mutable private

Definition at line 162 of file TableCache.h.

## tableMap_p

std::map<String,void*> casacore::TableCache::tableMap_p

private

Definition at line 160 of file TableCache.h.

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

- tables/Tables/TableCache.h