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