casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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$
27 
28 #ifndef TABLES_STINDARRAIO_H
29 #define TABLES_STINDARRAIO_H
30 
31 
32 //# Includes
33 #include <casacore/casa/aips.h>
37 
38 namespace casacore { //# NAMESPACE CASACORE - BEGIN
39 
40 //# Forward Declarations
41 class AipsIO;
42 class StManArrayFile;
43 class 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 {
99 public:
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  // It can handle access to a slice in a cell.
109  Bool canAccessSlice (Bool& reask) const;
110 
111  // Set the (fixed) shape of the arrays in the entire column.
112  void setShapeColumn (const IPosition& shape);
113 
114  // Add (newNrrow-oldNrrow) rows to the column.
115  // Allocate the data arrays in these rows if the shape is fixed.
116  void addRow (uInt newNrrow, uInt oldNrrow);
117 
118  // Set the shape of the array in the given row and allocate the array
119  // in the file.
120  void setShape (uInt rownr, const IPosition& shape);
121 
122  // Is the shape defined (i.e. is there an array) in this row?
123  Bool isShapeDefined (uInt rownr);
124 
125  // Get the dimensionality of the item in the given row.
126  // 0 is returned if there is no array.
127  uInt ndim (uInt rownr);
128 
129  // Get the shape of the array in the given row.
130  // An zero-length IPosition is returned if there is no array.
131  IPosition shape (uInt rownr);
132 
133  // This storage manager can handle changing array shapes
134  // for non-FixedShape columns.
135  Bool canChangeShape() const;
136 
137  // Get an array value in the given row.
138  // The buffer pointed to by dataPtr has to have the correct length
139  // (which is guaranteed by the ArrayColumn get function).
140  // <group>
141  void getArrayBoolV (uInt rownr, Array<Bool>* dataPtr);
142  void getArrayuCharV (uInt rownr, Array<uChar>* dataPtr);
143  void getArrayShortV (uInt rownr, Array<Short>* dataPtr);
144  void getArrayuShortV (uInt rownr, Array<uShort>* dataPtr);
145  void getArrayIntV (uInt rownr, Array<Int>* dataPtr);
146  void getArrayuIntV (uInt rownr, Array<uInt>* dataPtr);
147  void getArrayfloatV (uInt rownr, Array<float>* dataPtr);
148  void getArrayInt64V (uInt rownr, Array<Int64>* dataPtr);
149  void getArraydoubleV (uInt rownr, Array<double>* dataPtr);
150  void getArrayComplexV (uInt rownr, Array<Complex>* dataPtr);
151  void getArrayDComplexV (uInt rownr, Array<DComplex>* dataPtr);
152  void getArrayStringV (uInt rownr, Array<String>* dataPtr);
153  // </group>
154 
155  // Put an array value into the given row.
156  // The buffer pointed to by dataPtr has to have the correct length
157  // (which is guaranteed by the ArrayColumn put function).
158  // <group>
159  void putArrayBoolV (uInt rownr, const Array<Bool>* dataPtr);
160  void putArrayuCharV (uInt rownr, const Array<uChar>* dataPtr);
161  void putArrayShortV (uInt rownr, const Array<Short>* dataPtr);
162  void putArrayuShortV (uInt rownr, const Array<uShort>* dataPtr);
163  void putArrayIntV (uInt rownr, const Array<Int>* dataPtr);
164  void putArrayuIntV (uInt rownr, const Array<uInt>* dataPtr);
165  void putArrayInt64V (uInt rownr, const Array<Int64>* dataPtr);
166  void putArrayfloatV (uInt rownr, const Array<float>* dataPtr);
167  void putArraydoubleV (uInt rownr, const Array<double>* dataPtr);
168  void putArrayComplexV (uInt rownr, const Array<Complex>* dataPtr);
169  void putArrayDComplexV (uInt rownr, const Array<DComplex>* dataPtr);
170  void putArrayStringV (uInt rownr, const Array<String>* dataPtr);
171  // </group>
172 
173  // Get a section of the array in the given row.
174  // The buffer pointed to by dataPtr has to have the correct length
175  // (which is guaranteed by the ArrayColumn getSlice function).
176  // <group>
177  void getSliceBoolV (uInt rownr, const Slicer&, Array<Bool>* dataPtr);
178  void getSliceuCharV (uInt rownr, const Slicer&, Array<uChar>* dataPtr);
179  void getSliceShortV (uInt rownr, const Slicer&, Array<Short>* dataPtr);
180  void getSliceuShortV (uInt rownr, const Slicer&, Array<uShort>* dataPtr);
181  void getSliceIntV (uInt rownr, const Slicer&, Array<Int>* dataPtr);
182  void getSliceuIntV (uInt rownr, const Slicer&, Array<uInt>* dataPtr);
183  void getSliceInt64V (uInt rownr, const Slicer&, Array<Int64>* dataPtr);
184  void getSlicefloatV (uInt rownr, const Slicer&, Array<float>* dataPtr);
185  void getSlicedoubleV (uInt rownr, const Slicer&, Array<double>* dataPtr);
186  void getSliceComplexV (uInt rownr, const Slicer&, Array<Complex>* dataPtr);
187  void getSliceDComplexV (uInt rownr, const Slicer&, Array<DComplex>* dataPtr);
188  void getSliceStringV (uInt rownr, const Slicer&, Array<String>* dataPtr);
189  // </group>
190 
191  // Put into a section of the array in the given row.
192  // The buffer pointed to by dataPtr has to have the correct length
193  // (which is guaranteed by the ArrayColumn putSlice function).
194  // <group>
195  void putSliceBoolV (uInt rownr, const Slicer&,
196  const Array<Bool>* dataPtr);
197  void putSliceuCharV (uInt rownr, const Slicer&,
198  const Array<uChar>* dataPtr);
199  void putSliceShortV (uInt rownr, const Slicer&,
200  const Array<Short>* dataPtr);
201  void putSliceuShortV (uInt rownr, const Slicer&,
202  const Array<uShort>* dataPtr);
203  void putSliceIntV (uInt rownr, const Slicer&,
204  const Array<Int>* dataPtr);
205  void putSliceuIntV (uInt rownr, const Slicer&,
206  const Array<uInt>* dataPtr);
207  void putSliceInt64V (uInt rownr, const Slicer&,
208  const Array<Int64>* dataPtr);
209  void putSlicefloatV (uInt rownr, const Slicer&,
210  const Array<float>* dataPtr);
211  void putSlicedoubleV (uInt rownr, const Slicer&,
212  const Array<double>* dataPtr);
213  void putSliceComplexV (uInt rownr, const Slicer&,
214  const Array<Complex>* dataPtr);
215  void putSliceDComplexV (uInt rownr, const Slicer&,
216  const Array<DComplex>* dataPtr);
217  void putSliceStringV (uInt rownr, const Slicer&,
218  const Array<String>* dataPtr);
219  // </group>
220 
221  // Remove the value in the given row.
222  // This will result in lost file space.
223  void remove (uInt rownr);
224 
225  // Let the column create its array file.
226  void doCreate (uInt nrrow);
227 
228  // Write the data into AipsIO.
229  // This will call StManColumnAipsIO::putFile which will in its turn
230  // call putData in this class for each of its chunks of data.
231  void putFile (uInt nrval, AipsIO&);
232 
233  // Read the data from AipsIO.
234  // This will call StManColumnAipsIO::getFile which will in its turn
235  // call getData in this class for each of its chunks of data.
236  void getFile (uInt nrval, AipsIO&);
237 
238  // Reopen the storage manager files for read/write.
239  virtual void reopenRW();
240 
241  // Check if the class invariants still hold.
242  Bool ok() const;
243 
244 private:
245  // The (unique) sequence number of the column.
247  // The shape of all arrays in case it is fixed.
249  // Switch indicating if the shape is fixed.
251  // The version of the object retrieved from a file.
252  // Versions < 2 use a StManArrayFile of their own.
253  // Newer versions share the one in StManAipsIO.
255  // The file containing the indirect arrays.
257 
258 
259  // Open the file with the given mode.
260  void openFile (ByteIO::OpenOption opt);
261 
262  // Delete the array in the given row.
263  void deleteArray (uInt rownr);
264 
265  // Read the shape at the given row.
266  // This will cache the information in the StIndArray
267  // object for that row.
268  StIndArray* getShape (uInt rownr);
269 
270  // Put the data of a data block.
271  // datap is an array of nrval pointers to StIndArray.
272  // Only the file offsets get written.
273  void putData (void* datap, uInt nrval, AipsIO&);
274 
275  // Get file offsets to the arrays into a data block at the given index.
276  // datap is an array of pointers to StIndArray.
277  // nrval blocks will be allocated and read starting at datap[index].
278  // The actual shape and array data will be read when needed.
279  void getData (void* datap, uInt index, uInt nrval, AipsIO&, uInt version);
280 
281  // Forbid copy constructor.
283 
284  // Forbid assignment.
286 };
287 
288 
289 
290 
291 } //# NAMESPACE CASACORE - END
292 
293 #endif
void putSliceDComplexV(uInt rownr, const Slicer &, const Array< DComplex > *dataPtr)
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:119
~StManColumnIndArrayAipsIO()
Frees up the storage and delete the StManArrayFile object.
void putArrayComplexV(uInt rownr, const Array< Complex > *dataPtr)
void putSliceStringV(uInt rownr, const Slicer &, const Array< String > *dataPtr)
void putSliceBoolV(uInt rownr, const Slicer &, const Array< Bool > *dataPtr)
Put into a section of the array in the given row.
void getArrayfloatV(uInt rownr, Array< float > *dataPtr)
void getArrayStringV(uInt rownr, Array< String > *dataPtr)
void getSliceDComplexV(uInt rownr, const Slicer &, Array< DComplex > *dataPtr)
void putArrayInt64V(uInt rownr, const Array< Int64 > *dataPtr)
StManColumnIndArrayAipsIO(StManAipsIO *, int dataType)
Create a column of the given type.
void putSliceuShortV(uInt rownr, const Slicer &, const Array< uShort > *dataPtr)
void getSliceuIntV(uInt rownr, const Slicer &, Array< uInt > *dataPtr)
AipsIO is the object persistency mechanism of Casacore.
Definition: AipsIO.h:168
void getArrayuCharV(uInt rownr, Array< uChar > *dataPtr)
IPosition shape(uInt rownr)
Get the shape of the array in the given row.
Read/write indirect arrays.
Definition: StIndArray.h:141
void getArrayInt64V(uInt rownr, Array< Int64 > *dataPtr)
Bool canAccessSlice(Bool &reask) const
It can handle access to a slice in a cell.
void putSliceIntV(uInt rownr, const Slicer &, const Array< Int > *dataPtr)
uInt version_p
The version of the object retrieved from a file.
Definition: StIndArrAIO.h:254
void getArraydoubleV(uInt rownr, Array< double > *dataPtr)
Bool isShapeDefined(uInt rownr)
Is the shape defined (i.e.
void putSliceuCharV(uInt rownr, const Slicer &, const Array< uChar > *dataPtr)
void getSliceShortV(uInt rownr, const Slicer &, Array< Short > *dataPtr)
void addRow(uInt newNrrow, uInt oldNrrow)
Add (newNrrow-oldNrrow) rows to the column.
void getArrayIntV(uInt rownr, Array< Int > *dataPtr)
void putArrayDComplexV(uInt rownr, const Array< DComplex > *dataPtr)
void getArrayDComplexV(uInt rownr, Array< DComplex > *dataPtr)
StManArrayFile * iosfile_p
The file containing the indirect arrays.
Definition: StIndArrAIO.h:256
virtual void reopenRW()
Reopen the storage manager files for read/write.
int dataType() const
Return the data type of the column.
IPosition fixedShape_p
The shape of all arrays in case it is fixed.
Definition: StIndArrAIO.h:248
void getFile(uInt nrval, AipsIO &)
Read the data from AipsIO.
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.
AipsIO table column storage manager class.
Definition: StManAipsIO.h:106
void getSliceuCharV(uInt rownr, const Slicer &, Array< uChar > *dataPtr)
void putArraydoubleV(uInt rownr, const Array< double > *dataPtr)
void putArrayBoolV(uInt rownr, const Array< Bool > *dataPtr)
Put an array value into the given row.
void putArrayShortV(uInt rownr, const Array< Short > *dataPtr)
void putSliceuIntV(uInt rownr, const Slicer &, const Array< uInt > *dataPtr)
void getArrayBoolV(uInt rownr, Array< Bool > *dataPtr)
Get an array value in the given row.
void putArrayfloatV(uInt rownr, const Array< float > *dataPtr)
void putArrayIntV(uInt rownr, const Array< Int > *dataPtr)
Bool shapeIsFixed_p
Switch indicating if the shape is fixed.
Definition: StIndArrAIO.h:250
void getSliceStringV(uInt rownr, const Slicer &, Array< String > *dataPtr)
void putData(void *datap, uInt nrval, AipsIO &)
Put the data of a data block.
void getSlicefloatV(uInt rownr, const Slicer &, Array< float > *dataPtr)
void putArrayStringV(uInt rownr, const Array< String > *dataPtr)
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
void putSliceInt64V(uInt rownr, const Slicer &, const Array< Int64 > *dataPtr)
void getArrayComplexV(uInt rownr, Array< Complex > *dataPtr)
uInt ndim(uInt rownr)
Get the dimensionality of the item in the given row.
void setShapeColumn(const IPosition &shape)
Set the (fixed) shape of the arrays in the entire column.
void putSlicefloatV(uInt rownr, const Slicer &, const Array< float > *dataPtr)
void setShape(uInt rownr, const IPosition &shape)
Set the shape of the array in the given row and allocate the array in the file.
void putFile(uInt nrval, AipsIO &)
Write the data into AipsIO.
void getSliceBoolV(uInt rownr, const Slicer &, Array< Bool > *dataPtr)
Get a section of the array in the given row.
void getSliceuShortV(uInt rownr, const Slicer &, Array< uShort > *dataPtr)
Specify which elements to extract from an n-dimensional array.
Definition: Slicer.h:289
void putSlicedoubleV(uInt rownr, const Slicer &, const Array< double > *dataPtr)
AipsIO table storage manager class.
Definition: StManAipsIO.h:367
void getSliceIntV(uInt rownr, const Slicer &, Array< Int > *dataPtr)
void putArrayuShortV(uInt rownr, const Array< uShort > *dataPtr)
void doCreate(uInt nrrow)
Let the column create its array file.
OpenOption
Define the possible ByteIO open options.
Definition: ByteIO.h:65
Bool canChangeShape() const
This storage manager can handle changing array shapes for non-FixedShape columns. ...
void getSliceInt64V(uInt rownr, const Slicer &, Array< Int64 > *dataPtr)
void putSliceComplexV(uInt rownr, const Slicer &, const Array< Complex > *dataPtr)
AipsIO storage manager for indirect table arrays.
Definition: StIndArrAIO.h:97
StIndArray * getShape(uInt rownr)
Read the shape at the given row.
void putArrayuIntV(uInt rownr, const Array< uInt > *dataPtr)
void putArrayuCharV(uInt rownr, const Array< uChar > *dataPtr)
void deleteArray(uInt rownr)
Delete the array in the given row.
void getArrayShortV(uInt rownr, Array< Short > *dataPtr)
void getArrayuShortV(uInt rownr, Array< uShort > *dataPtr)
uInt seqnr_p
The (unique) sequence number of the column.
Definition: StIndArrAIO.h:246
void putSliceShortV(uInt rownr, const Slicer &, const Array< Short > *dataPtr)
Read/write array in external format for a storage manager.
Definition: StArrayFile.h:129
Bool ok() const
Check if the class invariants still hold.
void openFile(ByteIO::OpenOption opt)
Open the file with the given mode.
unsigned int uInt
Definition: aipstype.h:51
void getSlicedoubleV(uInt rownr, const Slicer &, Array< double > *dataPtr)
void getArrayuIntV(uInt rownr, Array< uInt > *dataPtr)
void getSliceComplexV(uInt rownr, const Slicer &, Array< Complex > *dataPtr)
StManColumnIndArrayAipsIO & operator=(const StManColumnIndArrayAipsIO &)
Forbid assignment.
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42