casacore
SSMIndColumn.h
Go to the documentation of this file.
1 //# SSMIndColumn.h: A column in Standard storage manager for indirect arrays
2 //# Copyright (C) 2000
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_SSMINDCOLUMN_H
29 #define TABLES_SSMINDCOLUMN_H
30 
31 
32 //# Includes
33 #include <casacore/casa/aips.h>
34 #include <casacore/tables/DataMan/SSMColumn.h>
35 #include <casacore/tables/DataMan/StIndArray.h>
36 #include <casacore/casa/Arrays/IPosition.h>
37 
38 namespace casacore { //# NAMESPACE CASACORE - BEGIN
39 
40 //# Forward Declarations
41 class StManArrayFile;
42 class AipsIO;
43 
44 
45 // <summary>
46 // A column of Standard storage manager for indirect arrays.
47 // </summary>
48 
49 // <use visibility=local>
50 
51 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="tStandardStMan.cc">
52 // </reviewed>
53 
54 // <prerequisite>
55 //# Classes you should understand before using this one.
56 // <li> <linkto class=SSMColumn>SSMColumn</linkto>
57 // <li> <linkto class=StIndArray>StIndArray</linkto>
58 // </prerequisite>
59 
60 // <etymology>
61 // SSMIndColumn represents a Column in the Standard Storage Manager
62 // containing Indirect arrays.
63 // </etymology>
64 
65 // <synopsis>
66 // SSMIndColumn is the implementation of an
67 // <linkto class=SSMColumn>SSMColumn</linkto> class
68 // to handle indirect arrays. The arrays (shape and data) are stored in
69 // a separate file using class <linkto class=StIndArray>StIndArray</linkto>.
70 // The file offset of the beginning of the array in stored in the
71 // appropriate data bucket using the standard SSMColumn functions.
72 // <p>
73 // Note that an indirect array can have a fixed shape. In that case
74 // adding a row results in reserving space for the array in the StIndArray
75 // file, so for each row an array is present.
76 // On the other hand adding a row does nothing for variable shaped arrays.
77 // So when no data is put or shape is set, a row may contain no array at all.
78 // In that case the function <src>isShapeDefined</src> returns False for
79 // that row.
80 // <p>
81 // Indirect arrays containing strings are not handled by this class, but
82 // by <linkto class=SSMIndStringColumn>SSMIndStringColumn</linkto>.
83 // That class stores those string arrays in the special string buckets
84 // instead of using StIndArray. The reason is that the string buckets
85 // are more disk space efficient when string arrays are frequently updated.
86 // </synopsis>
87 
88 //# <todo asof="$DATE:$">
89 //# A List of bugs, limitations, extensions or planned refinements.
90 //# </todo>
91 
92 
93 class SSMIndColumn : public SSMColumn
94 {
95 public:
96  // Create a column of the given data type.
97  // It keeps the pointer to its parent (but does not own it).
98  SSMIndColumn (SSMBase* aParent, int aDataType, uInt aColNr);
99 
100  // Frees up the storage.
101  ~SSMIndColumn();
102 
103  // An array of 'fixed length' strings is not handled specially,
104  // thus this function is ignored.
105  // It is needed to override the bahviour of the base class.
106  virtual void setMaxLength (uInt maxLength);
107 
108  // It can handle access to a slice in a cell.
109  virtual Bool canAccessSlice (Bool& reask) const;
110 
111  // Add (newNrrow-oldNrrow) rows to the column.
112  virtual void addRow (uInt aNewNrRows, uInt anOldNrRows, Bool doInit);
113 
114  // Set the (fixed) shape of the arrays in the entire column.
115  virtual void setShapeColumn (const IPosition& aShape);
116 
117  // Get the dimensionality of the item in the given row.
118  virtual uInt ndim (uInt aRowNr);
119 
120  // Set the shape of the array in the given row and allocate the array
121  // in the file.
122  void setShape (uInt aRowNr, const IPosition& aShape);
123 
124  // Is the shape defined (i.e. is there an array) in this row?
125  virtual Bool isShapeDefined (uInt aRowNr);
126 
127  // Get the shape of the array in the given row.
128  virtual IPosition shape (uInt aRowNr);
129 
130  // This storage manager can handle changing array shapes.
131  Bool canChangeShape() const;
132 
133  // Get an array value in the given row.
134  // The buffer pointed to by dataPtr has to have the correct length
135  // (which is guaranteed by the ArrayColumn get function).
136  // <group>
137  virtual void getArrayBoolV (uInt aRowNr, Array<Bool>* aDataPtr);
138  virtual void getArrayuCharV (uInt aRowNr, Array<uChar>* aDataPtr);
139  virtual void getArrayShortV (uInt aRowNr, Array<Short>* aDataPtr);
140  virtual void getArrayuShortV (uInt aRowNr, Array<uShort>* aDataPtr);
141  virtual void getArrayIntV (uInt aRowNr, Array<Int>* aDataPtr);
142  virtual void getArrayuIntV (uInt aRowNr, Array<uInt>* aDataPtr);
143  virtual void getArrayfloatV (uInt aRowNr, Array<float>* aDataPtr);
144  virtual void getArraydoubleV (uInt aRowNr, Array<double>* aDataPtr);
145  virtual void getArrayComplexV (uInt aRowNr, Array<Complex>* aDataPtr);
146  virtual void getArrayDComplexV (uInt aRowNr, Array<DComplex>* aDataPtr);
147  virtual void getArrayStringV (uInt aRowNr, Array<String>* aDataPtr);
148  // </group>
149 
150  // Put an array value into the given row.
151  // The buffer pointed to by dataPtr has to have the correct length
152  // (which is guaranteed by the ArrayColumn put function).
153  // <group>
154  virtual void putArrayBoolV (uInt aRowNr,
155  const Array<Bool>* aDataPtr);
156  virtual void putArrayuCharV (uInt aRowNr,
157  const Array<uChar>* aDataPtr);
158  virtual void putArrayShortV (uInt aRowNr,
159  const Array<Short>* aDataPtr);
160  virtual void putArrayuShortV (uInt aRowNr,
161  const Array<uShort>* aDataPtr);
162  virtual void putArrayIntV (uInt aRowNr,
163  const Array<Int>* aDataPtr);
164  virtual void putArrayuIntV (uInt aRowNr,
165  const Array<uInt>* aDataPtr);
166  virtual void putArrayfloatV (uInt aRowNr,
167  const Array<float>* aDataPtr);
168  virtual void putArraydoubleV (uInt aRowNr,
169  const Array<double>* aDataPtr);
170  virtual void putArrayComplexV (uInt aRowNr,
171  const Array<Complex>* aDataPtr);
172  virtual void putArrayDComplexV (uInt aRowNr,
173  const Array<DComplex>* aDataPtr);
174  virtual void putArrayStringV (uInt aRowNr,
175  const Array<String>* aDataPtr);
176  // </group>
177 
178  // Get a section of the array in the given row.
179  // The buffer pointed to by dataPtr has to have the correct length
180  // (which is guaranteed by the ArrayColumn getSlice function).
181  // <group>
182  virtual void getSliceBoolV (uInt aRowNr, const Slicer&,
183  Array<Bool>* aDataPtr);
184  virtual void getSliceuCharV (uInt aRowNr, const Slicer&,
185  Array<uChar>* aDataPtr);
186  virtual void getSliceShortV (uInt aRowNr, const Slicer&,
187  Array<Short>* aDataPtr);
188  virtual void getSliceuShortV (uInt aRowNr, const Slicer&,
189  Array<uShort>* aDataPtr);
190  virtual void getSliceIntV (uInt aRowNr, const Slicer&,
191  Array<Int>* aDataPtr);
192  virtual void getSliceuIntV (uInt aRowNr, const Slicer&,
193  Array<uInt>* aDataPtr);
194  virtual void getSlicefloatV (uInt aRowNr, const Slicer&,
195  Array<float>* aDataPtr);
196  virtual void getSlicedoubleV (uInt aRowNr, const Slicer&,
197  Array<double>* aDataPtr);
198  virtual void getSliceComplexV (uInt aRowNr, const Slicer&,
199  Array<Complex>* aDataPtr);
200  virtual void getSliceDComplexV (uInt aRowNr, const Slicer&,
201  Array<DComplex>* aDataPtr);
202  virtual void getSliceStringV (uInt aRowNr, const Slicer&,
203  Array<String>* aDataPtr);
204  // </group>
205 
206  // Put into a section of the array in the given row.
207  // The buffer pointed to by aDataPtr has to have the correct length
208  // (which is guaranteed by the ArrayColumn putSlice function).
209  // <group>
210  virtual void putSliceBoolV (uInt aRowNr, const Slicer&,
211  const Array<Bool>* aDataPtr);
212  virtual void putSliceuCharV (uInt aRowNr, const Slicer&,
213  const Array<uChar>* aDataPtr);
214  virtual void putSliceShortV (uInt aRowNr, const Slicer&,
215  const Array<Short>* aDataPtr);
216  virtual void putSliceuShortV (uInt aRowNr, const Slicer&,
217  const Array<uShort>* aDataPtr);
218  virtual void putSliceIntV (uInt aRowNr, const Slicer&,
219  const Array<Int>* aDataPtr);
220  virtual void putSliceuIntV (uInt aRowNr, const Slicer&,
221  const Array<uInt>* aDataPtr);
222  virtual void putSlicefloatV (uInt aRowNr, const Slicer&,
223  const Array<float>* aDataPtr);
224  virtual void putSlicedoubleV (uInt aRowNr, const Slicer&,
225  const Array<double>* aDataPtr);
226  virtual void putSliceComplexV (uInt aRowNr, const Slicer&,
227  const Array<Complex>* aDataPtr);
228  virtual void putSliceDComplexV (uInt aRowNr, const Slicer&,
229  const Array<DComplex>* aDataPtr);
230  virtual void putSliceStringV (uInt aRowNr, const Slicer&,
231  const Array<String>* aDataPtr);
232  // </group>
233 
234  // Let the column object create its array file.
235  virtual void doCreate (uInt aNrRows);
236 
237  // Open an existing file.
238  virtual void getFile (uInt aNrRows);
239 
240  // Remove the given row from the data bucket and possibly string bucket.
241  virtual void deleteRow(uInt aRowNr);
242 
243 
244 private:
245  // Forbid copy constructor.
246  SSMIndColumn (const SSMIndColumn&);
247 
248  // Forbid assignment.
250 
251  // Initialize part of the object and open/create the file.
252  // It is used by doCreate and getFile.
253  void init();
254 
255  // Read the shape at the given row.
256  // This will cache the information in the StIndArray
257  // object for that row.
258  StIndArray* getShape (uInt aRowNr);
259 
260  // Return a pointer to the array in the given row (for a get).
261  StIndArray* getArrayPtr (uInt aRowNr);
262 
263 
264  //# The shape off all arrays in case it is fixed
266  //# Switch indicating if the shape is fixed.
268  //# The file containing the arrays.
270  //# The indirect array object.
272 };
273 
274 
275 
276 } //# NAMESPACE CASACORE - END
277 
278 #endif
A Vector of integers, for indexing into Array<T> objects.
Definition: IPosition.h:119
virtual void putSlicedoubleV(uInt aRowNr, const Slicer &, const Array< double > *aDataPtr)
virtual void getArrayBoolV(uInt aRowNr, Array< Bool > *aDataPtr)
Get an array value in the given row.
virtual void getSliceuCharV(uInt aRowNr, const Slicer &, Array< uChar > *aDataPtr)
virtual void putSliceIntV(uInt aRowNr, const Slicer &, const Array< Int > *aDataPtr)
virtual void putArrayuShortV(uInt aRowNr, const Array< uShort > *aDataPtr)
virtual void doCreate(uInt aNrRows)
Let the column object create its array file.
virtual void getSliceComplexV(uInt aRowNr, const Slicer &, Array< Complex > *aDataPtr)
virtual void getFile(uInt aNrRows)
Open an existing file.
virtual void putSliceDComplexV(uInt aRowNr, const Slicer &, const Array< DComplex > *aDataPtr)
virtual void putSliceuCharV(uInt aRowNr, const Slicer &, const Array< uChar > *aDataPtr)
virtual void putSliceuShortV(uInt aRowNr, const Slicer &, const Array< uShort > *aDataPtr)
StIndArray * getArrayPtr(uInt aRowNr)
Return a pointer to the array in the given row (for a get).
SSMIndColumn(SSMBase *aParent, int aDataType, uInt aColNr)
Create a column of the given data type.
virtual void getSliceShortV(uInt aRowNr, const Slicer &, Array< Short > *aDataPtr)
StManArrayFile * itsIosFile
Definition: SSMIndColumn.h:269
virtual void getArrayStringV(uInt aRowNr, Array< String > *aDataPtr)
Read/write indirect arrays.
Definition: StIndArray.h:141
virtual void getSliceStringV(uInt aRowNr, const Slicer &, Array< String > *aDataPtr)
virtual void putArrayuIntV(uInt aRowNr, const Array< uInt > *aDataPtr)
virtual void putArrayBoolV(uInt aRowNr, const Array< Bool > *aDataPtr)
Put an array value into the given row.
A column of Standard storage manager for indirect arrays.
Definition: SSMIndColumn.h:93
virtual IPosition shape(uInt aRowNr)
Get the shape of the array in the given row.
Bool canChangeShape() const
This storage manager can handle changing array shapes.
virtual void putSliceComplexV(uInt aRowNr, const Slicer &, const Array< Complex > *aDataPtr)
Base class of the Standard Storage Manager.
Definition: SSMBase.h:158
virtual Bool isShapeDefined(uInt aRowNr)
Is the shape defined (i.e.
virtual void getArraydoubleV(uInt aRowNr, Array< double > *aDataPtr)
virtual void setShapeColumn(const IPosition &aShape)
Set the (fixed) shape of the arrays in the entire column.
virtual uInt ndim(uInt aRowNr)
Get the dimensionality of the item in the given row.
virtual void getArrayuIntV(uInt aRowNr, Array< uInt > *aDataPtr)
virtual void putArrayShortV(uInt aRowNr, const Array< Short > *aDataPtr)
virtual void putArrayfloatV(uInt aRowNr, const Array< float > *aDataPtr)
void setShape(uInt aRowNr, const IPosition &aShape)
Set the shape of the array in the given row and allocate the array in the file.
virtual void putSliceuIntV(uInt aRowNr, const Slicer &, const Array< uInt > *aDataPtr)
SSMIndColumn & operator=(const SSMIndColumn &)
Forbid assignment.
virtual void getSliceDComplexV(uInt aRowNr, const Slicer &, Array< DComplex > *aDataPtr)
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:39
virtual void addRow(uInt aNewNrRows, uInt anOldNrRows, Bool doInit)
Add (newNrrow-oldNrrow) rows to the column.
A Column in the Standard Storage Manager.
Definition: SSMColumn.h:99
virtual void putArrayIntV(uInt aRowNr, const Array< Int > *aDataPtr)
virtual void putArrayComplexV(uInt aRowNr, const Array< Complex > *aDataPtr)
virtual void getSlicedoubleV(uInt aRowNr, const Slicer &, Array< double > *aDataPtr)
virtual void getArrayShortV(uInt aRowNr, Array< Short > *aDataPtr)
Specify which elements to extract from an n-dimensional array.
Definition: Slicer.h:275
virtual void putArrayStringV(uInt aRowNr, const Array< String > *aDataPtr)
virtual void getArrayuCharV(uInt aRowNr, Array< uChar > *aDataPtr)
StIndArray * getShape(uInt aRowNr)
Read the shape at the given row.
virtual void getArrayIntV(uInt aRowNr, Array< Int > *aDataPtr)
virtual void getArrayComplexV(uInt aRowNr, Array< Complex > *aDataPtr)
virtual void deleteRow(uInt aRowNr)
Remove the given row from the data bucket and possibly string bucket.
virtual void putSliceShortV(uInt aRowNr, const Slicer &, const Array< Short > *aDataPtr)
virtual Bool canAccessSlice(Bool &reask) const
It can handle access to a slice in a cell.
virtual void getSliceBoolV(uInt aRowNr, const Slicer &, Array< Bool > *aDataPtr)
Get a section of the array in the given row.
virtual void setMaxLength(uInt maxLength)
An array of &#39;fixed length&#39; strings is not handled specially, thus this function is ignored...
virtual void putSliceStringV(uInt aRowNr, const Slicer &, const Array< String > *aDataPtr)
virtual void getSliceuShortV(uInt aRowNr, const Slicer &, Array< uShort > *aDataPtr)
Read/write array in external format for a storage manager.
Definition: StArrayFile.h:129
virtual void putArraydoubleV(uInt aRowNr, const Array< double > *aDataPtr)
virtual void getArrayDComplexV(uInt aRowNr, Array< DComplex > *aDataPtr)
virtual void putSlicefloatV(uInt aRowNr, const Slicer &, const Array< float > *aDataPtr)
this file contains all the compiler specific defines
Definition: mainpage.dox:28
virtual void getSliceIntV(uInt aRowNr, const Slicer &, Array< Int > *aDataPtr)
virtual void getArrayuShortV(uInt aRowNr, Array< uShort > *aDataPtr)
virtual void putSliceBoolV(uInt aRowNr, const Slicer &, const Array< Bool > *aDataPtr)
Put into a section of the array in the given row.
unsigned int uInt
Definition: aipstype.h:48
virtual void getSliceuIntV(uInt aRowNr, const Slicer &, Array< uInt > *aDataPtr)
virtual void getArrayfloatV(uInt aRowNr, Array< float > *aDataPtr)
virtual void putArrayuCharV(uInt aRowNr, const Array< uChar > *aDataPtr)
void init()
Initialize part of the object and open/create the file.
~SSMIndColumn()
Frees up the storage.
virtual void putArrayDComplexV(uInt aRowNr, const Array< DComplex > *aDataPtr)
virtual void getSlicefloatV(uInt aRowNr, const Slicer &, Array< float > *aDataPtr)