casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ScaColData.h
Go to the documentation of this file.
1 //# ScaColData.h: Access to a table column containing scalars
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_SCACOLDATA_H
29 #define TABLES_SCACOLDATA_H
30 
31 //# Includes
32 #include <casacore/casa/aips.h>
34 
35 namespace casacore { //# NAMESPACE CASACORE - BEGIN
36 
37 //# Forward Declarations
38 class ColumnSet;
39 template<class T> class ScalarColumnDesc;
40 class AipsIO;
41 template<class T> class Vector;
42 
43 
44 // <summary>
45 // Access to a table column containing scalars
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> ScalarColumnDesc
57 // <li> Table
58 // </prerequisite>
59 
60 // <etymology>
61 // ScalarColumnData represents a table column containing scalars.
62 // </etymology>
63 
64 // <synopsis>
65 // The class ScalarColumnData is derived from PlainColumn.
66 // It implements the virtual functions accessing a table column
67 // containing scalars with an arbitrary data type.
68 //
69 // It is possible to access an scalar an individual cell (i.e. table row)
70 // or in the entire column.
71 //
72 // The main task of this class is to communicate with the data manager
73 // column object. This consists of:
74 // <ul>
75 // <li> Binding itself to a data manager.
76 // <li> Letting the data manager create its column object.
77 // <li> Closing the data manager column object (in putFileDerived).
78 // <li> Reconstructing the data manager object for an existing table
79 // (in getFileDerived).
80 // <li> Transferring get/put calls to the data manager column object.
81 // </ul>
82 //
83 // The class is hidden from the user by the envelope class ScalarColumn.
84 // It used directly, it should be done with care. It assumes that the
85 // arrays in the various get and put functions have the correct length.
86 // ScalarColumn does that check.
87 // </synopsis>
88 
89 // <todo asof="$DATE:$">
90 //# A List of bugs, limitations, extensions or planned refinements.
91 // </todo>
92 
93 
94 template<class T>
96 {
97 public:
98 
99  // Construct a scalar column object from the given description
100  // in the given column set.
101  // This constructor is used by ScalarColumnDesc::makeColumn.
103 
105 
106  // Ask if the data manager can handle a column.
107  Bool canAccessScalarColumn (Bool& reask) const;
108 
109  // Ask if the data manager can handle some cells in a column.
110  Bool canAccessScalarColumnCells (Bool& reask) const;
111 
112  // Initialize the rows from startRownr till endRownr (inclusive)
113  // with the default value defined in the column description.
114  void initialize (uInt startRownr, uInt endRownr);
115 
116  // Test if the given cell contains a defined value.
117  Bool isDefined (uInt rownr) const;
118 
119  // Get the value from a particular cell.
120  void get (uInt rownr, void*) const;
121 
122  // Get the array of all values in the column.
123  // The length of the buffer pointed to by dataPtr must match
124  // the actual length. This is checked by ScalarColumn.
125  void getScalarColumn (void* dataPtr) const;
126 
127  // Get the array of some values in the column (on behalf of RefColumn).
128  // The length of the buffer pointed to by dataPtr must match
129  // the actual length. This is checked by ScalarColumn.
130  void getScalarColumnCells (const RefRows& rownrs, void* dataPtr) const;
131 
132  // Put the value in a particular cell.
133  // The length of the buffer pointed to by dataPtr must match
134  // the actual length. This is checked by ScalarColumn.
135  void put (uInt rownr, const void* dataPtr);
136 
137  // Put the array of all values in the column.
138  // The length of the buffer pointed to by dataPtr must match
139  // the actual length. This is checked by ScalarColumn.
140  void putScalarColumn (const void* dataPtr);
141 
142  // Put the array of some values in the column (on behalf on RefColumn).
143  // The length of the buffer pointed to by dataPtr must match
144  // the actual length. This is checked by ScalarColumn.
145  void putScalarColumnCells (const RefRows& rownrs, const void* dataPtr);
146 
147  // Add this column and its data to the Sort object.
148  // It may allocate some storage on the heap, which will be saved
149  // in the argument dataSave.
150  // The function freeSortKey must be called to free this storage.
151  // <thrown>
152  // <li> TableInvSort
153  // </thrown>
154  // <group>
155  void makeSortKey (Sort&, CountedPtr<BaseCompare>& cmpFunc, Int order,
156  const void*& dataSave);
157  // Do it only for the given row numbers.
158  void makeRefSortKey (Sort&, CountedPtr<BaseCompare>& cmpFunc, Int order,
159  const Vector<uInt>& rownrs, const void*& dataSave);
160  // </group>
161 
162  // Free storage on the heap allocated by makeSortkey().
163  // The pointer will be set to zero.
164  void freeSortKey (const void*& dataSave);
165 
166  // Allocate value buffers for the table iterator.
167  // Also get a comparison object if undefined.
168  // The function freeIterBuf must be called to free the buffers.
169  void allocIterBuf (void*& lastVal, void*& curVal,
170  CountedPtr<BaseCompare>& cmpObj);
171 
172  // Free the value buffers allocated by allocIterBuf.
173  void freeIterBuf (void*& lastVal, void*& curVal);
174 
175  // Create a data manager column object for this column.
177 
178 
179 private:
180  // Pointer to column description.
182  // Undefined value can exist?
184  // Undefined value.
186 
187 
188  // Copy constructor cannot be used.
190 
191  // Assignment cannot be used.
193 
194  // Write the column data.
195  // The control information is written into the given AipsIO object,
196  // while the data is written/flushed by the data manager.
197  void putFileDerived (AipsIO&);
198 
199  // Read the column data back.
200  // The control information is read from the given AipsIO object.
201  // This is used to bind the column to the appropriate data manager.
202  // Thereafter the data manager gets opened.
203  void getFileDerived (AipsIO&, const ColumnSet&);
204 
205  // Fill in the sort key on behalf of the Table sort function.
206  // The pointer to the data (which can be allocated on the heap)
207  // is stored in dataPtr. This is used by freeSortKey to release it.
208  // It checks if a compare function is given when needed.
209  // <thrown>
210  // <li> TableInvSort
211  // </thrown>
212  void fillSortKey (const Vector<T>* dataPtr, Sort&,
213  CountedPtr<BaseCompare>& cmpObj, Int order);
214 };
215 
216 
217 
218 } //# NAMESPACE CASACORE - END
219 
220 #ifndef CASACORE_NO_AUTO_TEMPLATES
221 #include <casacore/tables/Tables/ScaColData.tcc>
222 #endif //# CASACORE_NO_AUTO_TEMPLATES
223 #endif
ScalarColumnData(const ScalarColumnDesc< T > *, ColumnSet *)
Construct a scalar column object from the given description in the given column set.
A 1-D Specialization of the Array class.
void putScalarColumn(const void *dataPtr)
Put the array of all values in the column.
Templated class to define columns of scalars in tables.
Definition: ScaColData.h:39
void makeRefSortKey(Sort &, CountedPtr< BaseCompare > &cmpFunc, Int order, const Vector< uInt > &rownrs, const void *&dataSave)
Do it only for the given row numbers.
int Int
Definition: aipstype.h:50
Bool undefFlag_p
Undefined value can exist?
Definition: ScaColData.h:183
AipsIO is the object persistency mechanism of Casacore.
Definition: AipsIO.h:168
void put(uInt rownr, const void *dataPtr)
Put the value in a particular cell.
void initialize(uInt startRownr, uInt endRownr)
Initialize the rows from startRownr till endRownr (inclusive) with the default value defined in the c...
void fillSortKey(const Vector< T > *dataPtr, Sort &, CountedPtr< BaseCompare > &cmpObj, Int order)
Fill in the sort key on behalf of the Table sort function.
Class to manage a set of table columns.
Definition: ColumnSet.h:93
Bool canAccessScalarColumn(Bool &reask) const
Ask if the data manager can handle a column.
void allocIterBuf(void *&lastVal, void *&curVal, CountedPtr< BaseCompare > &cmpObj)
Allocate value buffers for the table iterator.
ScalarColumnData< T > & operator=(const ScalarColumnData< T > &)
Assignment cannot be used.
Sort on one or more keys, ascending and/or descending.
Definition: Sort.h:248
void putFileDerived(AipsIO &)
Write the column data.
Referenced counted pointer for constant data.
Definition: VisModelData.h:42
void createDataManagerColumn()
Create a data manager column object for this column.
Class holding the row numbers in a RefTable.
Definition: RefRows.h:85
Bool isDefined(uInt rownr) const
Test if the given cell contains a defined value.
void getScalarColumnCells(const RefRows &rownrs, void *dataPtr) const
Get the array of some values in the column (on behalf of RefColumn).
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
void getScalarColumn(void *dataPtr) const
Get the array of all values in the column.
void getFileDerived(AipsIO &, const ColumnSet &)
Read the column data back.
Base class for a column in a plain table.
Definition: PlainColumn.h:84
void putScalarColumnCells(const RefRows &rownrs, const void *dataPtr)
Put the array of some values in the column (on behalf on RefColumn).
Access to a table column containing scalars.
Definition: ScaColData.h:95
void freeIterBuf(void *&lastVal, void *&curVal)
Free the value buffers allocated by allocIterBuf.
void freeSortKey(const void *&dataSave)
Free storage on the heap allocated by makeSortkey().
T undefVal_p
Undefined value.
Definition: ScaColData.h:185
void makeSortKey(Sort &, CountedPtr< BaseCompare > &cmpFunc, Int order, const void *&dataSave)
Add this column and its data to the Sort object.
const ScalarColumnDesc< T > * scaDescPtr_p
Pointer to column description.
Definition: ScaColData.h:181
Bool canAccessScalarColumnCells(Bool &reask) const
Ask if the data manager can handle some cells in a column.
unsigned int uInt
Definition: aipstype.h:51
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42