casacore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ArrColData.h
Go to the documentation of this file.
1 //# ArrColData.h: Access to a table column containing arrays
2 //# Copyright (C) 1994,1995,1996,1998,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_ARRCOLDATA_H
29 #define TABLES_ARRCOLDATA_H
30 
31 //# Includes
32 #include <casacore/casa/aips.h>
35 
36 namespace casacore { //# NAMESPACE CASACORE - BEGIN
37 
38 //# Forward Declarations
39 class ColumnSet;
40 class ArrayColumnDescBase;
41 class AipsIO;
42 
43 
44 // <summary>
45 // Access to a table column containing arrays
46 // </summary>
47 
48 // <use visibility=local>
49 
50 // <reviewed reviewer="Gareth Hunt" date="94Nov17" tests="">
51 // </reviewed>
52 
53 // <prerequisite>
54 //# Classes you should understand before using this one.
55 // <li> PlainColumn
56 // <li> ArrayColumnDesc
57 // <li> Table
58 // </prerequisite>
59 
60 // <etymology>
61 // ArrayColumnData represents a table column containing array data.
62 // </etymology>
63 
64 // <synopsis>
65 // The class ArrayColumnData is derived from PlainColumn.
66 // It implements the virtual functions accessing a table column
67 // containing arrays with an arbitrary data type.
68 // Both direct and indirect arrays are supported.
69 //
70 // It is possible to access an array or a subsection of it in an
71 // individual cell (i.e. table row) or in the entire column.
72 // The functions accessing the entire column are implemented by
73 // looping over the individual cells.
74 //
75 // The main task of this class is to communicate with the data manager
76 // column object. This consists of:
77 // <ul>
78 // <li> Binding itself to a data manager.
79 // <li> Letting the data manager create its column object and
80 // setting the shape for direct arrays.
81 // <li> Closing the data manager column object (in putFileDerived).
82 // <li> Reconstructing the data manager object for an existing table
83 // (in getFileDerived).
84 // <li> Transferring get/put calls to the data manager column object.
85 // </ul>
86 //
87 // The class is hidden from the user by the envelope class ArrayColumn.
88 // It used directly, it should be done with care. It assumes that the
89 // arrays in the various get and put functions have the correct length.
90 // ArrayColumn does that check.
91 // </synopsis>
92 
93 // <todo asof="$DATE:$">
94 //# A List of bugs, limitations, extensions or planned refinements.
95 // <li> support tiling
96 // </todo>
97 
98 
100 {
101 public:
102 
103  // Construct an array column object from the given description
104  // in the given column set.
105  // This constructor is used by ArrayColumnDescBase::makeColumn.
107 
109 
110  // Ask the data manager if the shape of an existing array can be changed.
111  virtual Bool canChangeShape() const;
112 
113  // Initialize the rows from startRownr till endRownr (inclusive)
114  // with the default value defined in the column description (if defined).
115  void initialize (rownr_t startRownr, rownr_t endRownr);
116 
117  // Get the global #dimensions of an array (ie. for all rows).
118  uInt ndimColumn() const;
119 
120  // Get the global shape of an array (ie. for all rows).
121  IPosition shapeColumn() const;
122 
123  // Set shape of all arrays in the column.
124  // It can only be used for direct arrays.
125  void setShapeColumn (const IPosition& shape);
126 
127  // Get the #dimensions of an array in a particular cell.
128  // If the cell does not contain an array, 0 is returned.
129  uInt ndim (rownr_t rownr) const;
130 
131  // Get the shape of an array in a particular cell.
132  // If the cell does not contain an array, an empty IPosition is returned.
133  IPosition shape(rownr_t rownr) const;
134 
135  // Get the tile shape of an array in a particular cell.
136  // If the cell does not contain an array, an empty IPosition is returned.
137  IPosition tileShape(rownr_t rownr) const;
138 
139  // Set dimensions of array in a particular cell.
140  // <group>
141  void setShape (rownr_t rownr, const IPosition& shape);
142  // The shape of tiles in the array can also be defined.
143  void setShape (rownr_t rownr, const IPosition& shape,
144  const IPosition& tileShape);
145  // </group>
146 
147  // Test if the given cell contains an array.
148  Bool isDefined (rownr_t rownr) const;
149 
150  // Get the array from a particular cell.
151  // The length of the array given by ArrayBase must match
152  // the actual length. This is checked by ArrayColumn.
153  void getArray (rownr_t rownr, ArrayBase& arrayPtr) const;
154 
155  // Get a slice of an N-dimensional array in a particular cell.
156  // The length of the array given by ArrayBase must match
157  // the actual length. This is checked by ArrayColumn.
158  void getSlice (rownr_t rownr, const Slicer&, ArrayBase& arrayPtr) const;
159 
160  // Get the array of all values in a column.
161  // If the column contains n-dim arrays, the resulting array is (n+1)-dim.
162  // The arrays in the column have to have the same shape in all cells.
163  // The length of the array given by ArrayBase must match
164  // the actual length. This is checked by ArrayColumn.
165  void getArrayColumn (ArrayBase& arrayPtr) const;
166 
167  // Get the array of some values in a column.
168  // If the column contains n-dim arrays, the resulting array is (n+1)-dim.
169  // The arrays in the column have to have the same shape in all cells.
170  // The length of the array given by ArrayBase must match
171  // the actual length. This is checked by ArrayColumn.
172  void getArrayColumnCells (const RefRows& rownrs, ArrayBase& arrayPtr) const;
173 
174  // Get subsections from all arrays in the column.
175  // If the column contains n-dim arrays, the resulting array is (n+1)-dim.
176  // The arrays in the column have to have the same shape in all cells.
177  // The length of the array given by ArrayBase must match
178  // the actual length. This is checked by ArrayColumn.
179  void getColumnSlice (const Slicer&, ArrayBase& arrayPtr) const;
180 
181  // Get subsections from some arrays in the column.
182  // If the column contains n-dim arrays, the resulting array is (n+1)-dim.
183  // The arrays in the column have to have the same shape in all cells.
184  // The length of the array given by ArrayBase must match
185  // the actual length. This is checked by ArrayColumn.
186  void getColumnSliceCells (const RefRows& rownrs, const Slicer&,
187  ArrayBase& arrayPtr) const;
188 
189  // Put the value in a particular cell.
190  // The length of the array given by ArrayBase must match
191  // the actual length. This is checked by ArrayColumn.
192  void putArray (rownr_t rownr, const ArrayBase& arrayPtr);
193 
194  // Put a slice of an N-dimensional array in a particular cell.
195  // The length of the array given by ArrayBase must match
196  // the actual length. This is checked by ArrayColumn.
197  void putSlice (rownr_t rownr, const Slicer&, const ArrayBase& arrayPtr);
198 
199  // Put the array of all values in the column.
200  // If the column contains n-dim arrays, the source array is (n+1)-dim.
201  // The arrays in the column have to have the same shape in all cells.
202  // The length of the array given by ArrayBase must match
203  // the actual length. This is checked by ArrayColumn.
204  void putArrayColumn (const ArrayBase& arrayPtr);
205 
206  // Put the array of some values in the column.
207  // If the column contains n-dim arrays, the source array is (n+1)-dim.
208  // The arrays in the column have to have the same shape in all cells.
209  // The length of the array given by ArrayBase must match
210  // the actual length. This is checked by ArrayColumn.
211  void putArrayColumnCells (const RefRows& rownrs, const ArrayBase& arrayPtr);
212 
213  // Put into subsections of all table arrays in the column.
214  // If the column contains n-dim arrays, the source array is (n+1)-dim.
215  // The arrays in the column have to have the same shape in all cells.
216  // The length of the array given by ArrayBase must match
217  // the actual length. This is checked by ArrayColumn.
218  void putColumnSlice (const Slicer&, const ArrayBase& arrayPtr);
219 
220  // Put into subsections of some table arrays in the column.
221  // If the column contains n-dim arrays, the source array is (n+1)-dim.
222  // The arrays in the column have to have the same shape in all cells.
223  // The length of the array given by ArrayBase must match
224  // the actual length. This is checked by ArrayColumn.
225  void putColumnSliceCells (const RefRows& rownrs, const Slicer&,
226  const ArrayBase& arrayPtr);
227 
228  // Create a data manager column object for this column.
230 
231 
232 private:
233  // Pointer to column description.
235  // Is the shape for all arrays in the columns defined.
237  // Shape for all arrays in the column.
239  // Does the length of a string has to be checked?
241 
242 
243  // Copy constructor cannot be used.
245 
246  // Assignment cannot be used.
248 
249  // Check if the shape of an array can be set and if it is set
250  // correctly (i.e. if matching possible #dim in column description).
251  void checkShape (const IPosition& shape) const;
252 
253  // Write the column data.
254  // The control information is written into the given AipsIO object,
255  // while the data is written/flushed by the data manager.
256  void putFileDerived (AipsIO&);
257 
258  // Read the column data back.
259  // The control information is read from the given AipsIO object.
260  // This is used to bind the column to the appropriate data manager.
261  // Thereafter the data manager gets opened.
262  void getFileDerived (AipsIO&, const ColumnSet&);
263 };
264 
265 
266 
267 
268 } //# NAMESPACE CASACORE - END
269 
270 #endif
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:118
void getColumnSliceCells(const RefRows &rownrs, const Slicer &, ArrayBase &arrayPtr) const
Get subsections from some arrays in the column.
IPosition shapeCol_p
Shape for all arrays in the column.
Definition: ArrColData.h:238
Non-templated base class for templated Array class.
Definition: ArrayBase.h:72
Bool shapeColDef_p
Is the shape for all arrays in the columns defined.
Definition: ArrColData.h:236
AipsIO is the object persistency mechanism of Casacore.
Definition: AipsIO.h:168
void putArrayColumn(const ArrayBase &arrayPtr)
Put the array of all values in the column.
void getArrayColumn(ArrayBase &arrayPtr) const
Get the array of all values in a column.
IPosition shape(rownr_t rownr) const
Get the shape of an array in a particular cell.
void initialize(rownr_t startRownr, rownr_t endRownr)
Initialize the rows from startRownr till endRownr (inclusive) with the default value defined in the c...
ArrayColumnData(const ArrayColumnDescBase *, ColumnSet *)
Construct an array column object from the given description in the given column set.
Abstract base class for description of table array columns.
Definition: ArrColDesc.h:63
ArrayColumnData & operator=(const ArrayColumnData &)
Assignment cannot be used.
Class to manage a set of table columns.
Definition: ColumnSet.h:93
void putColumnSliceCells(const RefRows &rownrs, const Slicer &, const ArrayBase &arrayPtr)
Put into subsections of some table arrays in the column.
Access to a table column containing arrays.
Definition: ArrColData.h:99
void putColumnSlice(const Slicer &, const ArrayBase &arrayPtr)
Put into subsections of all table arrays in the column.
Bool isDefined(rownr_t rownr) const
Test if the given cell contains an array.
void setShape(rownr_t rownr, const IPosition &shape)
Set dimensions of array in a particular cell.
void putFileDerived(AipsIO &)
Write the column data.
void putArrayColumnCells(const RefRows &rownrs, const ArrayBase &arrayPtr)
Put the array of some values in the column.
IPosition tileShape(rownr_t rownr) const
Get the tile shape of an array in a particular cell.
uInt ndimColumn() const
Get the global #dimensions of an array (ie.
void getArray(rownr_t rownr, ArrayBase &arrayPtr) const
Get the array from a particular cell.
Class holding the row numbers in a RefTable.
Definition: RefRows.h:85
void putArray(rownr_t rownr, const ArrayBase &arrayPtr)
Put the value in a particular cell.
void createDataManagerColumn()
Create a data manager column object for this column.
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
void getArrayColumnCells(const RefRows &rownrs, ArrayBase &arrayPtr) const
Get the array of some values in a column.
void checkShape(const IPosition &shape) const
Check if the shape of an array can be set and if it is set correctly (i.e.
void getFileDerived(AipsIO &, const ColumnSet &)
Read the column data back.
Bool checkValueLength_p
Does the length of a string has to be checked?
Definition: ArrColData.h:240
Specify which elements to extract from an n-dimensional array.
Definition: Slicer.h:288
Base class for a column in a plain table.
Definition: PlainColumn.h:84
IPosition shapeColumn() const
Get the global shape of an array (ie.
uInt64 rownr_t
Define the type of a row number in a table.
Definition: aipsxtype.h:46
virtual Bool canChangeShape() const
Ask the data manager if the shape of an existing array can be changed.
void getSlice(rownr_t rownr, const Slicer &, ArrayBase &arrayPtr) const
Get a slice of an N-dimensional array in a particular cell.
void putSlice(rownr_t rownr, const Slicer &, const ArrayBase &arrayPtr)
Put a slice of an N-dimensional array in a particular cell.
void setShapeColumn(const IPosition &shape)
Set shape of all arrays in the column.
const ArrayColumnDescBase * arrDescPtr_p
Pointer to column description.
Definition: ArrColData.h:234
void getColumnSlice(const Slicer &, ArrayBase &arrayPtr) const
Get subsections from all arrays in the column.
unsigned int uInt
Definition: aipstype.h:51
uInt ndim(rownr_t rownr) const
Get the #dimensions of an array in a particular cell.