casacore
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>
34 #include <casacore/casa/Arrays/ArrayFwd.h>
35 #include <casacore/tables/Tables/PlainColumn.h>
36 
37 namespace casacore { //# NAMESPACE CASACORE - BEGIN
38 
39 //# Forward Declarations
40 class ColumnSet;
41 class ScalarRecordColumnDesc;
42 class AipsIO;
43 
44 // <summary>
45 // Access to a table column containing scalar records.
46 // </summary>
47 
48 // <use visibility=local>
49 
50 // <reviewed reviewer="Wim Brouw" date="1998/12/09" tests="tRecordColumn.cc">
51 // </reviewed>
52 
53 // <prerequisite>
54 //# Classes you should understand before using this one.
55 // <li> <linkto class=PlainColumn>PlainColumn</linkto>
56 // <li> <linkto class=ScalarRecordColumnDesc>ScalarRecordColumnDesc</linkto>
57 // <li> <linkto class=Table>Table</linkto>
58 // </prerequisite>
59 
60 // <etymology>
61 // ScalarRecordColumnData represents a table column containing scalars.
62 // </etymology>
63 
64 // <synopsis>
65 // The class ScalarRecordColumnData is derived from PlainColumn.
66 // It implements the virtual functions accessing a table column
67 // containing scalars holding records.
68 // <br>
69 // It is possible to access an scalar in an individual cell (i.e. table row)
70 // or in the entire column.
71 // <p>
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 // If used directly by other Table classes, it should be done with care.
85 // It assumes that the arrays in the various get and put functions have
86 // the correct length. ScalarColumn does that check.
87 // </synopsis>
88 
89 // <todo asof="$DATE:$">
90 //# A List of bugs, limitations, extensions or planned refinements.
91 // <li> Introduce a class ArrayRecordColumnData to support arrays of records.
92 // </todo>
93 
94 
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 ScalarRecordColumnDesc::makeColumn.
103 
105 
106  // Initialize the rows from startRownr till endRownr (inclusive)
107  // with the default value defined in the column description.
108  virtual void initialize (rownr_t startRownr, rownr_t endRownr);
109 
110  // Test if the given cell contains a defined value.
111  virtual Bool isDefined (rownr_t rownr) const;
112 
113  // Get the value from a particular cell.
114  virtual void get (rownr_t rownr, void*) const;
115 
116  // Get the array of all values in the column.
117  // The length of the buffer pointed to by dataPtr must match
118  // the actual length. This is checked by ScalarColumn.
119  virtual void getScalarColumn (ArrayBase& dataPtr) const;
120 
121  // Get the array of some values in the column (on behalf of RefColumn).
122  // The length of the buffer pointed to by dataPtr must match
123  // the actual length. This is checked by ScalarColumn.
124  virtual void getScalarColumnCells (const RefRows& rownrs,
125  ArrayBase& dataPtr) const;
126 
127  // Put the value in a particular cell.
128  // The length of the buffer pointed to by dataPtr must match
129  // the actual length. This is checked by ScalarColumn.
130  virtual void put (rownr_t rownr, const void* dataPtr);
131 
132  // Put the array of all values in the column.
133  // The length of the buffer pointed to by dataPtr must match
134  // the actual length. This is checked by ScalarColumn.
135  virtual void putScalarColumn (const ArrayBase& dataPtr);
136 
137  // Put the array of some values in the column (on behalf on RefColumn).
138  // The length of the buffer pointed to by dataPtr must match
139  // the actual length. This is checked by ScalarColumn.
140  virtual void putScalarColumnCells (const RefRows& rownrs,
141  const ArrayBase& dataPtr);
142 
143  // Add this column and its data to the Sort object.
144  // Sorting on records is not supported, so an exception is thrown.
145  // <group>
146  virtual void makeSortKey (Sort&, CountedPtr<BaseCompare>& cmpObj,
147  Int order,
148  CountedPtr<ArrayBase>& dataSave);
149  // Do it only for the given row numbers.
150  virtual void makeRefSortKey (Sort&, CountedPtr<BaseCompare>& cmpObj,
151  Int order,
152  const Vector<rownr_t>& rownrs,
153  CountedPtr<ArrayBase>& dataSave);
154  // </group>
155 
156  // Allocate value buffers for the table iterator.
157  // Iteration based on records is not supported, so an exception is thrown.
158  virtual void allocIterBuf (void*& lastVal, void*& curVal,
159  CountedPtr<BaseCompare>& cmpObj);
160 
161  // Free the value buffers allocated by allocIterBuf.
162  virtual void freeIterBuf (void*& lastVal, void*& curVal);
163 
164  // Create a data manager column object for this column.
165  virtual void createDataManagerColumn();
166 
167 
168 private:
169  // Pointer to column description.
171 
172 
173  // Copy constructor cannot be used.
175 
176  // Assignment cannot be used.
178 
179  // Write the column data.
180  // The control information is written into the given AipsIO object,
181  // while the data is written/flushed by the data manager.
182  virtual void putFileDerived (AipsIO&);
183 
184  // Read the column data back.
185  // The control information is read from the given AipsIO object.
186  // This is used to bind the column to the appropriate data manager.
187  // Thereafter the data manager gets opened.
188  virtual void getFileDerived (AipsIO&, const ColumnSet&);
189 
190  // Handle getting and putting a record.
191  // It is stored as a Vector of uChar.
192  // <group>
193  void getRecord (rownr_t rownr, TableRecord& rec) const;
194  void putRecord (rownr_t rownr, const TableRecord& rec);
195  // </group>
196 };
197 
198 
199 
200 } //# NAMESPACE CASACORE - END
201 
202 #endif
Non-templated base class for templated Array class.
Definition: ArrayBase.h:73
Referenced counted pointer for constant data.
Definition: CountedPtr.h:81
virtual void getScalarColumnCells(const RefRows &rownrs, ArrayBase &dataPtr) const
Get the array of some values in the column (on behalf of RefColumn).
virtual void putFileDerived(AipsIO &)
Write the column data.
virtual void getFileDerived(AipsIO &, const ColumnSet &)
Read the column data back.
virtual void putScalarColumn(const ArrayBase &dataPtr)
Put the array of all values in the column.
virtual void makeRefSortKey(Sort &, CountedPtr< BaseCompare > &cmpObj, Int order, const Vector< rownr_t > &rownrs, CountedPtr< ArrayBase > &dataSave)
Do it only for the given row numbers.
virtual void allocIterBuf(void *&lastVal, void *&curVal, CountedPtr< BaseCompare > &cmpObj)
Allocate value buffers for the table iterator.
virtual void putScalarColumnCells(const RefRows &rownrs, const ArrayBase &dataPtr)
Put the array of some values in the column (on behalf on RefColumn).
virtual void makeSortKey(Sort &, CountedPtr< BaseCompare > &cmpObj, Int order, CountedPtr< ArrayBase > &dataSave)
Add this column and its data to the Sort object.
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.
const ScalarRecordColumnDesc * scaDescPtr_p
Pointer to column description.
virtual Bool isDefined(rownr_t rownr) const
Test if the given cell contains a defined value.
virtual void freeIterBuf(void *&lastVal, void *&curVal)
Free the value buffers allocated by allocIterBuf.
ScalarRecordColumnData(const ScalarRecordColumnData &)
Copy constructor cannot be used.
virtual void getScalarColumn(ArrayBase &dataPtr) const
Get the array of all values in the column.
void getRecord(rownr_t rownr, TableRecord &rec) const
Handle getting and putting a record.
virtual void get(rownr_t rownr, void *) const
Get the value from a particular cell.
ScalarRecordColumnData & operator=(const ScalarRecordColumnData &)
Assignment cannot be used.
void putRecord(rownr_t rownr, const TableRecord &rec)
virtual void createDataManagerColumn()
Create a data manager column object for this column.
ScalarRecordColumnData(const ScalarRecordColumnDesc *, ColumnSet *)
Construct a scalar column object from the given description in the given column set.
Sort on one or more keys, ascending and/or descending.
Definition: Sort.h:248
this file contains all the compiler specific defines
Definition: mainpage.dox:28
int Int
Definition: aipstype.h:50
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
uInt64 rownr_t
Define the type of a row number in a table.
Definition: aipsxtype.h:46