casacore
StArrAipsIO.h
Go to the documentation of this file.
1 //# StArrAipsIO.h: AipsIO storage manager for direct table arrays
2 //# Copyright (C) 1994,1995,1996,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_STARRAIPSIO_H
29 #define TABLES_STARRAIPSIO_H
30 
31 //# Includes
32 #include <casacore/casa/aips.h>
33 #include <casacore/tables/DataMan/StManAipsIO.h>
34 #include <casacore/casa/Arrays/IPosition.h>
35 
36 namespace casacore { //# NAMESPACE CASACORE - BEGIN
37 
38 //# Forward Declarations
39 class AipsIO;
40 
41 
42 // <summary>
43 // AipsIO storage manager for direct 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 // </prerequisite>
56 
57 // <etymology>
58 // StManColumnArrayAipsIO handles the access to a direct array in a table
59 // column using the AipsIO storage manager.
60 // </etymology>
61 
62 // <synopsis>
63 // StManColumnArrayAipsIO holds the direct arrays in memory and writes
64 // them into the AipsIO file when the table gets closed.
65 // It fully supports addition and removal of rows.
66 // When a row is added to the table, the direct array gets allocated.
67 // This is possible, because the shape of direct arrays is known.
68 //
69 // The class is derived from StManColumnAipsIO which is used to hold
70 // a pointer to the array.
71 // </synopsis>
72 
73 // <motivation>
74 // StManColumnArrayAipsIO handles the standard data types. The class
75 // is not templated, but a switch statement is used instead.
76 // Templates would cause too many instantiations.
77 // </motivation>
78 
79 // <todo asof="$DATE:$">
80 //# A List of bugs, limitations, extensions or planned refinements.
81 // <li> Maybe TpArrayInt, etc. should be used instead of TpInt.
82 // <li> get/putSlice use too many array operations.
83 // To solve this requires an array constructor taking a
84 // pointer to the data (which is foreseen in the new Array classes).
85 // </todo>
86 
87 
89 {
90 public:
91 
92  // Create a column of the given data type.
94 
95  // Frees up the storage.
97 
98  // It can handle access to a slice in a cell.
99  Bool canAccessSlice (Bool& reask) const;
100 
101  // It can handle access to an entire column.
102  Bool canAccessArrayColumn (Bool& reask) const;
103 
104  // Set the shape of the arrays in the entire column.
105  void setShapeColumn (const IPosition& shape);
106 
107  // Add (newNrrow-oldNrrow) rows to the column.
108  // Allocate the data arrays in these rows.
109  void addRow (uInt newNrrow, uInt oldNrrow);
110 
111  // Get the dimensionality of the item in the given row.
112  // This is the same for all rows.
113  uInt ndim (uInt rownr);
114 
115  // Get the shape of the array in the given row.
116  // This is the same for all rows.
117  IPosition shape (uInt rownr);
118 
119  // Get an array value in the given row.
120  // The buffer pointed to by dataPtr has to have the correct length
121  // (which is guaranteed by the ArrayColumn get function).
122  // <group>
123  void getArrayBoolV (uInt rownr, Array<Bool>* dataPtr);
124  void getArrayuCharV (uInt rownr, Array<uChar>* dataPtr);
125  void getArrayShortV (uInt rownr, Array<Short>* dataPtr);
126  void getArrayuShortV (uInt rownr, Array<uShort>* dataPtr);
127  void getArrayIntV (uInt rownr, Array<Int>* dataPtr);
128  void getArrayuIntV (uInt rownr, Array<uInt>* dataPtr);
129  void getArrayfloatV (uInt rownr, Array<float>* dataPtr);
130  void getArraydoubleV (uInt rownr, Array<double>* dataPtr);
131  void getArrayComplexV (uInt rownr, Array<Complex>* dataPtr);
132  void getArrayDComplexV (uInt rownr, Array<DComplex>* dataPtr);
133  void getArrayStringV (uInt rownr, Array<String>* dataPtr);
134  // </group>
135 
136  // Put an array value into the given row.
137  // The buffer pointed to by dataPtr has to have the correct length
138  // (which is guaranteed by the ArrayColumn put function).
139  // <group>
140  void putArrayBoolV (uInt rownr, const Array<Bool>* dataPtr);
141  void putArrayuCharV (uInt rownr, const Array<uChar>* dataPtr);
142  void putArrayShortV (uInt rownr, const Array<Short>* dataPtr);
143  void putArrayuShortV (uInt rownr, const Array<uShort>* dataPtr);
144  void putArrayIntV (uInt rownr, const Array<Int>* dataPtr);
145  void putArrayuIntV (uInt rownr, const Array<uInt>* dataPtr);
146  void putArrayfloatV (uInt rownr, const Array<float>* dataPtr);
147  void putArraydoubleV (uInt rownr, const Array<double>* dataPtr);
148  void putArrayComplexV (uInt rownr, const Array<Complex>* dataPtr);
149  void putArrayDComplexV (uInt rownr, const Array<DComplex>* dataPtr);
150  void putArrayStringV (uInt rownr, const Array<String>* dataPtr);
151  // </group>
152 
153  // Get 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 getSlice function).
156  // <group>
157  void getSliceBoolV (uInt rownr, const Slicer&, Array<Bool>* dataPtr);
158  void getSliceuCharV (uInt rownr, const Slicer&, Array<uChar>* dataPtr);
159  void getSliceShortV (uInt rownr, const Slicer&, Array<Short>* dataPtr);
160  void getSliceuShortV (uInt rownr, const Slicer&, Array<uShort>* dataPtr);
161  void getSliceIntV (uInt rownr, const Slicer&, Array<Int>* dataPtr);
162  void getSliceuIntV (uInt rownr, const Slicer&, Array<uInt>* dataPtr);
163  void getSlicefloatV (uInt rownr, const Slicer&, Array<float>* dataPtr);
164  void getSlicedoubleV (uInt rownr, const Slicer&, Array<double>* dataPtr);
165  void getSliceComplexV (uInt rownr, const Slicer&, Array<Complex>* dataPtr);
166  void getSliceDComplexV (uInt rownr, const Slicer&, Array<DComplex>* dataPtr);
167  void getSliceStringV (uInt rownr, const Slicer&, Array<String>* dataPtr);
168  // </group>
169 
170  // Put into a section of the array in the given row.
171  // The buffer pointed to by dataPtr has to have the correct length
172  // (which is guaranteed by the ArrayColumn putSlice function).
173  // <group>
174  void putSliceBoolV (uInt rownr, const Slicer&,
175  const Array<Bool>* dataPtr);
176  void putSliceuCharV (uInt rownr, const Slicer&,
177  const Array<uChar>* dataPtr);
178  void putSliceShortV (uInt rownr, const Slicer&,
179  const Array<Short>* dataPtr);
180  void putSliceuShortV (uInt rownr, const Slicer&,
181  const Array<uShort>* dataPtr);
182  void putSliceIntV (uInt rownr, const Slicer&,
183  const Array<Int>* dataPtr);
184  void putSliceuIntV (uInt rownr, const Slicer&,
185  const Array<uInt>* dataPtr);
186  void putSlicefloatV (uInt rownr, const Slicer&,
187  const Array<float>* dataPtr);
188  void putSlicedoubleV (uInt rownr, const Slicer&,
189  const Array<double>* dataPtr);
190  void putSliceComplexV (uInt rownr, const Slicer&,
191  const Array<Complex>* dataPtr);
192  void putSliceDComplexV (uInt rownr, const Slicer&,
193  const Array<DComplex>* dataPtr);
194  void putSliceStringV (uInt rownr, const Slicer&,
195  const Array<String>* dataPtr);
196  // </group>
197 
198  // Get all array values in the column.
199  // The buffer pointed to by dataPtr has to have the correct length
200  // (which is guaranteed by the ArrayColumn getColumn function).
201  // <group>
202  void getArrayColumnBoolV (Array<Bool>* dataPtr);
203  void getArrayColumnuCharV (Array<uChar>* dataPtr);
204  void getArrayColumnShortV (Array<Short>* dataPtr);
205  void getArrayColumnuShortV (Array<uShort>* dataPtr);
206  void getArrayColumnIntV (Array<Int>* dataPtr);
207  void getArrayColumnuIntV (Array<uInt>* dataPtr);
208  void getArrayColumnfloatV (Array<float>* dataPtr);
209  void getArrayColumndoubleV (Array<double>* dataPtr);
210  void getArrayColumnComplexV (Array<Complex>* dataPtr);
212  void getArrayColumnStringV (Array<String>* dataPtr);
213  // </group>
214 
215  // Put all arrays in the column.
216  // The buffer pointed to by dataPtr has to have the correct length
217  // (which is guaranteed by the ArrayColumn putColumn function).
218  // <group>
219  void putArrayColumnBoolV (const Array<Bool>* dataPtr);
220  void putArrayColumnuCharV (const Array<uChar>* dataPtr);
221  void putArrayColumnShortV (const Array<Short>* dataPtr);
222  void putArrayColumnuShortV (const Array<uShort>* dataPtr);
223  void putArrayColumnIntV (const Array<Int>* dataPtr);
224  void putArrayColumnuIntV (const Array<uInt>* dataPtr);
225  void putArrayColumnfloatV (const Array<float>* dataPtr);
226  void putArrayColumndoubleV (const Array<double>* dataPtr);
227  void putArrayColumnComplexV (const Array<Complex>* dataPtr);
228  void putArrayColumnDComplexV (const Array<DComplex>* dataPtr);
229  void putArrayColumnStringV (const Array<String>* dataPtr);
230  // </group>
231 
232  // Remove the value at the given index.
233  void remove (uInt index);
234 
235  // Write the data into AipsIO.
236  // This will call StManColumnAipsIO::putFile which will in its turn
237  // call putData in this class for each of its chunks of data.
238  void putFile (uInt nrval, AipsIO&);
239 
240  // Read the data from AipsIO.
241  // This will call StManColumnAipsIO::getFile which will in its turn
242  // call getData in this class for each of its chunks of data.
243  void getFile (uInt nrval, AipsIO&);
244 
245  // Check if the class invariants still hold.
246  Bool ok() const;
247 
248 private:
249  // The data type of the array (as defined in DataType.h).
251  // The shape of the array.
253  // The nr of elements in the array.
255 
256  // Delete the array at the given index.
257  void deleteArray (uInt index);
258 
259  // Put the data of a data block.
260  // datap is an array of nrval pointers to arrays.
261  void putData (void* datap, uInt nrval, AipsIO&);
262 
263  // Get data arrays into a data block at the given index.
264  // datap is an array of pointers to arrays. nrval arrays will
265  // be allocated and read starting at datap[index].
266  void getData (void* datap, uInt index, uInt nrval, AipsIO&, uInt version);
267 
268  // Forbid copy constructor.
270 
271  // Forbid assignment.
273 };
274 
275 
276 
277 
278 } //# NAMESPACE CASACORE - END
279 
280 #endif
void putSliceShortV(uInt rownr, const Slicer &, const Array< Short > *dataPtr)
A Vector of integers, for indexing into Array<T> objects.
Definition: IPosition.h:119
void getArrayStringV(uInt rownr, Array< String > *dataPtr)
void putArrayColumnDComplexV(const Array< DComplex > *dataPtr)
void getArrayColumnBoolV(Array< Bool > *dataPtr)
Get all array values in the column.
void putArrayuIntV(uInt rownr, const Array< uInt > *dataPtr)
void getSliceIntV(uInt rownr, const Slicer &, Array< Int > *dataPtr)
void putArrayColumnuIntV(const Array< uInt > *dataPtr)
StManColumnArrayAipsIO(StManAipsIO *, int dataType)
Create a column of the given data type.
void putSliceuIntV(uInt rownr, const Slicer &, const Array< uInt > *dataPtr)
uInt ndim(uInt rownr)
Get the dimensionality of the item in the given row.
void getArrayuIntV(uInt rownr, Array< uInt > *dataPtr)
uInt nrelem_p
The nr of elements in the array.
Definition: StArrAipsIO.h:254
void getFile(uInt nrval, AipsIO &)
Read the data from AipsIO.
Bool canAccessArrayColumn(Bool &reask) const
It can handle access to an entire column.
AipsIO is the object persistency mechanism of Casacore.
Definition: AipsIO.h:168
void putFile(uInt nrval, AipsIO &)
Write the data into AipsIO.
void getArrayColumndoubleV(Array< double > *dataPtr)
IPosition shape_p
The shape of the array.
Definition: StArrAipsIO.h:252
void putArrayColumndoubleV(const Array< double > *dataPtr)
void getSliceBoolV(uInt rownr, const Slicer &, Array< Bool > *dataPtr)
Get a section of the array in the given row.
void getArrayShortV(uInt rownr, Array< Short > *dataPtr)
void setShapeColumn(const IPosition &shape)
Set the shape of the arrays in the entire column.
void putArrayColumnStringV(const Array< String > *dataPtr)
Bool canAccessSlice(Bool &reask) const
It can handle access to a slice in a cell.
void getArrayfloatV(uInt rownr, Array< float > *dataPtr)
void putArrayColumnIntV(const Array< Int > *dataPtr)
void putArrayuCharV(uInt rownr, const Array< uChar > *dataPtr)
AipsIO storage manager for direct table arrays.
Definition: StArrAipsIO.h:88
void getArrayIntV(uInt rownr, Array< Int > *dataPtr)
void putArrayStringV(uInt rownr, const Array< String > *dataPtr)
int dataType() const
Return the data type of the column.
void getArrayColumnStringV(Array< String > *dataPtr)
void getArrayComplexV(uInt rownr, Array< Complex > *dataPtr)
void putArrayColumnfloatV(const Array< float > *dataPtr)
void getSlicefloatV(uInt rownr, const Slicer &, Array< float > *dataPtr)
int dtypeArr_p
The data type of the array (as defined in DataType.h).
Definition: StArrAipsIO.h:250
AipsIO table column storage manager class.
Definition: StManAipsIO.h:106
void getArrayColumnComplexV(Array< Complex > *dataPtr)
void putSlicefloatV(uInt rownr, const Slicer &, const Array< float > *dataPtr)
void deleteArray(uInt index)
Delete the array at the given index.
void getSliceComplexV(uInt rownr, const Slicer &, Array< Complex > *dataPtr)
void putArrayColumnuCharV(const Array< uChar > *dataPtr)
void putArrayColumnuShortV(const Array< uShort > *dataPtr)
void getSliceDComplexV(uInt rownr, const Slicer &, Array< DComplex > *dataPtr)
void putArrayComplexV(uInt rownr, const Array< Complex > *dataPtr)
void getArrayColumnfloatV(Array< float > *dataPtr)
void getArraydoubleV(uInt rownr, Array< double > *dataPtr)
void addRow(uInt newNrrow, uInt oldNrrow)
Add (newNrrow-oldNrrow) rows to the column.
void getArrayColumnDComplexV(Array< DComplex > *dataPtr)
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:39
void putSliceComplexV(uInt rownr, const Slicer &, const Array< Complex > *dataPtr)
void getArrayDComplexV(uInt rownr, Array< DComplex > *dataPtr)
void putArrayfloatV(uInt rownr, const Array< float > *dataPtr)
Bool ok() const
Check if the class invariants still hold.
void getSlicedoubleV(uInt rownr, const Slicer &, Array< double > *dataPtr)
void getSliceShortV(uInt rownr, const Slicer &, Array< Short > *dataPtr)
void putArrayColumnBoolV(const Array< Bool > *dataPtr)
Put all arrays in the column.
void getArrayColumnShortV(Array< Short > *dataPtr)
~StManColumnArrayAipsIO()
Frees up the storage.
void putArrayColumnShortV(const Array< Short > *dataPtr)
void getArrayColumnuCharV(Array< uChar > *dataPtr)
void getSliceuShortV(uInt rownr, const Slicer &, Array< uShort > *dataPtr)
IPosition shape(uInt rownr)
Get the shape of the array in the given row.
Specify which elements to extract from an n-dimensional array.
Definition: Slicer.h:275
void putSliceDComplexV(uInt rownr, const Slicer &, const Array< DComplex > *dataPtr)
AipsIO table storage manager class.
Definition: StManAipsIO.h:361
void putSliceuShortV(uInt rownr, const Slicer &, const Array< uShort > *dataPtr)
void getData(void *datap, uInt index, uInt nrval, AipsIO &, uInt version)
Get data arrays into a data block at the given index.
void putSliceuCharV(uInt rownr, const Slicer &, const Array< uChar > *dataPtr)
void putArrayIntV(uInt rownr, const Array< Int > *dataPtr)
void getArrayuCharV(uInt rownr, Array< uChar > *dataPtr)
void getArrayColumnIntV(Array< Int > *dataPtr)
void getArrayColumnuShortV(Array< uShort > *dataPtr)
void getSliceuCharV(uInt rownr, const Slicer &, Array< uChar > *dataPtr)
void getArrayBoolV(uInt rownr, Array< Bool > *dataPtr)
Get an array value in the given row.
void putSliceBoolV(uInt rownr, const Slicer &, const Array< Bool > *dataPtr)
Put into a section of the array in the given row.
void getSliceStringV(uInt rownr, const Slicer &, Array< String > *dataPtr)
void getSliceuIntV(uInt rownr, const Slicer &, Array< uInt > *dataPtr)
void getArrayColumnuIntV(Array< uInt > *dataPtr)
void putArraydoubleV(uInt rownr, const Array< double > *dataPtr)
void putArrayuShortV(uInt rownr, const Array< uShort > *dataPtr)
void putSlicedoubleV(uInt rownr, const Slicer &, 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 putSliceIntV(uInt rownr, const Slicer &, const Array< Int > *dataPtr)
void getArrayuShortV(uInt rownr, Array< uShort > *dataPtr)
void putArrayDComplexV(uInt rownr, const Array< DComplex > *dataPtr)
this file contains all the compiler specific defines
Definition: mainpage.dox:28
unsigned int uInt
Definition: aipstype.h:48
void putArrayColumnComplexV(const Array< Complex > *dataPtr)
StManColumnArrayAipsIO & operator=(const StManColumnArrayAipsIO &)
Forbid assignment.
void putSliceStringV(uInt rownr, const Slicer &, const Array< String > *dataPtr)
void putData(void *datap, uInt nrval, AipsIO &)
Put the data of a data block.