casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ScaRecordColData.h
Go to the documentation of this file.
1 //# ScaRecordColData.h: Access to a table column containing scalar records
2 //# Copyright (C) 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_SCARECORDCOLDATA_H
29 #define TABLES_SCARECORDCOLDATA_H
30 
31 
32 //# Includes
33 #include <casacore/casa/aips.h>
35 
36 namespace casacore { //# NAMESPACE CASACORE - BEGIN
37 
38 //# Forward Declarations
39 class ColumnSet;
40 class ScalarRecordColumnDesc;
41 class AipsIO;
42 template<class T> class Vector;
43 
44 
45 // <summary>
46 // Access to a table column containing scalar records.
47 // </summary>
48 
49 // <use visibility=local>
50 
51 // <reviewed reviewer="Wim Brouw" date="1998/12/09" tests="tRecordColumn.cc">
52 // </reviewed>
53 
54 // <prerequisite>
55 //# Classes you should understand before using this one.
56 // <li> <linkto class=PlainColumn>PlainColumn</linkto>
57 // <li> <linkto class=ScalarRecordColumnDesc>ScalarRecordColumnDesc</linkto>
58 // <li> <linkto class=Table>Table</linkto>
59 // </prerequisite>
60 
61 // <etymology>
62 // ScalarRecordColumnData represents a table column containing scalars.
63 // </etymology>
64 
65 // <synopsis>
66 // The class ScalarRecordColumnData is derived from PlainColumn.
67 // It implements the virtual functions accessing a table column
68 // containing scalars holding records.
69 // <br>
70 // It is possible to access an scalar in an individual cell (i.e. table row)
71 // or in the entire column.
72 // <p>
73 // The main task of this class is to communicate with the data manager
74 // column object. This consists of:
75 // <ul>
76 // <li> Binding itself to a data manager.
77 // <li> Letting the data manager create its column object.
78 // <li> Closing the data manager column object (in putFileDerived).
79 // <li> Reconstructing the data manager object for an existing table
80 // (in getFileDerived).
81 // <li> Transferring get/put calls to the data manager column object.
82 // </ul>
83 //
84 // The class is hidden from the user by the envelope class ScalarColumn.
85 // If used directly by other Table classes, it should be done with care.
86 // It assumes that the arrays in the various get and put functions have
87 // the correct length. ScalarColumn does that check.
88 // </synopsis>
89 
90 // <todo asof="$DATE:$">
91 //# A List of bugs, limitations, extensions or planned refinements.
92 // <li> Introduce a class ArrayRecordColumnData to support arrays of records.
93 // </todo>
94 
95 
97 {
98 public:
99 
100  // Construct a scalar column object from the given description
101  // in the given column set.
102  // This constructor is used by ScalarRecordColumnDesc::makeColumn.
104 
106 
107  // Ask if the data manager can handle a column.
108  virtual Bool canAccessScalarColumn (Bool& reask) const;
109 
110  // Ask if the data manager can handle some cells in a column.
111  virtual Bool canAccessScalarColumnCells (Bool& reask) const;
112 
113  // Initialize the rows from startRownr till endRownr (inclusive)
114  // with the default value defined in the column description.
115  virtual void initialize (uInt startRownr, uInt endRownr);
116 
117  // Test if the given cell contains a defined value.
118  virtual Bool isDefined (uInt rownr) const;
119 
120  // Get the value from a particular cell.
121  virtual void get (uInt rownr, void*) const;
122 
123  // Get the array of all values in the column.
124  // The length of the buffer pointed to by dataPtr must match
125  // the actual length. This is checked by ScalarColumn.
126  virtual void getScalarColumn (void* dataPtr) const;
127 
128  // Get the array of some values in the column (on behalf of RefColumn).
129  // The length of the buffer pointed to by dataPtr must match
130  // the actual length. This is checked by ScalarColumn.
131  virtual void getScalarColumnCells (const RefRows& rownrs,
132  void* dataPtr) const;
133 
134  // Put the value in a particular cell.
135  // The length of the buffer pointed to by dataPtr must match
136  // the actual length. This is checked by ScalarColumn.
137  virtual void put (uInt rownr, const void* dataPtr);
138 
139  // Put the array of all values in the column.
140  // The length of the buffer pointed to by dataPtr must match
141  // the actual length. This is checked by ScalarColumn.
142  virtual void putScalarColumn (const void* dataPtr);
143 
144  // Put the array of some values in the column (on behalf on RefColumn).
145  // The length of the buffer pointed to by dataPtr must match
146  // the actual length. This is checked by ScalarColumn.
147  virtual void putScalarColumnCells (const RefRows& rownrs,
148  const void* dataPtr);
149 
150  // Add this column and its data to the Sort object.
151  // Sorting on records is not supported, so an exception is thrown.
152  // <group>
153  virtual void makeSortKey (Sort&, CountedPtr<BaseCompare>& cmpObj,
154  Int order,
155  const void*& dataSave);
156  // Do it only for the given row numbers.
157  virtual void makeRefSortKey (Sort&, CountedPtr<BaseCompare>& cmpObj,
158  Int order,
159  const Vector<uInt>& rownrs,
160  const void*& dataSave);
161  // </group>
162 
163  // Free storage on the heap allocated by makeSortkey().
164  // The pointer will be set to zero.
165  virtual void freeSortKey (const void*& dataSave);
166 
167  // Allocate value buffers for the table iterator.
168  // Iteration based on records is not supported, so an exception is thrown.
169  virtual void allocIterBuf (void*& lastVal, void*& curVal,
170  CountedPtr<BaseCompare>& cmpObj);
171 
172  // Free the value buffers allocated by allocIterBuf.
173  virtual void freeIterBuf (void*& lastVal, void*& curVal);
174 
175  // Create a data manager column object for this column.
176  virtual void createDataManagerColumn();
177 
178 
179 private:
180  // Pointer to column description.
182 
183 
184  // Copy constructor cannot be used.
186 
187  // Assignment cannot be used.
189 
190  // Write the column data.
191  // The control information is written into the given AipsIO object,
192  // while the data is written/flushed by the data manager.
193  virtual void putFileDerived (AipsIO&);
194 
195  // Read the column data back.
196  // The control information is read from the given AipsIO object.
197  // This is used to bind the column to the appropriate data manager.
198  // Thereafter the data manager gets opened.
199  virtual void getFileDerived (AipsIO&, const ColumnSet&);
200 
201  // Handle getting and putting a record.
202  // It is stored as a Vector of uChar.
203  // <group>
204  void getRecord (uInt rownr, TableRecord& rec) const;
205  void putRecord (uInt rownr, const TableRecord& rec);
206  // </group>
207 };
208 
209 
210 
211 } //# NAMESPACE CASACORE - END
212 
213 #endif
int Int
Definition: aipstype.h:50
virtual Bool canAccessScalarColumnCells(Bool &reask) const
Ask if the data manager can handle some cells in a column.
std::vector< double > Vector
Definition: ds9context.h:24
virtual void put(uInt rownr, const void *dataPtr)
Put the value in a particular cell.
AipsIO is the object persistency mechanism of Casacore.
Definition: AipsIO.h:168
ScalarRecordColumnData & operator=(const ScalarRecordColumnData &)
Assignment cannot be used.
virtual Bool isDefined(uInt rownr) const
Test if the given cell contains a defined value.
Access to a table column containing scalar records.
virtual void getScalarColumn(void *dataPtr) const
Get the array of all values in the column.
Class to manage a set of table columns.
Definition: ColumnSet.h:93
virtual void makeSortKey(Sort &, CountedPtr< BaseCompare > &cmpObj, Int order, const void *&dataSave)
Add this column and its data to the Sort object.
Sort on one or more keys, ascending and/or descending.
Definition: Sort.h:248
virtual void makeRefSortKey(Sort &, CountedPtr< BaseCompare > &cmpObj, Int order, const Vector< uInt > &rownrs, const void *&dataSave)
Do it only for the given row numbers.
Referenced counted pointer for constant data.
Definition: VisModelData.h:42
void getRecord(uInt rownr, TableRecord &rec) const
Handle getting and putting a record.
Class holding the row numbers in a RefTable.
Definition: RefRows.h:85
virtual void createDataManagerColumn()
Create a data manager column object for this column.
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
virtual void putScalarColumn(const void *dataPtr)
Put the array of all values in the column.
virtual void allocIterBuf(void *&lastVal, void *&curVal, CountedPtr< BaseCompare > &cmpObj)
Allocate value buffers for the table iterator.
Class to define columns of scalar records in tables.
const ScalarRecordColumnDesc * scaDescPtr_p
Pointer to column description.
A hierarchical collection of named fields of various types.
Definition: TableRecord.h:182
virtual void freeIterBuf(void *&lastVal, void *&curVal)
Free the value buffers allocated by allocIterBuf.
Base class for a column in a plain table.
Definition: PlainColumn.h:84
ScalarRecordColumnData(const ScalarRecordColumnDesc *, ColumnSet *)
Construct a scalar column object from the given description in the given column set.
virtual void getScalarColumnCells(const RefRows &rownrs, void *dataPtr) const
Get the array of some values in the column (on behalf of RefColumn).
virtual void putScalarColumnCells(const RefRows &rownrs, const void *dataPtr)
Put the array of some values in the column (on behalf on RefColumn).
virtual void putFileDerived(AipsIO &)
Write the column data.
virtual void getFileDerived(AipsIO &, const ColumnSet &)
Read the column data back.
void putRecord(uInt rownr, const TableRecord &rec)
virtual Bool canAccessScalarColumn(Bool &reask) const
Ask if the data manager can handle a column.
virtual void initialize(uInt startRownr, uInt endRownr)
Initialize the rows from startRownr till endRownr (inclusive) with the default value defined in the c...
virtual void freeSortKey(const void *&dataSave)
Free storage on the heap allocated by makeSortkey().
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