casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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>
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 getArrayInt64V (uInt rownr, Array<Int64>* dataPtr);
125  void getArrayfloatV (uInt rownr, Array<float>* dataPtr);
126  void getArraydoubleV (uInt rownr, Array<double>* dataPtr);
127  void getArrayComplexV (uInt rownr, Array<Complex>* dataPtr);
128  void getArrayDComplexV (uInt rownr, Array<DComplex>* dataPtr);
129  void getArrayStringV (uInt rownr, Array<String>* dataPtr);
130  // </group>
131 
132  // Put an array value into the given row.
133  // The buffer pointed to by dataPtr has to have the correct length
134  // (which is guaranteed by the ArrayColumn put function).
135  // <group>
136  void putArrayBoolV (uInt rownr, const Array<Bool>* dataPtr);
137  void putArrayuCharV (uInt rownr, const Array<uChar>* dataPtr);
138  void putArrayShortV (uInt rownr, const Array<Short>* dataPtr);
139  void putArrayuShortV (uInt rownr, const Array<uShort>* dataPtr);
140  void putArrayIntV (uInt rownr, const Array<Int>* dataPtr);
141  void putArrayuIntV (uInt rownr, const Array<uInt>* dataPtr);
142  void putArrayInt64V (uInt rownr, const Array<Int64>* dataPtr);
143  void putArrayfloatV (uInt rownr, const Array<float>* dataPtr);
144  void putArraydoubleV (uInt rownr, const Array<double>* dataPtr);
145  void putArrayComplexV (uInt rownr, const Array<Complex>* dataPtr);
146  void putArrayDComplexV (uInt rownr, const Array<DComplex>* dataPtr);
147  void putArrayStringV (uInt rownr, const Array<String>* dataPtr);
148  // </group>
149 
150  // Get a section of the array in the given row.
151  // The buffer pointed to by dataPtr has to have the correct length
152  // (which is guaranteed by the ArrayColumn getSlice function).
153  // <group>
154  void getSliceBoolV (uInt rownr, const Slicer&, Array<Bool>* dataPtr);
155  void getSliceuCharV (uInt rownr, const Slicer&, Array<uChar>* dataPtr);
156  void getSliceShortV (uInt rownr, const Slicer&, Array<Short>* dataPtr);
157  void getSliceuShortV (uInt rownr, const Slicer&, Array<uShort>* dataPtr);
158  void getSliceIntV (uInt rownr, const Slicer&, Array<Int>* dataPtr);
159  void getSliceuIntV (uInt rownr, const Slicer&, Array<uInt>* dataPtr);
160  void getSliceInt64V (uInt rownr, const Slicer&, Array<Int64>* dataPtr);
161  void getSlicefloatV (uInt rownr, const Slicer&, Array<float>* dataPtr);
162  void getSlicedoubleV (uInt rownr, const Slicer&, Array<double>* dataPtr);
163  void getSliceComplexV (uInt rownr, const Slicer&, Array<Complex>* dataPtr);
164  void getSliceDComplexV (uInt rownr, const Slicer&, Array<DComplex>* dataPtr);
165  void getSliceStringV (uInt rownr, const Slicer&, Array<String>* dataPtr);
166  // </group>
167 
168  // Put into a section of the array in the given row.
169  // The buffer pointed to by dataPtr has to have the correct length
170  // (which is guaranteed by the ArrayColumn putSlice function).
171  // <group>
172  void putSliceBoolV (uInt rownr, const Slicer&,
173  const Array<Bool>* dataPtr);
174  void putSliceuCharV (uInt rownr, const Slicer&,
175  const Array<uChar>* dataPtr);
176  void putSliceShortV (uInt rownr, const Slicer&,
177  const Array<Short>* dataPtr);
178  void putSliceuShortV (uInt rownr, const Slicer&,
179  const Array<uShort>* dataPtr);
180  void putSliceIntV (uInt rownr, const Slicer&,
181  const Array<Int>* dataPtr);
182  void putSliceuIntV (uInt rownr, const Slicer&,
183  const Array<uInt>* dataPtr);
184  void putSliceInt64V (uInt rownr, const Slicer&,
185  const Array<Int64>* 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  // Remove the value in the given row.
199  // This will result in lost file space.
200  void remove (uInt rownr);
201 
202 
203 private:
204  class Data {
205  public:
206  Data (const IPosition& shape, int dtype);
207  // explicitly specify noexcept to squash compiler warning
208  ~Data() noexcept(false);
209  void clear (int dtype);
210  const IPosition& shape() const {return shape_p;}
211  void* data() {return data_p;}
212  private:
213  Data (const Data&);
214  Data& operator= (const Data&);
216  void* data_p;
217  };
218  // The shape of all arrays in case it is fixed.
220  // The size of an array element.
222  // The size at the start of the data (for the IPosition).
224 
225 
226  // Delete the array in the given row.
227  void deleteArray (uInt rownr);
228 
229  // Read the shape at the given row.
230  // It throws an exception if undefined.
231  Data* getShape (uInt rownr);
232 
233  // Get a pointer to the data array.
234  void* getDataPtr (uInt rownr)
235  { return (char*)(getShape(rownr)) + startSize_p; }
236 
237  // Forbid copy constructor.
238  MSMIndColumn (const MSMIndColumn&);
239 
240  // Forbid assignment.
242 };
243 
244 
245 
246 } //# NAMESPACE CASACORE - END
247 
248 #endif
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:119
void putArrayInt64V(uInt rownr, const Array< Int64 > *dataPtr)
const IPosition & shape() const
Definition: MSMIndColumn.h:210
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:221
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)
MSMIndColumn & operator=(const MSMIndColumn &)
Forbid assignment.
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:67
void * getDataPtr(uInt rownr)
Get a pointer to the data array.
Definition: MSMIndColumn.h:234
void getSliceuShortV(uInt rownr, const Slicer &, Array< uShort > *dataPtr)
~Data() noexcept(false)
explicitly specify noexcept to squash compiler warning
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 getSliceInt64V(uInt rownr, const Slicer &, Array< Int64 > *dataPtr)
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:42
void getArrayInt64V(uInt rownr, Array< Int64 > *dataPtr)
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:289
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:219
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 putSliceInt64V(uInt rownr, const Slicer &, const Array< Int64 > *dataPtr)
void getArrayShortV(uInt rownr, Array< Short > *dataPtr)
void putArraydoubleV(uInt rownr, const Array< double > *dataPtr)
uInt startSize_p
The size at the start of the data (for the IPosition).
Definition: MSMIndColumn.h:223
unsigned int uInt
Definition: aipstype.h:51
void putArrayIntV(uInt rownr, const Array< Int > *dataPtr)
Mmeory storage manager for variable shaped table arrays.
Definition: MSMIndColumn.h:76
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42