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