casacore
Loading...
Searching...
No Matches
StIndArrAIO.h
Go to the documentation of this file.
1// # StIndArrAIO.h: AipsIO storage manager for indirect table arrays
2// # Copyright (C) 1994,1995,1996,1997,1999
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_STINDARRAIO_H
27#define TABLES_STINDARRAIO_H
28
29// # Includes
30#include <casacore/casa/aips.h>
31#include <casacore/tables/DataMan/StManAipsIO.h>
32#include <casacore/casa/Arrays/IPosition.h>
33#include <casacore/casa/IO/ByteIO.h>
34
35namespace casacore { // # NAMESPACE CASACORE - BEGIN
36
37// # Forward Declarations
38class AipsIO;
39class StManArrayFile;
40class StIndArray;
41
42// <summary>
43// AipsIO storage manager for indirect table arrays
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> StManAipsIO
54// <li> StManColumnAipsIO
55// <li> StIndArray
56// </prerequisite>
57
58// <etymology>
59// StManColumnIndArrayAipsIO handles the access to an indirect array
60// in a table column using the AipsIO storage manager.
61// </etymology>
62
63// <synopsis>
64// StManColumnArrayAipsIO handles indirect arrays in a table column.
65// An StManArrayFile object is used to read and write the arrays
66// from/into a file in a simple way. So this column has a file of its own
67// to store the actual data in. It uses the (unique) column sequence
68// number to make the file name unique.
69//
70// An array (or section of an array) is only read when needed.
71// It, however, caches the array shape using the helper class
72// StIndArray. Pointers to these objects
73// are maintained using the standard StManColumnAipsIO facilities.
74// When the column gets written, the offsets in the StManArrayFile file
75// get written. Those will be read back when the column is read in.
76//
77// When a row gets deleted or when the array gets bigger, the file space
78// is lost. This storage manager is a simple one and no attempts
79// are done to make it smart.
80// </synopsis>
81
82// <motivation>
83// StManColumnIndArrayAipsIO handles the standard data types. The class
84// is not templated, but a switch statement is used instead.
85// Templates would cause too many instantiations.
86// </motivation>
87
88// <todo asof="$DATE:$">
89// # A List of bugs, limitations, extensions or planned refinements.
90// </todo>
91
93 public:
94 // Create a column of the given type.
95 // The StManArrayFile object is not allocated here but by doCreate.
97
98 // Frees up the storage and delete the StManArrayFile object.
100
101 // Forbid copy constructor.
103
104 // Forbid assignment.
106
107 // Set the (fixed) shape of the arrays in the entire column.
108 virtual void setShapeColumn(const IPosition& shape);
109
110 // Add (newNrrow-oldNrrow) rows to the column.
111 // Allocate the data arrays in these rows if the shape is fixed.
112 virtual void addRow(rownr_t newNrrow, rownr_t oldNrrow);
113
114 // Set the shape of the array in the given row and allocate the array
115 // in the file.
116 virtual void setShape(rownr_t rownr, const IPosition& shape);
117
118 // Is the shape defined (i.e. is there an array) in this row?
120
121 // Get the dimensionality of the item in the given row.
122 // 0 is returned if there is no array.
123 virtual uInt ndim(rownr_t rownr);
124
125 // Get the shape of the array in the given row.
126 // An zero-length IPosition is returned if there is no array.
127 virtual IPosition shape(rownr_t rownr);
128
129 // This storage manager can handle changing array shapes
130 // for non-FixedShape columns.
131 virtual Bool canChangeShape() const;
132
133 // Get an array value in the given row.
134 // The buffer pointed to by dataPtr has to have the correct length
135 // (which is guaranteed by the ArrayColumn get function).
136 virtual void getArrayV(rownr_t rownr, ArrayBase& dataPtr);
137
138 // Put an array value into the given row.
139 // The buffer pointed to by dataPtr has to have the correct length
140 // (which is guaranteed by the ArrayColumn put function).
141 virtual void putArrayV(rownr_t rownr, const ArrayBase& dataPtr);
142
143 // Get a section of the array in the given row.
144 // The buffer pointed to by dataPtr has to have the correct length
145 // (which is guaranteed by the ArrayColumn getSlice function).
146 virtual void getSliceV(rownr_t rownr, const Slicer&, ArrayBase& dataPtr);
147
148 // Put into a section of the array in the given row.
149 // The buffer pointed to by dataPtr has to have the correct length
150 // (which is guaranteed by the ArrayColumn putSlice function).
151 virtual void putSliceV(rownr_t rownr, const Slicer&, const ArrayBase& dataPtr);
152
153 // Remove the value in the given row.
154 // This will result in lost file space.
155 virtual void remove(rownr_t rownr);
156
157 // Let the column create its array file.
158 virtual void doCreate(rownr_t nrrow);
159
160 // Write the data into AipsIO.
161 // This will call StManColumnAipsIO::putFile which will in its turn
162 // call putData in this class for each of its chunks of data.
163 virtual void putFile(rownr_t nrval, AipsIO&);
164
165 // Read the data from AipsIO.
166 // This will call StManColumnAipsIO::getFile which will in its turn
167 // call getData in this class for each of its chunks of data.
168 virtual void getFile(rownr_t nrval, AipsIO&);
169
170 // Reopen the storage manager files for read/write.
171 virtual void reopenRW();
172
173 // Check if the class invariants still hold.
174 Bool ok() const;
175
176 private:
177 // The storage manager.
179 // The (unique) sequence number of the column.
181 // The shape of all arrays in case it is fixed.
183 // Switch indicating if the shape is fixed.
185 // The version of the object retrieved from a file.
186 // Versions < 2 use a StManArrayFile of their own.
187 // Newer versions share the one in StManAipsIO.
189 // The file containing the indirect arrays.
191
192 // Open the file with the given mode.
194
195 // Delete the array in the given row.
196 void deleteArray(rownr_t rownr);
197
198 // Read the shape at the given row.
199 // This will cache the information in the StIndArray
200 // object for that row.
202
203 // Put the data of a data block.
204 // datap is an array of nrval pointers to StIndArray.
205 // Only the file offsets get written.
206 void putData(void* datap, uInt nrval, AipsIO&);
207
208 // Get file offsets to the arrays into a data block at the given index.
209 // datap is an array of pointers to StIndArray.
210 // nrval blocks will be allocated and read starting at datap[index].
211 // The actual shape and array data will be read when needed.
212 void getData(void* datap, uInt index, uInt nrval, AipsIO&, uInt version);
213};
214
215} // namespace casacore
216
217#endif
Non-templated base class for templated Array class.
Definition ArrayBase.h:69
OpenOption
Define the possible ByteIO open options.
Definition ByteIO.h:60
AipsIO table storage manager class.
StManColumnAipsIO(StManAipsIO *stMan, int dataType, Bool byPtr)
Create a column of the given type.
IPosition fixedShape_p
The shape of all arrays in case it is fixed.
Bool ok() const
Check if the class invariants still hold.
virtual IPosition shape(rownr_t rownr)
Get the shape of the array in the given row.
StManColumnIndArrayAipsIO(const StManColumnIndArrayAipsIO &)=delete
Forbid copy constructor.
uInt seqnr_p
The (unique) sequence number of the column.
virtual ~StManColumnIndArrayAipsIO()
Frees up the storage and delete the StManArrayFile object.
virtual void putFile(rownr_t nrval, AipsIO &)
Write the data into AipsIO.
virtual void doCreate(rownr_t nrrow)
Let the column create its array file.
virtual void remove(rownr_t rownr)
Remove the value in the given row.
virtual void getSliceV(rownr_t rownr, const Slicer &, ArrayBase &dataPtr)
Get a section of the array in the given row.
void getData(void *datap, uInt index, uInt nrval, AipsIO &, uInt version)
Get file offsets to the arrays into a data block at the given index.
void openFile(ByteIO::OpenOption opt)
Open the file with the given mode.
StManColumnIndArrayAipsIO & operator=(const StManColumnIndArrayAipsIO &)=delete
Forbid assignment.
virtual Bool isShapeDefined(rownr_t rownr)
Is the shape defined (i.e.
void putData(void *datap, uInt nrval, AipsIO &)
Put the data of a data block.
virtual void addRow(rownr_t newNrrow, rownr_t oldNrrow)
Add (newNrrow-oldNrrow) rows to the column.
virtual Bool canChangeShape() const
This storage manager can handle changing array shapes for non-FixedShape columns.
virtual void putSliceV(rownr_t rownr, const Slicer &, const ArrayBase &dataPtr)
Put into a section of the array in the given row.
void deleteArray(rownr_t rownr)
Delete the array in the given row.
StManColumnIndArrayAipsIO(StManAipsIO *, int dataType)
Create a column of the given type.
Bool shapeIsFixed_p
Switch indicating if the shape is fixed.
StIndArray * getShape(rownr_t rownr)
Read the shape at the given row.
virtual void putArrayV(rownr_t rownr, const ArrayBase &dataPtr)
Put an array value into the given row.
virtual void getArrayV(rownr_t rownr, ArrayBase &dataPtr)
Get an array value in the given row.
StManAipsIO * staioPtr_p
The storage manager.
virtual uInt ndim(rownr_t rownr)
Get the dimensionality of the item in the given row.
virtual void setShapeColumn(const IPosition &shape)
Set the (fixed) shape of the arrays in the entire column.
virtual void reopenRW()
Reopen the storage manager files for read/write.
StManArrayFile * iosfile_p
The file containing the indirect arrays.
virtual void getFile(rownr_t nrval, AipsIO &)
Read the data from AipsIO.
virtual void setShape(rownr_t rownr, const IPosition &shape)
Set the shape of the array in the given row and allocate the array in the file.
uInt version_p
The version of the object retrieved from a file.
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
unsigned int uInt
Definition aipstype.h:49
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