casacore
MSMIndColumn.h
Go to the documentation of this file.
1 //# MSMIndColumn.h: Memory storage manager for variable shaped table arrays
2 //# Copyright (C) 2003
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_MSMINDCOLUMN_H
29 #define TABLES_MSMINDCOLUMN_H
30 
31 
32 //# Includes
33 #include <casacore/casa/aips.h>
34 #include <casacore/tables/DataMan/MSMColumn.h>
35 #include <casacore/tables/DataMan/MSMBase.h>
36 #include <casacore/casa/Arrays/IPosition.h>
37 
38 
39 namespace casacore { //# NAMESPACE CASACORE - BEGIN
40 
41 // <summary>
42 // Mmeory storage manager for variable shaped table arrays
43 // </summary>
44 
45 // <use visibility=local>
46 
47 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
48 // </reviewed>
49 
50 // <prerequisite>
51 //# Classes you should understand before using this one.
52 // <li> MSMBase
53 // <li> MSMColumn
54 // </prerequisite>
55 
56 // <synopsis>
57 // StManColumnArrayAipsIO handles indirect arrays in a table column.
58 //
59 // An array (or section of an array) is only read when needed.
60 // It, however, caches the array shape using the helper class
61 // StIndArray. Pointers to these objects
62 // are maintained using the standard StManColumnAipsIO facilities.
63 // When the column gets written, the offsets in the StManArrayFile file
64 // get written. Those will be read back when the column is read in.
65 //
66 // When a row gets deleted or when the array gets bigger, the file space
67 // is lost. This storage manager is a simple one and no attempts
68 // are done to make it smart.
69 // </synopsis>
70 
71 //# <todo asof="$DATE:$">
72 //# A List of bugs, limitations, extensions or planned refinements.
73 //# </todo>
74 
75 
76 class MSMIndColumn : public MSMColumn
77 {
78 public:
79 
80  // Create a column of the given type.
82 
83  // Frees up the storage.
84  ~MSMIndColumn();
85 
86  // It can handle access to a slice in a cell.
87  Bool canAccessSlice (Bool& reask) const;
88 
89  // Set the (fixed) shape of the arrays in the entire column.
90  void setShapeColumn (const IPosition& shape);
91 
92  // Get the column shape.
93  const IPosition& columnShape() const
94  { return fixedShape_p; }
95 
96  // Set the shape of the array in the given row and allocate the array
97  // in the file.
98  void setShape (uInt rownr, const IPosition& shape);
99 
100  // Is the shape defined (i.e. is there an array) in this row?
101  Bool isShapeDefined (uInt rownr);
102 
103  // Get the dimensionality of the item in the given row.
104  // 0 is returned if there is no array.
105  uInt ndim (uInt rownr);
106 
107  // Get the shape of the array in the given row.
108  // An zero-length IPosition is returned if there is no array.
109  IPosition shape (uInt rownr);
110 
111  // This storage manager can handle changing array shapes.
112  Bool canChangeShape() const;
113 
114  // Get an array value in the given row.
115  // The buffer pointed to by dataPtr has to have the correct length
116  // (which is guaranteed by the ArrayColumn get function).
117  // <group>
118  void getArrayBoolV (uInt rownr, Array<Bool>* dataPtr);
119  void getArrayuCharV (uInt rownr, Array<uChar>* dataPtr);
120  void getArrayShortV (uInt rownr, Array<Short>* dataPtr);
121  void getArrayuShortV (uInt rownr, Array<uShort>* dataPtr);
122  void getArrayIntV (uInt rownr, Array<Int>* dataPtr);
123  void getArrayuIntV (uInt rownr, Array<uInt>* dataPtr);
124  void getArrayfloatV (uInt rownr, Array<float>* dataPtr);
125  void getArraydoubleV (uInt rownr, Array<double>* dataPtr);
126  void getArrayComplexV (uInt rownr, Array<Complex>* dataPtr);
127  void getArrayDComplexV (uInt rownr, Array<DComplex>* dataPtr);
128  void getArrayStringV (uInt rownr, Array<String>* dataPtr);
129  // </group>
130 
131  // Put an array value into the given row.
132  // The buffer pointed to by dataPtr has to have the correct length
133  // (which is guaranteed by the ArrayColumn put function).
134  // <group>
135  void putArrayBoolV (uInt rownr, const Array<Bool>* dataPtr);
136  void putArrayuCharV (uInt rownr, const Array<uChar>* dataPtr);
137  void putArrayShortV (uInt rownr, const Array<Short>* dataPtr);
138  void putArrayuShortV (uInt rownr, const Array<uShort>* dataPtr);
139  void putArrayIntV (uInt rownr, const Array<Int>* dataPtr);
140  void putArrayuIntV (uInt rownr, const Array<uInt>* dataPtr);
141  void putArrayfloatV (uInt rownr, const Array<float>* dataPtr);
142  void putArraydoubleV (uInt rownr, const Array<double>* dataPtr);
143  void putArrayComplexV (uInt rownr, const Array<Complex>* dataPtr);
144  void putArrayDComplexV (uInt rownr, const Array<DComplex>* dataPtr);
145  void putArrayStringV (uInt rownr, const Array<String>* dataPtr);
146  // </group>
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  // <group>
152  void getSliceBoolV (uInt rownr, const Slicer&, Array<Bool>* dataPtr);
153  void getSliceuCharV (uInt rownr, const Slicer&, Array<uChar>* dataPtr);
154  void getSliceShortV (uInt rownr, const Slicer&, Array<Short>* dataPtr);
155  void getSliceuShortV (uInt rownr, const Slicer&, Array<uShort>* dataPtr);
156  void getSliceIntV (uInt rownr, const Slicer&, Array<Int>* dataPtr);
157  void getSliceuIntV (uInt rownr, const Slicer&, Array<uInt>* dataPtr);
158  void getSlicefloatV (uInt rownr, const Slicer&, Array<float>* dataPtr);
159  void getSlicedoubleV (uInt rownr, const Slicer&, Array<double>* dataPtr);
160  void getSliceComplexV (uInt rownr, const Slicer&, Array<Complex>* dataPtr);
161  void getSliceDComplexV (uInt rownr, const Slicer&, Array<DComplex>* dataPtr);
162  void getSliceStringV (uInt rownr, const Slicer&, Array<String>* dataPtr);
163  // </group>
164 
165  // Put into a section of the array in the given row.
166  // The buffer pointed to by dataPtr has to have the correct length
167  // (which is guaranteed by the ArrayColumn putSlice function).
168  // <group>
169  void putSliceBoolV (uInt rownr, const Slicer&,
170  const Array<Bool>* dataPtr);
171  void putSliceuCharV (uInt rownr, const Slicer&,
172  const Array<uChar>* dataPtr);
173  void putSliceShortV (uInt rownr, const Slicer&,
174  const Array<Short>* dataPtr);
175  void putSliceuShortV (uInt rownr, const Slicer&,
176  const Array<uShort>* dataPtr);
177  void putSliceIntV (uInt rownr, const Slicer&,
178  const Array<Int>* dataPtr);
179  void putSliceuIntV (uInt rownr, const Slicer&,
180  const Array<uInt>* dataPtr);
181  void putSlicefloatV (uInt rownr, const Slicer&,
182  const Array<float>* dataPtr);
183  void putSlicedoubleV (uInt rownr, const Slicer&,
184  const Array<double>* dataPtr);
185  void putSliceComplexV (uInt rownr, const Slicer&,
186  const Array<Complex>* dataPtr);
187  void putSliceDComplexV (uInt rownr, const Slicer&,
188  const Array<DComplex>* dataPtr);
189  void putSliceStringV (uInt rownr, const Slicer&,
190  const Array<String>* dataPtr);
191  // </group>
192 
193  // Remove the value in the given row.
194  // This will result in lost file space.
195  void remove (uInt rownr);
196 
197 
198 private:
199  class Data {
200  public:
201  Data (const IPosition& shape, int dtype);
202  ~Data();
203  void clear (int dtype);
204  const IPosition& shape() const {return shape_p;}
205  void* data() {return data_p;}
206  private:
207  Data (const Data&);
208  Data& operator= (const Data&);
210  void* data_p;
211  };
212  // The shape of all arrays in case it is fixed.
214  // The size of an array element.
216  // The size at the start of the data (for the IPosition).
218 
219 
220  // Delete the array in the given row.
221  void deleteArray (uInt rownr);
222 
223  // Read the shape at the given row.
224  // It throws an exception if undefined.
225  Data* getShape (uInt rownr);
226 
227  // Get a pointer to the data array.
228  void* getDataPtr (uInt rownr)
229  { return (char*)(getShape(rownr)) + startSize_p; }
230 
231  // Forbid copy constructor.
232  MSMIndColumn (const MSMIndColumn&);
233 
234  // Forbid assignment.
236 };
237 
238 
239 
240 } //# NAMESPACE CASACORE - END
241 
242 #endif
A Vector of integers, for indexing into Array<T> objects.
Definition: IPosition.h:119
const IPosition & shape() const
Definition: MSMIndColumn.h:204
void putArrayStringV(uInt rownr, const Array< String > *dataPtr)
void getArrayStringV(uInt rownr, Array< String > *dataPtr)
void getArrayuCharV(uInt rownr, Array< uChar > *dataPtr)
void putSliceIntV(uInt rownr, const Slicer &, const Array< Int > *dataPtr)
uInt elemSize_p
The size of an array element.
Definition: MSMIndColumn.h:215
void setShapeColumn(const IPosition &shape)
Set the (fixed) shape of the arrays in the entire column.
void putSliceuShortV(uInt rownr, const Slicer &, const Array< uShort > *dataPtr)
void putSlicefloatV(uInt rownr, const Slicer &, const Array< float > *dataPtr)
Bool canAccessSlice(Bool &reask) const
It can handle access to a slice in a cell.
void putSliceuIntV(uInt rownr, const Slicer &, const Array< uInt > *dataPtr)
void putSliceDComplexV(uInt rownr, const Slicer &, const Array< DComplex > *dataPtr)
void putSliceComplexV(uInt rownr, const Slicer &, const Array< Complex > *dataPtr)
void putArrayDComplexV(uInt rownr, const Array< DComplex > *dataPtr)
void getSlicefloatV(uInt rownr, const Slicer &, Array< float > *dataPtr)
void getArrayDComplexV(uInt rownr, Array< DComplex > *dataPtr)
void putArrayuIntV(uInt rownr, const Array< uInt > *dataPtr)
Base class for memory-based table storage manager class.
Definition: MSMBase.h:66
void * getDataPtr(uInt rownr)
Get a pointer to the data array.
Definition: MSMIndColumn.h:228
void getSliceuShortV(uInt rownr, const Slicer &, Array< uShort > *dataPtr)
void putArrayShortV(uInt rownr, const Array< Short > *dataPtr)
MSMIndColumn(MSMBase *, int dataType)
Create a column of the given type.
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 putArrayuCharV(uInt rownr, const Array< uChar > *dataPtr)
~MSMIndColumn()
Frees up the storage.
void putSliceShortV(uInt rownr, const Slicer &, const Array< Short > *dataPtr)
void putSliceStringV(uInt rownr, const Slicer &, const Array< String > *dataPtr)
int dataType() const
Return the data type of the column.
void getSliceuIntV(uInt rownr, const Slicer &, Array< uInt > *dataPtr)
void getArrayComplexV(uInt rownr, Array< Complex > *dataPtr)
void putArrayuShortV(uInt rownr, const Array< uShort > *dataPtr)
Data * getShape(uInt rownr)
Read the shape at the given row.
void getSliceIntV(uInt rownr, const Slicer &, Array< Int > *dataPtr)
Bool isShapeDefined(uInt rownr)
Is the shape defined (i.e.
IPosition shape(uInt rownr)
Get the shape of the array in the given row.
Data(const IPosition &shape, int dtype)
void putSliceBoolV(uInt rownr, const Slicer &, const Array< Bool > *dataPtr)
Put into a section of the array in the given row.
void getSliceComplexV(uInt rownr, const Slicer &, Array< Complex > *dataPtr)
const IPosition & columnShape() const
Get the column shape.
Definition: MSMIndColumn.h:93
uInt ndim(uInt rownr)
Get the dimensionality of the item in the given row.
void getArraydoubleV(uInt rownr, Array< double > *dataPtr)
void getArrayfloatV(uInt rownr, Array< float > *dataPtr)
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:39
void putSlicedoubleV(uInt rownr, const Slicer &, const Array< double > *dataPtr)
void getSliceBoolV(uInt rownr, const Slicer &, Array< Bool > *dataPtr)
Get a section of the array in the given row.
void getArrayBoolV(uInt rownr, Array< Bool > *dataPtr)
Get an array value in the given row.
void getSlicedoubleV(uInt rownr, const Slicer &, Array< double > *dataPtr)
void putArrayComplexV(uInt rownr, const Array< Complex > *dataPtr)
void putArrayBoolV(uInt rownr, const Array< Bool > *dataPtr)
Put an array value into the given row.
Column in the Memory table storage manager class.
Definition: MSMColumn.h:104
Data & operator=(const Data &)
Specify which elements to extract from an n-dimensional array.
Definition: Slicer.h:275
void deleteArray(uInt rownr)
Delete the array in the given row.
IPosition fixedShape_p
The shape of all arrays in case it is fixed.
Definition: MSMIndColumn.h:213
void getSliceShortV(uInt rownr, const Slicer &, Array< Short > *dataPtr)
void getArrayuShortV(uInt rownr, Array< uShort > *dataPtr)
Bool canChangeShape() const
This storage manager can handle changing array shapes.
void getArrayIntV(uInt rownr, Array< Int > *dataPtr)
void putSliceuCharV(uInt rownr, const Slicer &, const Array< uChar > *dataPtr)
void putArrayfloatV(uInt rownr, const Array< float > *dataPtr)
void getSliceuCharV(uInt rownr, const Slicer &, Array< uChar > *dataPtr)
void getSliceDComplexV(uInt rownr, const Slicer &, Array< DComplex > *dataPtr)
void getSliceStringV(uInt rownr, const Slicer &, Array< String > *dataPtr)
void getArrayuIntV(uInt rownr, Array< uInt > *dataPtr)
void getArrayShortV(uInt rownr, Array< Short > *dataPtr)
void putArraydoubleV(uInt rownr, const Array< double > *dataPtr)
this file contains all the compiler specific defines
Definition: mainpage.dox:28
uInt startSize_p
The size at the start of the data (for the IPosition).
Definition: MSMIndColumn.h:217
unsigned int uInt
Definition: aipstype.h:48
void putArrayIntV(uInt rownr, const Array< Int > *dataPtr)
Mmeory storage manager for variable shaped table arrays.
Definition: MSMIndColumn.h:76