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