casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RefColumn.h
Go to the documentation of this file.
1 //# RefColumn.h: A column in a reference table
2 //# Copyright (C) 1994,1995,1996,1997,1998
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_REFCOLUMN_H
29 #define TABLES_REFCOLUMN_H
30 
31 
32 //# Includes
33 #include <casacore/casa/aips.h>
36 
37 namespace casacore { //# NAMESPACE CASACORE - BEGIN
38 
39 //# Forward Declarations
40 class RefTable;
41 class BaseColumnDesc;
42 class TableRecord;
43 class Slicer;
44 class IPosition;
45 template<class T> class Vector;
46 
47 
48 // <summary>
49 // A column in a reference table
50 // </summary>
51 
52 // <use visibility=local>
53 
54 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
55 // </reviewed>
56 
57 // <prerequisite>
58 //# Classes you should understand before using this one.
59 // <li> RefTable
60 // <li> BaseColumn
61 // </prerequisite>
62 
63 // <etymology>
64 // RefTable represents a column in a RefTable. A RefTable is a table
65 // referencing another table, usually as the result of a select, etc..
66 // </etymology>
67 
68 // <synopsis>
69 // RefColumn handles the access of a column in a RefTable.
70 // It calls the corresponding function in the referenced column
71 // while converting the given row number to the row number in the
72 // referenced table.
73 // </synopsis>
74 
75 // <motivation>
76 // This class is untyped, i.e. not templated.
77 // Every call is sent to the underlying referenced BaseColumn which
78 // is typed by the virtual function mechanism.
79 // A RefColumn can never be used directly. A user always has to
80 // construct a typed ArrayColumn or ScalarColumn object to access a column.
81 // This means everyting is fully type safe.
82 // </motivation>
83 
84 // <todo asof="$DATE:$">
85 //# A List of bugs, limitations, extensions or planned refinements.
86 // <li> Act upon removal of rows or the underlying column
87 // </todo>
88 
89 
90 class RefColumn : public BaseColumn
91 {
92 public:
93 
94  // Construct the RefColumn. It will point to the given column
95  // description, RefTable and referenced column.
96  // The RefTable will be used to convert the rownr to the rownr
97  // in the referenced column.
98  RefColumn (const BaseColumnDesc*, RefTable*, BaseColumn* referencedColumn);
99 
100  ~RefColumn();
101 
102  // Test if the column is writable in the parent table.
103  virtual Bool isWritable() const;
104 
105  // Test if the column is stored (otherwise it is virtual).
106  virtual Bool isStored() const;
107 
108  // Get access to the column keyword set.
109  // This is the keyword set in the referenced column.
110  // <group>
111  virtual TableRecord& rwKeywordSet();
112  virtual TableRecord& keywordSet();
113  // </group>
114 
115  // Get nr of rows in the column.
116  virtual uInt nrow() const;
117 
118  // Test if a value in a particular cell has been defined.
119  virtual Bool isDefined (uInt rownr) const;
120 
121  // Set the shape of the array in the given row.
122  virtual void setShape (uInt rownr, const IPosition& shape);
123 
124  // Set the shape and tile shape of the array in the given row.
125  virtual void setShape (uInt rownr, const IPosition& shape,
126  const IPosition& tileShape);
127 
128  // Get the global #dimensions of an array (i.e. for all rows).
129  virtual uInt ndimColumn() const;
130 
131  // Get the global shape of an array (i.e. for all rows).
132  virtual IPosition shapeColumn() const;
133 
134  // Get the #dimensions of an array in a particular cell.
135  virtual uInt ndim (uInt rownr) const;
136 
137  // Get the shape of an array in a particular cell.
138  virtual IPosition shape (uInt rownr) const;
139 
140  // It can change shape if the underlying column can.
141  virtual Bool canChangeShape() const;
142 
143  // It can handle a scalar column if the underlying column
144  // can handle cells in a scalar column.
145  virtual Bool canAccessScalarColumn (Bool& reask) const;
146 
147  // It can handle an array column if the underlying column
148  // can handle cells in an array column.
149  virtual Bool canAccessArrayColumn (Bool& reask) const;
150 
151  // It can handle a cell slice if the underlying column can do it.
152  virtual Bool canAccessSlice (Bool& reask) const;
153 
154  // It can handle a column slice if the underlying column
155  // can handle a collection of cells in a column and a column slice.
156  virtual Bool canAccessColumnSlice (Bool& reask) const;
157 
158  // It can handle cells in a scalar column if the underlying column
159  // can do it.
160  virtual Bool canAccessScalarColumnCells (Bool& reask) const;
161 
162  // It can handle cells in an array column if the underlying column
163  // can do it.
164  virtual Bool canAccessArrayColumnCells (Bool& reask) const;
165 
166  // Initialize the rows from startRownr till endRownr (inclusive)
167  // with the default value defined in the column description (if defined).
168  void initialize (uInt startRownr, uInt endRownr);
169 
170  // Get the value from a particular cell.
171  // This can be a scalar or an array.
172  virtual void get (uInt rownr, void* dataPtr) const;
173 
174  // Get a slice of an N-dimensional array in a particular cell.
175  virtual void getSlice (uInt rownr, const Slicer&, void* dataPtr) const;
176 
177  // Get the vector of all scalar values in a column.
178  virtual void getScalarColumn (void* dataPtr) const;
179 
180  // Get the array of all array values in a column.
181  // If the column contains n-dim arrays, the resulting array is (n+1)-dim.
182  // The arrays in the column have to have the same shape in all cells.
183  virtual void getArrayColumn (void* dataPtr) const;
184 
185  // Get subsections from all arrays in the column.
186  // If the column contains n-dim arrays, the resulting array is (n+1)-dim.
187  // The arrays in the column have to have the same shape in all cells.
188  virtual void getColumnSlice (const Slicer&, void* dataPtr) const;
189 
190  // Get the vector of some scalar values in a column.
191  virtual void getScalarColumnCells (const RefRows& rownrs,
192  void* dataPtr) const;
193 
194  // Get the array of some array values in a column.
195  // If the column contains n-dim arrays, the resulting array is (n+1)-dim.
196  // The arrays in the column have to have the same shape in all cells.
197  virtual void getArrayColumnCells (const RefRows& rownrs,
198  void* dataPtr) const;
199 
200  // Get subsections from some arrays in the column.
201  // If the column contains n-dim arrays, the resulting array is (n+1)-dim.
202  // The arrays in the column have to have the same shape in all cells.
203  virtual void getColumnSliceCells (const RefRows& rownrs,
204  const Slicer&, void* dataPtr) const;
205 
206  // Put the value in a particular cell.
207  // This can be a scalar or an array.
208  virtual void put (uInt rownr, const void* dataPtr);
209 
210  // Put a slice of an N-dimensional array in a particular cell.
211  virtual void putSlice (uInt rownr, const Slicer&, const void* dataPtr);
212 
213  // Put the vector of all scalar values in the column.
214  virtual void putScalarColumn (const void* dataPtr);
215 
216  // Put the array of all array values in the column.
217  // If the column contains n-dim arrays, the source array is (n+1)-dim.
218  // The arrays in the column have to have the same shape in all cells.
219  virtual void putArrayColumn (const void* dataPtr);
220 
221  // Put into subsections of all table arrays in the column.
222  // If the column contains n-dim arrays, the source array is (n+1)-dim.
223  // The arrays in the column have to have the same shape in all cells.
224  virtual void putColumnSlice (const Slicer&, const void* dataPtr);
225 
226  // Get the vector of some scalar values in a column.
227  virtual void putScalarColumnCells (const RefRows& rownrs,
228  const void* dataPtr);
229 
230  // Get the array of some array values in a column.
231  // If the column contains n-dim arrays, the resulting array is (n+1)-dim.
232  // The arrays in the column have to have the same shape in all cells.
233  virtual void putArrayColumnCells (const RefRows& rownrs,
234  const void* dataPtr);
235 
236  // Put subsections of some arrays in the column.
237  // If the column contains n-dim arrays, the source array is (n+1)-dim.
238  // The arrays in the column have to have the same shape in all cells.
239  virtual void putColumnSliceCells (const RefRows& rownrs,
240  const Slicer&, const void* dataPtr);
241 
242  // Get the underlying column cache.
243  virtual ColumnCache& columnCache();
244 
245  // Set the maximum cache size (in bytes) to be used by a storage manager.
246  virtual void setMaximumCacheSize (uInt nbytes);
247 
248  // Add this column and its data to the Sort object.
249  // It may allocate some storage on the heap, which will be saved
250  // in the argument dataSave.
251  // The function freeSortKey must be called to free this storage.
252  virtual void makeSortKey (Sort&, CountedPtr<BaseCompare>& cmpObj,
253  Int order, const void*& dataSave);
254 
255  // Free storage on the heap allocated by makeSortkey().
256  // The pointer will be set to zero.
257  virtual void freeSortKey (const void*& dataSave);
258 
259  // Allocate value buffers for the table iterator.
260  // Also get a comparison functiuon if undefined.
261  // The function freeIterBuf must be called to free the buffers.
262  virtual void allocIterBuf (void*& lastVal, void*& curVal,
263  CountedPtr<BaseCompare>& cmpObj);
264 
265  // Free the value buffers allocated by allocIterBuf.
266  virtual void freeIterBuf (void*& lastVal, void*& curVal);
267 
268 protected:
272 };
273 
274 
275 
276 
277 } //# NAMESPACE CASACORE - END
278 
279 #endif
RefColumn(const BaseColumnDesc *, RefTable *, BaseColumn *referencedColumn)
Construct the RefColumn.
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:119
virtual Bool canAccessScalarColumnCells(Bool &reask) const
It can handle cells in a scalar column if the underlying column can do it.
virtual void getColumnSliceCells(const RefRows &rownrs, const Slicer &, void *dataPtr) const
Get subsections from some arrays in the column.
virtual void put(uInt rownr, const void *dataPtr)
Put the value in a particular cell.
int Int
Definition: aipstype.h:50
virtual void putArrayColumn(const void *dataPtr)
Put the array of all array values in the column.
std::vector< double > Vector
Definition: ds9context.h:24
BaseColumn * colPtr_p
Definition: RefColumn.h:270
virtual void allocIterBuf(void *&lastVal, void *&curVal, CountedPtr< BaseCompare > &cmpObj)
Allocate value buffers for the table iterator.
virtual void putColumnSliceCells(const RefRows &rownrs, const Slicer &, const void *dataPtr)
Put subsections of some arrays in the column.
An abstract base class for table column descriptions.
Definition: BaseColDesc.h:107
virtual Bool canAccessSlice(Bool &reask) const
It can handle a cell slice if the underlying column can do it.
virtual Bool canChangeShape() const
It can change shape if the underlying column can.
virtual Bool canAccessColumnSlice(Bool &reask) const
It can handle a column slice if the underlying column can handle a collection of cells in a column an...
virtual TableRecord & keywordSet()
virtual TableRecord & rwKeywordSet()
Get access to the column keyword set.
virtual Bool canAccessArrayColumn(Bool &reask) const
It can handle an array column if the underlying column can handle cells in an array column...
virtual uInt nrow() const
Get nr of rows in the column.
virtual void freeSortKey(const void *&dataSave)
Free storage on the heap allocated by makeSortkey().
virtual uInt ndimColumn() const
Get the global #dimensions of an array (i.e.
ColumnCache colCache_p
Definition: RefColumn.h:271
virtual void getScalarColumn(void *dataPtr) const
Get the vector of all scalar values in a column.
virtual void getArrayColumnCells(const RefRows &rownrs, void *dataPtr) const
Get the array of some array values in a column.
virtual ColumnCache & columnCache()
Get the underlying column cache.
Sort on one or more keys, ascending and/or descending.
Definition: Sort.h:248
virtual void putScalarColumn(const void *dataPtr)
Put the vector of all scalar values in the column.
virtual void getScalarColumnCells(const RefRows &rownrs, void *dataPtr) const
Get the vector of some scalar values in a column.
virtual void setMaximumCacheSize(uInt nbytes)
Set the maximum cache size (in bytes) to be used by a storage manager.
virtual void setShape(uInt rownr, const IPosition &shape)
Set the shape of the array in the given row.
virtual void putArrayColumnCells(const RefRows &rownrs, const void *dataPtr)
Get the array of some array values in a column.
Referenced counted pointer for constant data.
Definition: VisModelData.h:42
virtual uInt ndim(uInt rownr) const
Get the #dimensions of an array in a particular cell.
Class for a table as a view of another table.
Definition: RefTable.h:104
virtual Bool canAccessArrayColumnCells(Bool &reask) const
It can handle cells in an array column if the underlying column can do it.
Class holding the row numbers in a RefTable.
Definition: RefRows.h:85
void initialize(uInt startRownr, uInt endRownr)
Initialize the rows from startRownr till endRownr (inclusive) with the default value defined in the c...
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
A caching object for a table column.
Definition: ColumnCache.h:83
virtual void getArrayColumn(void *dataPtr) const
Get the array of all array values in a column.
A hierarchical collection of named fields of various types.
Definition: TableRecord.h:182
virtual void putScalarColumnCells(const RefRows &rownrs, const void *dataPtr)
Get the vector of some scalar values in a column.
Specify which elements to extract from an n-dimensional array.
Definition: Slicer.h:289
virtual void getColumnSlice(const Slicer &, void *dataPtr) const
Get subsections from all arrays in the column.
virtual void makeSortKey(Sort &, CountedPtr< BaseCompare > &cmpObj, Int order, const void *&dataSave)
Add this column and its data to the Sort object.
virtual IPosition shape(uInt rownr) const
Get the shape of an array in a particular cell.
virtual Bool isStored() const
Test if the column is stored (otherwise it is virtual).
virtual Bool isDefined(uInt rownr) const
Test if a value in a particular cell has been defined.
virtual void putSlice(uInt rownr, const Slicer &, const void *dataPtr)
Put a slice of an N-dimensional array in a particular cell.
virtual void putColumnSlice(const Slicer &, const void *dataPtr)
Put into subsections of all table arrays in the column.
virtual void freeIterBuf(void *&lastVal, void *&curVal)
Free the value buffers allocated by allocIterBuf.
virtual void getSlice(uInt rownr, const Slicer &, void *dataPtr) const
Get a slice of an N-dimensional array in a particular cell.
virtual Bool canAccessScalarColumn(Bool &reask) const
It can handle a scalar column if the underlying column can handle cells in a scalar column...
RefTable * refTabPtr_p
Definition: RefColumn.h:269
virtual Bool isWritable() const
Test if the column is writable in the parent table.
virtual IPosition shapeColumn() const
Get the global shape of an array (i.e.
virtual IPosition tileShape(uInt rownr) const
Get the tile shape of an array in a particular cell.
A column in a reference table.
Definition: RefColumn.h:90
unsigned int uInt
Definition: aipstype.h:51
Abstract base class for a table column.
Definition: BaseColumn.h:98
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42