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.
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  // Add (newNrrow-oldNrrow) rows to the column.
109  virtual void addRow (rownr_t aNewNrRows, rownr_t anOldNrRows, Bool doInit);
110 
111  // Set the (fixed) shape of the arrays in the entire column.
112  virtual void setShapeColumn (const IPosition& aShape);
113 
114  // Get the dimensionality of the item in the given row.
115  virtual uInt ndim (rownr_t aRowNr);
116 
117  // Set the shape of the array in the given row and allocate the array
118  // in the file.
119  void setShape (rownr_t aRowNr, const IPosition& aShape);
120 
121  // Is the shape defined (i.e. is there an array) in this row?
122  virtual Bool isShapeDefined (rownr_t aRowNr);
123 
124  // Get the shape of the array in the given row.
125  virtual IPosition shape (rownr_t aRowNr);
126 
127  // This storage manager can handle changing array shapes.
129 
130  // Get an array value in the given row.
131  // The buffer pointed to by dataPtr has to have the correct length
132  // (which is guaranteed by the ArrayColumn get function).
133  virtual void getArrayV (rownr_t aRowNr, ArrayBase& aDataPtr);
134 
135  // Put an array value into the given row.
136  // The buffer pointed to by dataPtr has to have the correct length
137  // (which is guaranteed by the ArrayColumn put function).
138  virtual void putArrayV (rownr_t aRowNr, const ArrayBase& aDataPtr);
139 
140  // Get a section of the array in the given row.
141  // The buffer pointed to by dataPtr has to have the correct length
142  // (which is guaranteed by the ArrayColumn getSlice function).
143  virtual void getSliceV (rownr_t aRowNr, const Slicer&,
144  ArrayBase& aDataPtr);
145 
146  // Put into a section of the array in the given row.
147  // The buffer pointed to by aDataPtr has to have the correct length
148  // (which is guaranteed by the ArrayColumn putSlice function).
149  virtual void putSliceV (rownr_t aRowNr, const Slicer&,
150  const ArrayBase& aDataPtr);
151 
152  // Let the column object create its array file.
153  virtual void doCreate (rownr_t aNrRows);
154 
155  // Open an existing file.
156  virtual void getFile (rownr_t aNrRows);
157 
158  // Remove the given row from the data bucket and possibly string bucket.
159  virtual void deleteRow(rownr_t aRowNr);
160 
161 
162 private:
163  // Forbid copy constructor.
165 
166  // Forbid assignment.
168 
169  // Initialize part of the object and open/create the file.
170  // It is used by doCreate and getFile.
171  void init();
172 
173  // Read the shape at the given row.
174  // This will cache the information in the StIndArray
175  // object for that row.
177 
178  // Return a pointer to the array in the given row (for a get).
180 
181 
182  //# The shape off all arrays in case it is fixed
184  //# Switch indicating if the shape is fixed.
186  //# The file containing the arrays.
188  //# The indirect array object.
190 };
191 
192 
193 
194 } //# NAMESPACE CASACORE - END
195 
196 #endif
Non-templated base class for templated Array class.
Definition: ArrayBase.h:73
virtual void putSliceV(rownr_t aRowNr, const Slicer &, const ArrayBase &aDataPtr)
Put into a section of the array in the given row.
void init()
Initialize part of the object and open/create the file.
SSMIndColumn & operator=(const SSMIndColumn &)
Forbid assignment.
virtual void deleteRow(rownr_t aRowNr)
Remove the given row from the data bucket and possibly string bucket.
virtual uInt ndim(rownr_t aRowNr)
Get the dimensionality of the item in the given row.
StIndArray * getShape(rownr_t aRowNr)
Read the shape at the given row.
virtual void putArrayV(rownr_t aRowNr, const ArrayBase &aDataPtr)
Put an array value into the given row.
virtual void getArrayV(rownr_t aRowNr, ArrayBase &aDataPtr)
Get an array value in the given row.
virtual void doCreate(rownr_t aNrRows)
Let the column object create its array file.
~SSMIndColumn()
Frees up the storage.
StIndArray * getArrayPtr(rownr_t aRowNr)
Return a pointer to the array in the given row (for a get).
virtual void getFile(rownr_t aNrRows)
Open an existing file.
virtual void addRow(rownr_t aNewNrRows, rownr_t anOldNrRows, Bool doInit)
Add (newNrrow-oldNrrow) rows to the column.
virtual void getSliceV(rownr_t aRowNr, const Slicer &, ArrayBase &aDataPtr)
Get a section of the array in the given row.
virtual IPosition shape(rownr_t aRowNr)
Get the shape of the array in the given row.
SSMIndColumn(SSMBase *aParent, int aDataType, uInt aColNr)
Create a column of the given data type.
virtual Bool isShapeDefined(rownr_t aRowNr)
Is the shape defined (i.e.
void setShape(rownr_t aRowNr, const IPosition &aShape)
Set the shape of the array in the given row and allocate the array in the file.
Bool canChangeShape() const
This storage manager can handle changing array shapes.
virtual void setShapeColumn(const IPosition &aShape)
Set the (fixed) shape of the arrays in the entire column.
StManArrayFile * itsIosFile
Definition: SSMIndColumn.h:187
SSMIndColumn(const SSMIndColumn &)
Forbid copy constructor.
virtual void setMaxLength(uInt maxLength)
An array of 'fixed length' strings is not handled specially, thus this function is ignored.
this file contains all the compiler specific defines
Definition: mainpage.dox:28
unsigned int uInt
Definition: aipstype.h:51
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
uInt64 rownr_t
Define the type of a row number in a table.
Definition: aipsxtype.h:46