casacore
Loading...
Searching...
No Matches
VirtColEng.h
Go to the documentation of this file.
1// # VirtColEng.h: Abstract base class for virtual column handling
2// # Copyright (C) 1994,1995,1996,1997,1999,2001
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_VIRTCOLENG_H
27#define TABLES_VIRTCOLENG_H
28
29// # Includes
30#include <casacore/casa/aips.h>
31#include <casacore/tables/DataMan/DataManager.h>
32
33namespace casacore { // # NAMESPACE CASACORE - BEGIN
34
35// # Forward Declarations
36
37// <summary>
38// Abstract base class for virtual column handling
39// </summary>
40
41// <use visibility=local>
42
43// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
44// </reviewed>
45
46// <prerequisite>
47// # Classes you should understand before using this one.
48// <li> DataManager
49// <li> Table
50// </prerequisite>
51
52// <etymology>
53// VirtualColumnEngine is the abstract data manager class for specialized
54// classes (engines) handling a group of virtual columns.
55// </etymology>
56
57// <synopsis>
58// VirtualColumnEngine is the data manager for classes handling
59// a group of virtual columns in tables. It is an abstract base class
60// for the specialized virtual column engines.
61// Each virtual column as such is represented by a class which has
62// to be derived from the abstract base classes VirtualScalarColumn
63// or VirtualArrayColumn. The engine has to create the various
64// column objects via the functions makeXXXColumn.
65//
66// Initialization of the virtual column engine is done by the
67// functions create (for new tables), open (for existing tables) and prepare.
68// The engine can be flushed by the function flush, which allows to
69// write some data. The function open can read these data back.
70// VirtualColumnEngine is closely related with the table system.
71//
72// A number of (pure) virtual functions have been defined. The pure
73// virtual functions must be implemented in the derived class.
74// The non-pure virtual functions have a default implementation throwing
75// a "not possible" exception. They need to be implemented if they
76// are used for this engine (e.g. makeIndArrColumn does not need to
77// be implemented if the engine does not handle arrays).
78// Furthermore the pure virtual function dataManagerType (defined in
79// DataManager.h) has to be implemented. This should return the name
80// of the data manager, which is usually its class name. This name
81// has to be unique; so if the engine is templated, the template
82// parameter has to be part of the data manager name.
83//
84// The engine has to be registered before it can be used by the table system.
85// This means that a special makeObject function has to be made
86// known to the table system, which allows the table system to
87// reconstruct the engine using its name.
88//
89// An example of a virtual column engine can be found in dVirtColEng.{h,cc}
90// in the test directory of the Tables module.
91// Another exanple is class ScaledComplexData.
92// </synopsis>
93
94// <motivation>
95// It is nice if a table column can be expressed as a function
96// of other columns (maybe even in other tables). A virtual column
97// provides this functionality in a very flexible way.
98// A specialized class can calculate the data of a virtual column,
99// but a common base class is required to interface it to the
100// table system.
101// </motivation>
102
103// <todo asof="$DATE:$">
104// # A List of bugs, limitations, extensions or planned refinements.
105// </todo>
106
108 public:
109 // Create the object.
111
113
114 // The copy constructor cannot be used for this base class.
115 // The clone function should be used instead.
117
118 // Assignment cannot be used for this base class.
120
121 private:
122 // The data manager is not a storage manager?
123 virtual Bool isStorageManager() const;
124
125 // Does the data manager allow to add rows? (default no)
126 virtual Bool canAddRow() const;
127
128 // Does the data manager allow to delete rows? (default no)
129 virtual Bool canRemoveRow() const;
130
131 // Add rows to all columns.
132 // The default implementation does nothing.
133 virtual void addRow64(rownr_t nrrow);
134
135 // Delete a row from all columns.
136 // The default implementation does nothing.
137 virtual void removeRow64(rownr_t rownr);
138
139 // Flush the data in the engine object.
140 // If the object contains persistent data, this is the place to write them.
141 // This can be done in two ways:
142 // <ul>
143 // <li>
144 // They can be written in the main table file (using the AipsIO argument).
145 // This should preferably be used if the object contains only little data.
146 // <li>
147 // They can be written in a file of its own. A unique filename
148 // can be acquired using DataManager::fileName().
149 // This way is preferred when the object contains a lot of data.
150 // Possibly this file could already be created in function create
151 // and only be flushed and closed in this function. This allows
152 // getting and putting of data as needed.
153 // </ul>
154 // Another way of storing information is by storing it as a keyword
155 // in the table. In this case it is important to know that close
156 // is called AFTER the keywords are written. Thus, in this way the
157 // information has to be stored and read back in create, open and/or
158 // prepare.
159 // It returns a True status if it had to flush (i.e. if data have changed).
160 // <br>The default implementation does nothing and returns False.
161 virtual Bool flush(AipsIO&, Bool fsync);
162
163 // Resync the storage manager with the new file contents.
164 // This is done by clearing the cache.
165 // The default implementation does nothing.
166 virtual rownr_t resync64(rownr_t nrrow);
167
168 // Initialize the object for a new table containing initially nrrow rows.
169 // It can be used to initialize variables (possibly using data
170 // from other columns in the table).
171 // The default implementation does nothing.
172 virtual void create64(rownr_t initialNrrow);
173
174 // Initialize the object for an existing table containing nrrow rows.
175 // It can be used to read values back (written by close) and/or
176 // to initialize variables (possibly using data from other columns
177 // in the table).
178 // The default implementation does nothing.
179 virtual rownr_t open64(rownr_t nrrow, AipsIO& mainTableFile);
180
181 // Let the data manager initialize itself further.
182 // Prepare is called after create/open has been called for all
183 // columns. In this way one can be sure that referenced columns
184 // are read back and partly initialized.
185 // The default implementation does nothing.
186 virtual void prepare();
187
188 // The data manager will be deleted (because all its columns are
189 // requested to be deleted).
190 // So clean up the things needed (e.g. delete files).
191 // By default it assumes that nothing has to be done.
192 virtual void deleteManager();
193
194 // Make a column object in the engine on behalf of a table column.
195 // This column object class is derived from VirtualScalarColumn
196 // or VirtualArrayColumn. It handles the gets and puts of data.
197 // <group>
198 // Create a scalar column.
199 // The default implementation throws an exception that it cannot
200 // do it for this column.
201 virtual DataManagerColumn* makeScalarColumn(const String& columnName, int dataType,
202 const String& dataTypeId);
203 // Create a direct array column.
204 // The default implementation calls makeIndArrColumn
205 // (when reading the user sees no difference between direct and indirect).
206 virtual DataManagerColumn* makeDirArrColumn(const String& columnName, int dataType,
207 const String& dataTypeId);
208 // Create an indirect array column.
209 // The default implementation throws an exception that it cannot
210 // do it for this column.
211 virtual DataManagerColumn* makeIndArrColumn(const String& columnName, int dataType,
212 const String& dataTypeId);
213 // </group>
214};
215
216} // namespace casacore
217
218#endif
DataManager()
Default constructor.
String: the storage and methods of handling collections of characters.
Definition String.h:355
virtual void prepare()
Let the data manager initialize itself further.
virtual DataManagerColumn * makeScalarColumn(const String &columnName, int dataType, const String &dataTypeId)
Make a column object in the engine on behalf of a table column.
VirtualColumnEngine & operator=(const VirtualColumnEngine &)=delete
Assignment cannot be used for this base class.
VirtualColumnEngine()
Create the object.
Definition VirtColEng.h:110
virtual Bool flush(AipsIO &, Bool fsync)
Flush the data in the engine object.
virtual Bool canRemoveRow() const
Does the data manager allow to delete rows?
virtual rownr_t open64(rownr_t nrrow, AipsIO &mainTableFile)
Initialize the object for an existing table containing nrrow rows.
virtual Bool isStorageManager() const
The data manager is not a storage manager?
virtual void deleteManager()
The data manager will be deleted (because all its columns are requested to be deleted).
virtual DataManagerColumn * makeIndArrColumn(const String &columnName, int dataType, const String &dataTypeId)
Create an indirect array column.
virtual void removeRow64(rownr_t rownr)
Delete a row from all columns.
virtual rownr_t resync64(rownr_t nrrow)
Resync the storage manager with the new file contents.
virtual DataManagerColumn * makeDirArrColumn(const String &columnName, int dataType, const String &dataTypeId)
Create a direct array column.
virtual void addRow64(rownr_t nrrow)
Add rows to all columns.
virtual void create64(rownr_t initialNrrow)
Initialize the object for a new table containing initially nrrow rows.
VirtualColumnEngine(const VirtualColumnEngine &)=delete
The copy constructor cannot be used for this base class.
virtual Bool canAddRow() const
Does the data manager allow to add rows?
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
uInt64 rownr_t
Define the type of a row number in a table.
Definition aipsxtype.h:44
DataType dataType(const RecordFieldId &) const