casacore
Loading...
Searching...
No Matches
TSMIdColumn.h
Go to the documentation of this file.
1// # TSMIdColumn.h: An id column in Tiled Storage Manager
2// # Copyright (C) 1995,1996,1997,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_TSMIDCOLUMN_H
27#define TABLES_TSMIDCOLUMN_H
28
29// # Includes
30#include <casacore/casa/aips.h>
31#include <casacore/tables/DataMan/DataManError.h>
32#include <casacore/tables/DataMan/TSMColumn.h>
33#include <casacore/tables/DataMan/TiledStMan.h>
34#include <casacore/tables/DataMan/TSMCube.h>
35#include <casacore/casa/Arrays/IPosition.h>
36#include <casacore/casa/BasicSL/String.h>
37
38namespace casacore { // # NAMESPACE CASACORE - BEGIN
39
40// # Forward Declarations
41
42// <summary>
43// An id column in Tiled Storage Manager.
44// </summary>
45
46// <use visibility=local>
47
48// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
49// </reviewed>
50
51// <prerequisite>
52// # Classes you should understand before using this one.
53// <li> <linkto class=TSMColumn>TSMColumn</linkto>
54// <li> <linkto class=TSMCube>TSMCube</linkto>
55// <li> <linkto class=Record>Record</linkto>
56// </prerequisite>
57
58// <etymology>
59// TSMIdColumn handles an id column for a Tiled
60// Storage Manager.
61// </etymology>
62
63// <synopsis>
64// TSMIdColumn is used by
65// <linkto class=TiledStMan>TiledStMan</linkto>
66// to handle the access to
67// a table column containing an id value of a tiled hypercube.
68// Explicitly putting an id value is not possible. The only way to
69// define the value is by specifying it when adding a hypercube
70// in <linkto class=TiledDataStMan>TiledDataStMan</linkto>.
71// <p>
72// The id values are held in a TSMCube object. The row number
73// determines which TSMCube object has to be accessed.
74// <p>
75// The creation of a TSMIdColumn object is done by a TSMColumn object.
76// This process is described in more detail in the class
77// <linkto class=TSMColumn>TSMColumn</linkto>.
78// </synopsis>
79
80// <motivation>
81// Handling coordinate columns in the Tiled Storage Manager is
82// different from other columns.
83// </motivation>
84
85// # <todo asof="$DATE:$">
86// # A List of bugs, limitations, extensions or planned refinements.
87// # </todo>
88
89class TSMIdColumn : public TSMColumn {
90 public:
91 // Create an id column from the given column.
92 TSMIdColumn(const TSMColumn& column) : TSMColumn(column) {}
93
94 // Frees up the storage.
95 virtual ~TSMIdColumn() = default;
96
97 // Forbid copy constructor.
98 TSMIdColumn(const TSMIdColumn&) = delete;
99
100 // Forbid assignment.
102
103 // Get a scalar value in the given row.
104 // The buffer pointed to by dataPtr has to have the correct length
105 // (which is guaranteed by the ScalarColumn get function).
106 // <group>
107 void getBool(rownr_t rownr, Bool* dataPtr) override { GetGeneric(rownr, dataPtr); }
108 void getInt(rownr_t rownr, Int* dataPtr) override { GetGeneric(rownr, dataPtr); }
109 void getuInt(rownr_t rownr, uInt* dataPtr) override { GetGeneric(rownr, dataPtr); }
110 void getInt64(rownr_t rownr, Int64* dataPtr) override { GetGeneric(rownr, dataPtr); }
111 void getfloat(rownr_t rownr, float* dataPtr) override { GetGeneric(rownr, dataPtr); }
112 void getdouble(rownr_t rownr, double* dataPtr) override { GetGeneric(rownr, dataPtr); }
113 void getComplex(rownr_t rownr, Complex* dataPtr) override { GetGeneric(rownr, dataPtr); }
114 void getDComplex(rownr_t rownr, DComplex* dataPtr) override { GetGeneric(rownr, dataPtr); }
115 void getString(rownr_t rownr, String* dataPtr) override { GetGeneric(rownr, dataPtr); }
116 // </group>
117
118 // Put a scalar value in the given row.
119 // The buffer pointed to by dataPtr has to have the correct length
120 // (which is guaranteed by the ScalarColumn get function).
121 // The value to be put must match the value which has already
122 // been inserted by the TiledStMan::addHypercube function.
123 // The put function is only there to be fully orthogonal.
124 // <group>
125 void putBool(rownr_t rownr, const Bool* dataPtr) override { PutGeneric(rownr, dataPtr); }
126 void putInt(rownr_t rownr, const Int* dataPtr) override { PutGeneric(rownr, dataPtr); }
127 void putuInt(rownr_t rownr, const uInt* dataPtr) override { PutGeneric(rownr, dataPtr); }
128 void putInt64(rownr_t rownr, const Int64* dataPtr) override { PutGeneric(rownr, dataPtr); }
129 void putfloat(rownr_t rownr, const float* dataPtr) override { PutGeneric(rownr, dataPtr); }
130 void putdouble(rownr_t rownr, const double* dataPtr) override { PutGeneric(rownr, dataPtr); }
131 void putComplex(rownr_t rownr, const Complex* dataPtr) override { PutGeneric(rownr, dataPtr); }
132 void putDComplex(rownr_t rownr, const DComplex* dataPtr) override { PutGeneric(rownr, dataPtr); }
133 void putString(rownr_t rownr, const String* dataPtr) override { PutGeneric(rownr, dataPtr); }
134 // </group>
135
136 private:
137 template <typename T>
138 void GetGeneric(rownr_t rownr, T* dataPtr) {
139 TSMCube* hypercube = stmanPtr_p->getHypercube(rownr);
140 hypercube->valueRecord().get(columnName(), *dataPtr);
141 }
142
143 template <typename T>
144 void PutGeneric(rownr_t rownr, const T* dataPtr) {
145 T value;
146 GetGeneric<T>(rownr, &value);
147 if (value != *dataPtr) {
148 throw TSMError(
149 "TSMIdColumn::put: new value mismatches existing"
150 " in id column " +
151 columnName());
152 }
153 }
154};
155
156} // namespace casacore
157
158#endif
String: the storage and methods of handling collections of characters.
Definition String.h:355
TSMColumn(TiledStMan *stman, int dataType, const String &columnName)
Create a column of the given type.
const String & columnName() const
Get the name of the column.
Definition TSMColumn.h:150
TiledStMan * stmanPtr_p
The storage manager.
Definition TSMColumn.h:136
const Record & valueRecord() const
Get the record containing the id and coordinate values.
Definition TSMCube.h:394
Table DataManager error; error in TiledStMan.
void getInt64(rownr_t rownr, Int64 *dataPtr) override
TSMIdColumn & operator=(const TSMIdColumn &)=delete
Forbid assignment.
void getComplex(rownr_t rownr, Complex *dataPtr) override
void putInt64(rownr_t rownr, const Int64 *dataPtr) override
void getInt(rownr_t rownr, Int *dataPtr) override
void getdouble(rownr_t rownr, double *dataPtr) override
void PutGeneric(rownr_t rownr, const T *dataPtr)
void getDComplex(rownr_t rownr, DComplex *dataPtr) override
void GetGeneric(rownr_t rownr, T *dataPtr)
void getBool(rownr_t rownr, Bool *dataPtr) override
Get a scalar value in the given row.
void putInt(rownr_t rownr, const Int *dataPtr) override
void putComplex(rownr_t rownr, const Complex *dataPtr) override
void getuInt(rownr_t rownr, uInt *dataPtr) override
void putdouble(rownr_t rownr, const double *dataPtr) override
void putfloat(rownr_t rownr, const float *dataPtr) override
virtual ~TSMIdColumn()=default
Frees up the storage.
TSMIdColumn(const TSMIdColumn &)=delete
Forbid copy constructor.
void putDComplex(rownr_t rownr, const DComplex *dataPtr) override
void getfloat(rownr_t rownr, float *dataPtr) override
void getString(rownr_t rownr, String *dataPtr) override
void putBool(rownr_t rownr, const Bool *dataPtr) override
Put a scalar value in the given row.
void putuInt(rownr_t rownr, const uInt *dataPtr) override
void putString(rownr_t rownr, const String *dataPtr) override
TSMIdColumn(const TSMColumn &column)
Create an id column from the given column.
Definition TSMIdColumn.h:92
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
unsigned int uInt
Definition aipstype.h:49
long long Int64
Define the extra non-standard types used by Casacore (like proposed uSize, Size).
Definition aipsxtype.h:36
int Int
Definition aipstype.h:48
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
NewDelAllocator< T > NewDelAllocator< T >::value
Definition Allocator.h:360
uInt64 rownr_t
Define the type of a row number in a table.
Definition aipsxtype.h:44