casacore
Loading...
Searching...
No Matches
MemoryTable.h
Go to the documentation of this file.
1//# MemoryTable.h: Class for a table held in memory
2//# Copyright (C) 2003
3//# Associated Universities, Inc. Washington DC, USA.
4//#
5//# This library is free software; you can redistribute it and/or modify it
6//# under the terms of the GNU Library General Public License as published by
7//# the Free Software Foundation; either version 2 of the License, or (at your
8//# option) any later version.
9//#
10//# This library is distributed in the hope that it will be useful, but WITHOUT
11//# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12//# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13//# License for more details.
14//#
15//# You should have received a copy of the GNU Library General Public License
16//# along with this library; if not, write to the Free Software Foundation,
17//# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18//#
19//# Correspondence concerning AIPS++ should be addressed as follows:
20//# Internet email: casa-feedback@nrao.edu.
21//# Postal address: AIPS++ Project Office
22//# National Radio Astronomy Observatory
23//# 520 Edgemont Road
24//# Charlottesville, VA 22903-2475 USA
25
26#ifndef TABLES_MEMORYTABLE_H
27#define TABLES_MEMORYTABLE_H
28
29
30//# Includes
31#include <casacore/casa/aips.h>
32#include <casacore/tables/Tables/BaseTable.h>
33#include <casacore/casa/BasicSL/String.h>
34#include <casacore/casa/Arrays/Vector.h>
35
36namespace casacore { //# NAMESPACE CASACORE - BEGIN
37
38//# Forward Declarations
39class SetupNewTable;
40class ColumnSet;
41class TableLockData;
42
43
44// <summary>
45// Class for a table held in memory
46// </summary>
47
48// <use visibility=local>
49
50// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
51// </reviewed>
52
53// <prerequisite>
54//# Classes you should understand before using this one.
55// <li> BaseTable
56// </prerequisite>
57
58// <synopsis>
59// MemoryTable holds all its data in memory.
60// It means that the data is not persistent. However, it can be copied to
61// another table to make the data persistent.
62// Furthermore it is a table as all other tables, so all table functions
63// can be applied to it. Some functions (e.g. lock) won't do anything.
64// Also all table operations like sorting, selecting, and iterating can
65// be used.
66//
67// The constructor accepts a SetupNewTable object which can contain
68// bindings of columns to any data manager. All bindings to storage
69// managers will be replaced by a binding to the memory based storage
70// manager <linkto class=MemoryStMan>MemoryStMan</linkto>. Also all
71// unbound columns will be bound to MemoryStMan.
72// Thus it is still possible that a column is bound to a virtual column
73// engine like <linkto class=CompressComplex>CompressComplex</linkto>.
74// </synopsis>
75
76//# <todo asof="$DATE:$">
77//# </todo>
78
79
80class MemoryTable : public BaseTable
81{
82public:
83
84 // Create the table in memory using the definitions in the
85 // SetupNewTable object.
86 MemoryTable (SetupNewTable&, rownr_t nrrow, Bool initialize);
87
88 // The destructor deletes all data.
89 virtual ~MemoryTable();
90
91 // Copy constructor is forbidden, because copying a table requires
92 // some more knowledge (like table name of result).
93 MemoryTable (const MemoryTable&) = delete;
94
95 // Assignment is forbidden, because copying a table requires
96 // some more knowledge (like table name of result).
98
99 // Try to reopen the table (the underlying one) for read/write access.
100 // It does nothing.
101 virtual void reopenRW();
102
103 // Is the table stored in big or little endian format?
104 // It returns the endian format of the machine.
105 virtual Bool asBigEndian() const;
106
107 // Get the storage option used for the table.
108 virtual const StorageOption& storageOption() const;
109
110 // Is the table in use (i.e. open) in another process?
111 // It always returns False.
112 virtual Bool isMultiUsed (Bool checkSubTable) const;
113
114 // Get the locking info.
115 // It returns PermanentLocking.
116 virtual const TableLock& lockOptions() const;
117
118 // Merge the given lock info with the existing one.
119 // It does nothing.
120 virtual void mergeLock (const TableLock& lockOptions);
121
122 // Has this process the read or write lock, thus can the table
123 // be read or written safely?
124 // It always returns True.
126
127 // Locking the table is a no-op.
128 virtual Bool lock (FileLocker::LockType, uInt nattempts);
129
130 // Unlocking the table is a no-op.
131 virtual void unlock();
132
133 // Flushing the table is a no-op.
134 virtual void flush (Bool fsync, Bool recursive);
135
136 // Resyncing the Table is a no-op.
137 virtual void resync();
138
139 // Get the modify counter. It always returns 0.
140 virtual uInt getModifyCounter() const;
141
142 // Test if the table is opened as writable. It always returns True.
143 virtual Bool isWritable() const;
144
145 // Copy the table and all its subtables.
146 // It copies the contents of each row to get a real copy.
147 // <group>
148 virtual void copy (const String& newName, int tableOption) const;
149 virtual void deepCopy (const String& newName,
150 const Record& dataManagerInfo,
151 const StorageOption&,
152 int tableOption, Bool, int endianFormat,
153 Bool noRows) const;
154 // </group>
155
156 // Rename the table. The tableOption is ignored.
157 virtual void rename (const String& newName, int tableOption);
158
159 // Get the table type (Table::Memory).
160 virtual int tableType() const;
161
162 // Get the actual table description.
163 virtual TableDesc actualTableDesc() const;
164
165 // Get the data manager info.
166 virtual Record dataManagerInfo() const;
167
168 // Get readonly access to the table keyword set.
170
171 // Get read/write access to the table keyword set.
173
174 // Write the TableInfo object. It does not do anything.
175 virtual void flushTableInfo();
176
177 // Get a column object using its index.
178 virtual BaseColumn* getColumn (uInt columnIndex) const;
179
180 // Get a column object using its name.
181 virtual BaseColumn* getColumn (const String& columnName) const;
182
183 // Test if it is possible to add a row to this table (yes).
184 virtual Bool canAddRow() const;
185
186 // Add one or more rows and possibly initialize them.
187 // This will fail for tables not supporting addition of rows.
188 virtual void addRow (rownr_t nrrow = 1, Bool initialize = True);
189
190 // Test if it is possible to remove a row from this table (yes).
191 virtual Bool canRemoveRow() const;
192
193 // Remove the given row.
194 virtual void removeRow (rownr_t rownr);
195
196 // Add a column to the table.
197 // If the DataManager is not a virtual engine, MemoryStMan will be used.
198 // The last Bool argument is not used in MemoryTable, but can be used in
199 // other classes derived from BaseTable.
200 // <group>
201 virtual void addColumn (const ColumnDesc& columnDesc, Bool addToParent);
202 virtual void addColumn (const ColumnDesc& columnDesc,
203 const String& dataManager, Bool byName,
204 Bool addToParent);
205 virtual void addColumn (const ColumnDesc& columnDesc,
206 const DataManager& dataManager, Bool addToParent);
207 virtual void addColumn (const TableDesc& tableDesc,
208 const DataManager& dataManager, Bool addToParent);
209 // </group>
210
211 // Test if columns can be removed (yes).
212 virtual Bool canRemoveColumn (const Vector<String>& columnNames) const;
213
214 // Remove columns.
215 virtual void removeColumn (const Vector<String>& columnNames);
216
217 // Test if a column can be renamed (yes).
218 virtual Bool canRenameColumn (const String& columnName) const;
219
220 // Rename a column.
221 virtual void renameColumn (const String& newName, const String& oldName);
222
223 // Rename a hypercolumn.
224 virtual void renameHypercolumn (const String& newName,
225 const String& oldName);
226
227 // Find the data manager with the given name or for the given column.
228 // There is only one storage manager (MemoryStMan) with name MSM.
229 virtual DataManager* findDataManager (const String& name,
230 Bool byColumn) const;
231
232
233private:
234 std::shared_ptr<ColumnSet> colSetPtr_p; //# pointer to set of columns
235 TableLockData* lockPtr_p; //# pointer to lock object
236
237 // Setup the main parts of the object.
238 // <br>Create the initial name map from the table description.
239 // This map maps a name to the name in the original table.
240 // A rename might change the map.
241 // <br>Create the RefColumn objects.
242 // <br>Create the initial TableInfo as a copy of the original BaseTable.
243 void setup (BaseTable* btp);
244};
245
246
247
248} //# NAMESPACE CASACORE - END
249
250#endif
const TableDesc & tableDesc() const
Get the table description.
Definition BaseTable.h:272
int tableOption() const
Get the table option.
Definition BaseTable.h:253
Abstract base class for a data manager.
LockType
Define the possible lock types.
Definition FileLocker.h:93
virtual BaseColumn * getColumn(uInt columnIndex) const
Get a column object using its index.
virtual void flushTableInfo()
Write the TableInfo object.
virtual Bool canAddRow() const
Test if it is possible to add a row to this table (yes).
virtual Record dataManagerInfo() const
Get the data manager info.
virtual TableRecord & keywordSet()
Get readonly access to the table keyword set.
virtual const StorageOption & storageOption() const
Get the storage option used for the table.
MemoryTable & operator=(const MemoryTable &)=delete
Assignment is forbidden, because copying a table requires some more knowledge (like table name of res...
virtual TableRecord & rwKeywordSet()
Get read/write access to the table keyword set.
virtual void copy(const String &newName, int tableOption) const
Copy the table and all its subtables.
virtual void mergeLock(const TableLock &lockOptions)
Merge the given lock info with the existing one.
virtual void flush(Bool fsync, Bool recursive)
Flushing the table is a no-op.
virtual void renameHypercolumn(const String &newName, const String &oldName)
Rename a hypercolumn.
virtual void addColumn(const ColumnDesc &columnDesc, const DataManager &dataManager, Bool addToParent)
virtual Bool isMultiUsed(Bool checkSubTable) const
Is the table in use (i.e.
virtual void addColumn(const ColumnDesc &columnDesc, Bool addToParent)
Add a column to the table.
virtual void deepCopy(const String &newName, const Record &dataManagerInfo, const StorageOption &, int tableOption, Bool, int endianFormat, Bool noRows) const
virtual void removeColumn(const Vector< String > &columnNames)
Remove columns.
virtual Bool hasLock(FileLocker::LockType) const
Has this process the read or write lock, thus can the table be read or written safely?...
virtual void removeRow(rownr_t rownr)
Remove the given row.
MemoryTable(SetupNewTable &, rownr_t nrrow, Bool initialize)
Create the table in memory using the definitions in the SetupNewTable object.
virtual DataManager * findDataManager(const String &name, Bool byColumn) const
Find the data manager with the given name or for the given column.
virtual uInt getModifyCounter() const
Get the modify counter.
virtual void resync()
Resyncing the Table is a no-op.
virtual void addColumn(const TableDesc &tableDesc, const DataManager &dataManager, Bool addToParent)
std::shared_ptr< ColumnSet > colSetPtr_p
TableLockData * lockPtr_p
virtual Bool canRenameColumn(const String &columnName) const
Test if a column can be renamed (yes).
virtual BaseColumn * getColumn(const String &columnName) const
Get a column object using its name.
virtual Bool asBigEndian() const
Is the table stored in big or little endian format? It returns the endian format of the machine.
MemoryTable(const MemoryTable &)=delete
Copy constructor is forbidden, because copying a table requires some more knowledge (like table name ...
virtual const TableLock & lockOptions() const
Get the locking info.
void setup(BaseTable *btp)
Setup the main parts of the object.
virtual void unlock()
Unlocking the table is a no-op.
virtual void renameColumn(const String &newName, const String &oldName)
Rename a column.
virtual int tableType() const
Get the table type (Table::Memory).
virtual ~MemoryTable()
The destructor deletes all data.
virtual Bool lock(FileLocker::LockType, uInt nattempts)
Locking the table is a no-op.
virtual Bool canRemoveRow() const
Test if it is possible to remove a row from this table (yes).
virtual Bool isWritable() const
Test if the table is opened as writable.
virtual void addColumn(const ColumnDesc &columnDesc, const String &dataManager, Bool byName, Bool addToParent)
virtual void rename(const String &newName, int tableOption)
Rename the table.
virtual void addRow(rownr_t nrrow=1, Bool initialize=True)
Add one or more rows and possibly initialize them.
virtual void reopenRW()
Try to reopen the table (the underlying one) for read/write access.
virtual Bool canRemoveColumn(const Vector< String > &columnNames) const
Test if columns can be removed (yes).
virtual TableDesc actualTableDesc() const
Get the actual table description.
Create a new table - define shapes, data managers, etc.
String: the storage and methods of handling collections of characters.
Definition String.h:223
this file contains all the compiler specific defines
Definition mainpage.dox:28
unsigned int uInt
Definition aipstype.h:49
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
const Bool True
Definition aipstype.h:41
uInt64 rownr_t
Define the type of a row number in a table.
Definition aipsxtype.h:44