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