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