casacore
 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>
35 
36 namespace casacore { //# NAMESPACE CASACORE - BEGIN
37 
38 //# Forward Declarations
39 class ColumnSet;
40 template<class T> class ScalarColumnDesc;
41 class AipsIO;
42 
43 // <summary>
44 // Access to a table column containing scalars
45 // </summary>
46 
47 // <use visibility=local>
48 
49 // <reviewed reviewer="Gareth Hunt" date="94Nov17" tests="">
50 // </reviewed>
51 
52 // <prerequisite>
53 //# Classes you should understand before using this one.
54 // <li> PlainColumn
55 // <li> ScalarColumnDesc
56 // <li> Table
57 // </prerequisite>
58 
59 // <etymology>
60 // ScalarColumnData represents a table column containing scalars.
61 // </etymology>
62 
63 // <synopsis>
64 // The class ScalarColumnData is derived from PlainColumn.
65 // It implements the virtual functions accessing a table column
66 // containing scalars with an arbitrary data type.
67 //
68 // It is possible to access an scalar an individual cell (i.e. table row)
69 // or in the entire column.
70 //
71 // The main task of this class is to communicate with the data manager
72 // column object. This consists of:
73 // <ul>
74 // <li> Binding itself to a data manager.
75 // <li> Letting the data manager create its column object.
76 // <li> Closing the data manager column object (in putFileDerived).
77 // <li> Reconstructing the data manager object for an existing table
78 // (in getFileDerived).
79 // <li> Transferring get/put calls to the data manager column object.
80 // </ul>
81 //
82 // The class is hidden from the user by the envelope class ScalarColumn.
83 // It used directly, it should be done with care. It assumes that the
84 // arrays in the various get and put functions have the correct length.
85 // ScalarColumn does that check.
86 // </synopsis>
87 
88 // <todo asof="$DATE:$">
89 //# A List of bugs, limitations, extensions or planned refinements.
90 // </todo>
91 
92 
93 template<class T>
95 {
96 public:
97 
98  // Construct a scalar column object from the given description
99  // in the given column set.
100  // This constructor is used by ScalarColumnDesc::makeColumn.
102 
104 
105  // Initialize the rows from startRownr till endRownr (inclusive)
106  // with the default value defined in the column description.
107  virtual void initialize (rownr_t startRownr, rownr_t endRownr);
108 
109  // Test if the given cell contains a defined value.
110  virtual Bool isDefined (rownr_t rownr) const;
111 
112  // Get the value from a particular cell.
113  virtual void get (rownr_t rownr, void*) const;
114 
115  // Get the array of all values in the column.
116  // The length of the buffer pointed to by dataPtr must match
117  // the actual length. This is checked by ScalarColumn.
118  virtual void getScalarColumn (ArrayBase& dataPtr) const;
119 
120  // Get the array of some values in the column (on behalf of RefColumn).
121  // The length of the buffer pointed to by dataPtr must match
122  // the actual length. This is checked by ScalarColumn.
123  virtual void getScalarColumnCells (const RefRows& rownrs,
124  ArrayBase& dataPtr) const;
125 
126  // Put the value in a particular cell.
127  // The length of the buffer pointed to by dataPtr must match
128  // the actual length. This is checked by ScalarColumn.
129  virtual void put (rownr_t rownr, const void* dataPtr);
130 
131  // Put the array of all values in the column.
132  // The length of the buffer pointed to by dataPtr must match
133  // the actual length. This is checked by ScalarColumn.
134  virtual void putScalarColumn (const ArrayBase& dataPtr);
135 
136  // Put the array of some values in the column (on behalf on RefColumn).
137  // The length of the buffer pointed to by dataPtr must match
138  // the actual length. This is checked by ScalarColumn.
139  virtual void putScalarColumnCells (const RefRows& rownrs,
140  const ArrayBase& dataPtr);
141 
142  // Add the sort key to the Sort object on behalf of the Table sort function.
143  // <group>
144  virtual void makeSortKey (Sort&, CountedPtr<BaseCompare>& cmpFunc, Int order,
145  CountedPtr<ArrayBase>& dataSave);
146  // Do it only for the given row numbers.
147  void makeRefSortKey (Sort&, CountedPtr<BaseCompare>& cmpFunc, Int order,
148  const Vector<rownr_t>& rownrs,
149  CountedPtr<ArrayBase>& dataSave);
150  // </group>
151 
152  // Allocate value buffers for the table iterator.
153  // Also get a comparison object if undefined.
154  // The function freeIterBuf must be called to free the buffers.
155  void allocIterBuf (void*& lastVal, void*& curVal,
156  CountedPtr<BaseCompare>& cmpObj);
157 
158  // Free the value buffers allocated by allocIterBuf.
159  void freeIterBuf (void*& lastVal, void*& curVal);
160 
161  // Create a data manager column object for this column.
163 
164 
165 private:
166  // Pointer to column description.
168  // Undefined value can exist?
170  // Undefined value.
172 
173 
174  // Copy constructor cannot be used.
176 
177  // Assignment cannot be used.
179 
180  // Write the column data.
181  // The control information is written into the given AipsIO object,
182  // while the data is written/flushed by the data manager.
183  void putFileDerived (AipsIO&);
184 
185  // Read the column data back.
186  // The control information is read from the given AipsIO object.
187  // This is used to bind the column to the appropriate data manager.
188  // Thereafter the data manager gets opened.
189  void getFileDerived (AipsIO&, const ColumnSet&);
190 
191  // Fill in the sort key on behalf of the Table sort function.
192  // The pointer to the data (which can be allocated on the heap)
193  // is stored in dataPtr. This is used by freeSortKey to release it.
194  // It checks if a compare function is given when needed.
195  // <thrown>
196  // <li> TableInvSort
197  // </thrown>
198  void fillSortKey (const Vector<T>* dataPtr, Sort&,
199  CountedPtr<BaseCompare>& cmpObj, Int order);
200 };
201 
202 
203 
204 } //# NAMESPACE CASACORE - END
205 
206 #ifndef CASACORE_NO_AUTO_TEMPLATES
207 #include <casacore/tables/Tables/ScaColData.tcc>
208 #endif //# CASACORE_NO_AUTO_TEMPLATES
209 #endif
ScalarColumnData(const ScalarColumnDesc< T > *, ColumnSet *)
Construct a scalar column object from the given description in the given column set.
Templated class to define columns of scalars in tables.
Definition: ScaColData.h:40
int Int
Definition: aipstype.h:50
Bool undefFlag_p
Undefined value can exist?
Definition: ScaColData.h:169
Non-templated base class for templated Array class.
Definition: ArrayBase.h:72
virtual void putScalarColumnCells(const RefRows &rownrs, const ArrayBase &dataPtr)
Put the array of some values in the column (on behalf on RefColumn).
AipsIO is the object persistency mechanism of Casacore.
Definition: AipsIO.h:168
virtual void getScalarColumnCells(const RefRows &rownrs, ArrayBase &dataPtr) const
Get the array of some values in the column (on behalf of RefColumn).
virtual void initialize(rownr_t startRownr, rownr_t endRownr)
Initialize the rows from startRownr till endRownr (inclusive) with the default value defined in the c...
virtual void put(rownr_t rownr, const void *dataPtr)
Put the value in a particular cell.
virtual void makeSortKey(Sort &, CountedPtr< BaseCompare > &cmpFunc, Int order, CountedPtr< ArrayBase > &dataSave)
Add the sort key to the Sort object on behalf of the Table sort function.
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
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:247
void putFileDerived(AipsIO &)
Write the column data.
Referenced counted pointer for constant data.
Definition: CountedPtr.h:80
void makeRefSortKey(Sort &, CountedPtr< BaseCompare > &cmpFunc, Int order, const Vector< rownr_t > &rownrs, CountedPtr< ArrayBase > &dataSave)
Do it only for the given row numbers.
void createDataManagerColumn()
Create a data manager column object for this column.
Class holding the row numbers in a RefTable.
Definition: RefRows.h:85
virtual void putScalarColumn(const ArrayBase &dataPtr)
Put the array of all values in the column.
virtual void getScalarColumn(ArrayBase &dataPtr) const
Get the array of all values in the column.
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
void getFileDerived(AipsIO &, const ColumnSet &)
Read the column data back.
virtual Bool isDefined(rownr_t rownr) const
Test if the given cell contains a defined value.
Base class for a column in a plain table.
Definition: PlainColumn.h:84
uInt64 rownr_t
Define the type of a row number in a table.
Definition: aipsxtype.h:46
Access to a table column containing scalars.
Definition: ScaColData.h:94
void freeIterBuf(void *&lastVal, void *&curVal)
Free the value buffers allocated by allocIterBuf.
T undefVal_p
Undefined value.
Definition: ScaColData.h:171
const ScalarColumnDesc< T > * scaDescPtr_p
Pointer to column description.
Definition: ScaColData.h:167