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// # Includes
30#include <casacore/casa/aips.h>
31#include <casacore/tables/Tables/BaseTable.h>
32#include <casacore/casa/BasicSL/String.h>
33#include <casacore/casa/Arrays/Vector.h>
34
35namespace casacore { // # NAMESPACE CASACORE - BEGIN
36
37// # Forward Declarations
38class SetupNewTable;
39class ColumnSet;
40class TableLockData;
41
42// <summary>
43// Class for a table held in memory
44// </summary>
45
46// <use visibility=local>
47
48// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
49// </reviewed>
50
51// <prerequisite>
52// # Classes you should understand before using this one.
53// <li> BaseTable
54// </prerequisite>
55
56// <synopsis>
57// MemoryTable holds all its data in memory.
58// It means that the data is not persistent. However, it can be copied to
59// another table to make the data persistent.
60// Furthermore it is a table as all other tables, so all table functions
61// can be applied to it. Some functions (e.g. lock) won't do anything.
62// Also all table operations like sorting, selecting, and iterating can
63// be used.
64//
65// The constructor accepts a SetupNewTable object which can contain
66// bindings of columns to any data manager. All bindings to storage
67// managers will be replaced by a binding to the memory based storage
68// manager <linkto class=MemoryStMan>MemoryStMan</linkto>. Also all
69// unbound columns will be bound to MemoryStMan.
70// Thus it is still possible that a column is bound to a virtual column
71// engine like <linkto class=CompressComplex>CompressComplex</linkto>.
72// </synopsis>
73
74// # <todo asof="$DATE:$">
75// # </todo>
76
77class MemoryTable : public BaseTable {
78 public:
79 // Create the table in memory using the definitions in the
80 // SetupNewTable object.
81 MemoryTable(SetupNewTable&, rownr_t nrrow, Bool initialize);
82
83 // The destructor deletes all data.
84 virtual ~MemoryTable();
85
86 // Copy constructor is forbidden, because copying a table requires
87 // some more knowledge (like table name of result).
88 MemoryTable(const MemoryTable&) = delete;
89
90 // Assignment is forbidden, because copying a table requires
91 // some more knowledge (like table name of result).
93
94 // Try to reopen the table (the underlying one) for read/write access.
95 // It does nothing.
96 virtual void reopenRW();
97
98 // Is the table stored in big or little endian format?
99 // It returns the endian format of the machine.
100 virtual Bool asBigEndian() const;
101
102 // Get the storage option used for the table.
103 virtual const StorageOption& storageOption() const;
104
105 // Is the table in use (i.e. open) in another process?
106 // It always returns False.
107 virtual Bool isMultiUsed(Bool checkSubTable) const;
108
109 // Get the locking info.
110 // It returns PermanentLocking.
111 virtual const TableLock& lockOptions() const;
112
113 // Merge the given lock info with the existing one.
114 // It does nothing.
115 virtual void mergeLock(const TableLock& lockOptions);
116
117 // Has this process the read or write lock, thus can the table
118 // be read or written safely?
119 // It always returns True.
121
122 // Locking the table is a no-op.
123 virtual Bool lock(FileLocker::LockType, uInt nattempts);
124
125 // Unlocking the table is a no-op.
126 virtual void unlock();
127
128 // Flushing the table is a no-op.
129 virtual void flush(Bool fsync, Bool recursive);
130
131 // Resyncing the Table is a no-op.
132 virtual void resync();
133
134 // Get the modify counter. It always returns 0.
135 virtual uInt getModifyCounter() const;
136
137 // Test if the table is opened as writable. It always returns True.
138 virtual Bool isWritable() const;
139
140 // Copy the table and all its subtables.
141 // It copies the contents of each row to get a real copy.
142 // <group>
143 virtual void copy(const String& newName, int tableOption) const;
144 virtual void deepCopy(const String& newName, const Record& dataManagerInfo, const StorageOption&,
145 int tableOption, Bool, int endianFormat, Bool noRows) const;
146 // </group>
147
148 // Rename the table. The tableOption is ignored.
149 virtual void rename(const String& newName, int tableOption);
150
151 // Get the table type (Table::Memory).
152 virtual int tableType() const;
153
154 // Get the actual table description.
155 virtual TableDesc actualTableDesc() const;
156
157 // Get the data manager info.
158 virtual Record dataManagerInfo() const;
159
160 // Get readonly access to the table keyword set.
162
163 // Get read/write access to the table keyword set.
165
166 // Write the TableInfo object. It does not do anything.
167 virtual void flushTableInfo();
168
169 // Get a column object using its index.
170 virtual BaseColumn* getColumn(uInt columnIndex) const;
171
172 // Get a column object using its name.
173 virtual BaseColumn* getColumn(const String& columnName) const;
174
175 // Test if it is possible to add a row to this table (yes).
176 virtual Bool canAddRow() const;
177
178 // Add one or more rows and possibly initialize them.
179 // This will fail for tables not supporting addition of rows.
180 virtual void addRow(rownr_t nrrow = 1, Bool initialize = True);
181
182 // Test if it is possible to remove a row from this table (yes).
183 virtual Bool canRemoveRow() const;
184
185 // Remove the given row.
186 virtual void removeRow(rownr_t rownr);
187
188 // Add a column to the table.
189 // If the DataManager is not a virtual engine, MemoryStMan will be used.
190 // The last Bool argument is not used in MemoryTable, but can be used in
191 // other classes derived from BaseTable.
192 // <group>
193 virtual void addColumn(const ColumnDesc& columnDesc, Bool addToParent);
194 virtual void addColumn(const ColumnDesc& columnDesc, const String& dataManager, Bool byName,
195 Bool addToParent);
196 virtual void addColumn(const ColumnDesc& columnDesc, const DataManager& dataManager,
197 Bool addToParent);
198 virtual void addColumn(const TableDesc& tableDesc, const DataManager& dataManager,
199 Bool addToParent);
200 // </group>
201
202 // Test if columns can be removed (yes).
203 virtual Bool canRemoveColumn(const Vector<String>& columnNames) const;
204
205 // Remove columns.
206 virtual void removeColumn(const Vector<String>& columnNames);
207
208 // Test if a column can be renamed (yes).
209 virtual Bool canRenameColumn(const String& columnName) const;
210
211 // Rename a column.
212 virtual void renameColumn(const String& newName, const String& oldName);
213
214 // Rename a hypercolumn.
215 virtual void renameHypercolumn(const String& newName, const String& oldName);
216
217 // Find the data manager with the given name or for the given column.
218 // There is only one storage manager (MemoryStMan) with name MSM.
219 virtual DataManager* findDataManager(const String& name, Bool byColumn) const;
220
221 private:
222 std::shared_ptr<ColumnSet> colSetPtr_p; // # pointer to set of columns
223 TableLockData* lockPtr_p; // # pointer to lock object
224
225 // Setup the main parts of the object.
226 // <br>Create the initial name map from the table description.
227 // This map maps a name to the name in the original table.
228 // A rename might change the map.
229 // <br>Create the RefColumn objects.
230 // <br>Create the initial TableInfo as a copy of the original BaseTable.
231 void setup(BaseTable* btp);
232};
233
234} // namespace casacore
235
236#endif
const TableDesc & tableDesc() const
Get the table description.
Definition BaseTable.h:261
BaseTable(const String &tableName, int tableOption, rownr_t nrrow)
Initialize the object.
int tableOption() const
Get the table option.
Definition BaseTable.h:244
Abstract base class for a data manager.
LockType
Define the possible lock types.
Definition FileLocker.h:89
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?
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:355
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
unsigned int uInt
Definition aipstype.h:49
String name() const
Return the name of the field.
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