casacore
Loading...
Searching...
No Matches
MSMColumn.h
Go to the documentation of this file.
1//# MSMColumn.h: A column in the MemoryStMan
2//# Copyright (C) 2003
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: MSMColumn.h 20551 2009-03-25 00:11:33Z Malte.Marquarding $
27
28#ifndef TABLES_MSMCOLUMN_H
29#define TABLES_MSMCOLUMN_H
30
31
32//# Includes
33#include <casacore/casa/aips.h>
34#include <casacore/tables/DataMan/StManColumnBase.h>
35#include <casacore/casa/Containers/Block.h>
36#include <casacore/casa/BasicSL/Complex.h>
37#include <casacore/casa/Arrays/IPosition.h>
38#include <casacore/casa/BasicSL/String.h>
39
40namespace casacore { //# NAMESPACE CASACORE - BEGIN
41
42//# Forward declarations
43class MSMBase;
44
45
46// <summary>
47// Column in the Memory table storage manager class
48// </summary>
49
50// <use visibility=local>
51
52// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
53// </reviewed>
54
55// <prerequisite>
56//# Classes you should understand before using this one.
57// <li> <linkto class=StManColumn>StManColumn</linkto>
58// <li> <linkto class=MemoryStMan>MemoryStMan</linkto>
59// </prerequisite>
60
61// <etymology>
62// MSMColumn handles a column for the memory-based storage manager.
63// </etymology>
64
65// <synopsis>
66// MSMColumn is used by MemoryStMan to handle the access to
67// the data in a table column.
68// It is an storage manager based in memory. Thus the data is lost
69// when the table is closed.
70// On reopen it will be initialized to the default column value.
71// It fully supports addition and removal of rows.
72//
73// MSMColumn serves 2 purposes:
74// <ol>
75// <li> It handles a column containing scalar values.
76// <li> It serves as a base class for MSMDirColumn and MSMIndColumn
77// These classes handle arrays and use MSMColumn to hold a pointer
78// to the array in each row.
79// </ol>
80//
81// MSMColumn does not hold a column as a consecutive array,
82// because extending the column (i.e. adding rows) proved be too
83// expensive due to the repeated copying involved when creating a table
84// (this method was used by the first version of the table system).
85// Instead it has a number of data blocks (extensions) indexed to by a
86// super block. Accessing a row means finding the appropriate extension
87// via a binary search. Because there is only 1 extension when a table is
88// read back, the overhead in finding a row is small.
89// </synopsis>
90
91// <motivation>
92// MSMColumn handles the standard data types. The class
93// is not templated, but a switch statement is used instead.
94// Templates would cause too many instantiations.
95// </motivation>
96
97// <todo asof="$DATE:$">
98//# A List of bugs, limitations, extensions or planned refinements.
99// <li> StManAipsIO should use this class
100// </todo>
101
102
104{
105public:
106 // Create a column of the given type.
107 // It will maintain a pointer to its parent storage manager.
108 MSMColumn (MSMBase* smptr, int dataType, Bool byPtr);
109
110 // Frees up the storage.
111 virtual ~MSMColumn();
112
113 // Get a scalar value in the given row.
114 // The buffer pointed to by dataPtr has to have the correct length
115 // (which is guaranteed by the Scalar/ArrayColumn get function).
116 // <group>
117 virtual void getBool (rownr_t rownr, Bool* dataPtr);
118 virtual void getuChar (rownr_t rownr, uChar* dataPtr);
119 virtual void getShort (rownr_t rownr, Short* dataPtr);
120 virtual void getuShort (rownr_t rownr, uShort* dataPtr);
121 virtual void getInt (rownr_t rownr, Int* dataPtr);
122 virtual void getuInt (rownr_t rownr, uInt* dataPtr);
123 virtual void getInt64 (rownr_t rownr, Int64* dataPtr);
124 virtual void getfloat (rownr_t rownr, float* dataPtr);
125 virtual void getdouble (rownr_t rownr, double* dataPtr);
126 virtual void getComplex (rownr_t rownr, Complex* dataPtr);
127 virtual void getDComplex (rownr_t rownr, DComplex* dataPtr);
128 virtual void getString (rownr_t rownr, String* dataPtr);
129 // </group>
130
131 // Put a scalar value into the given row.
132 // The buffer pointed to by dataPtr has to have the correct length
133 // (which is guaranteed by the Scalar/ArrayColumn put function).
134 // <group>
135 virtual void putBool (rownr_t rownr, const Bool* dataPtr);
136 virtual void putuChar (rownr_t rownr, const uChar* dataPtr);
137 virtual void putShort (rownr_t rownr, const Short* dataPtr);
138 virtual void putuShort (rownr_t rownr, const uShort* dataPtr);
139 virtual void putInt (rownr_t rownr, const Int* dataPtr);
140 virtual void putuInt (rownr_t rownr, const uInt* dataPtr);
141 virtual void putInt64 (rownr_t rownr, const Int64* dataPtr);
142 virtual void putfloat (rownr_t rownr, const float* dataPtr);
143 virtual void putdouble (rownr_t rownr, const double* dataPtr);
144 virtual void putComplex (rownr_t rownr, const Complex* dataPtr);
145 virtual void putDComplex (rownr_t rownr, const DComplex* dataPtr);
146 virtual void putString (rownr_t rownr, const String* dataPtr);
147 // </group>
148
149 // Get all scalar values in the column.
150 // The vector given in <src>data</src> has to have the correct length
151 // (which is guaranteed by the ScalarColumn getColumn function).
152 virtual void getScalarColumnV (ArrayBase& data);
153
154 // Put all scalar values in the column.
155 // The vector given in <src>data</src> has to have the correct length
156 // (which is guaranteed by the ScalarColumn putColumn function).
157 virtual void putScalarColumnV (const ArrayBase& data);
158
159 // Add (newNrrow-oldNrrow) rows to the column.
160 virtual void addRow (rownr_t newNrrow, rownr_t oldNrrow);
161
162 // Resize the data blocks.
163 // This adds an extension when needed.
164 void resize (rownr_t nrval);
165
166 // Remove the given row.
167 // If no rows remain in the extension, the extension is also removed.
168 virtual void remove (rownr_t rownr);
169
170 // Create the number of rows in a new table.
171 // This is used when a table gets created or opened.
172 virtual void doCreate (rownr_t nrrow);
173
174 // Make it possible to write the column data.
175 // It is only used by derived classes.
176 virtual void putFile (rownr_t nrval, AipsIO&);
177
178 // Make it possible to read the column data.
179 // It is only used by derived classes.
180 virtual void getFile (rownr_t nrval, AipsIO&);
181
182 // Reopen the storage manager files for read/write.
183 virtual void reopenRW();
184
185 // Check if the class invariants still hold.
186 virtual Bool ok() const;
187
188protected:
190 // The data is indirectly accessed via a pointer (for the derived classes).
192 // The number of allocated rows in the column.
194 // The nr of extensions in use.
196 // The assembly of all extensions (actually Block<T*>).
198 // The cumulative nr of rows in all extensions.
200
201 // Find the extension in which the row number is.
202 // If the flag is true, it also sets the columnCache object.
203 uInt findExt (rownr_t rownr, Bool setCache);
204
205 // Allocate an extension with the data type of the column.
206 void* allocData (rownr_t nrval, Bool byPtr);
207
208 // Delete all extensions.
209 // Possible underlying data (as used by StManArrayColumnMemory)
210 // will not be deleted and should have been deleted beforehand.
211 void deleteAll();
212
213 // Delete an extension.
214 void deleteData (void* datap, Bool byPtr);
215
216 // Remove an entry (i.e. a row) from an extension at the given index.
217 // It will do this by shifting the rest (nrvalAfter elements)
218 // one position to the left.
219 void removeData (void* datap, rownr_t inx, rownr_t nrvalAfter);
220
221 // Initialize the data (after an open).
222 virtual void initData (void* datap, rownr_t nrval);
223
224 // Get the pointer for the given row.
225 // This is for the derived classes like StManArrayColumnMemory.
226 void* getArrayPtr (rownr_t rownr);
227
228 // Put the pointer for the given row.
229 // This is for the derived classes like StManArrayColumnMemory.
230 void putArrayPtr (rownr_t rownr, void* dataPtr);
231
232private:
233 // Forbid copy constructor.
235
236 // Forbid assignment.
238};
239
240
241
242} //# NAMESPACE CASACORE - END
243
244#endif
Non-templated base class for templated Array class.
Definition ArrayBase.h:73
simple 1-D array
Definition Block.h:200
virtual void getdouble(rownr_t rownr, double *dataPtr)
virtual void getComplex(rownr_t rownr, Complex *dataPtr)
virtual void putComplex(rownr_t rownr, const Complex *dataPtr)
virtual void remove(rownr_t rownr)
Remove the given row.
virtual void putuShort(rownr_t rownr, const uShort *dataPtr)
void deleteAll()
Delete all extensions.
virtual void getuShort(rownr_t rownr, uShort *dataPtr)
Bool byPtr_p
The data is indirectly accessed via a pointer (for the derived classes).
Definition MSMColumn.h:191
virtual ~MSMColumn()
Frees up the storage.
void resize(rownr_t nrval)
Resize the data blocks.
virtual void putDComplex(rownr_t rownr, const DComplex *dataPtr)
virtual void addRow(rownr_t newNrrow, rownr_t oldNrrow)
Add (newNrrow-oldNrrow) rows to the column.
uInt findExt(rownr_t rownr, Bool setCache)
Find the extension in which the row number is.
Block< rownr_t > ncum_p
The cumulative nr of rows in all extensions.
Definition MSMColumn.h:199
MSMColumn(MSMBase *smptr, int dataType, Bool byPtr)
Create a column of the given type.
virtual void putString(rownr_t rownr, const String *dataPtr)
void putArrayPtr(rownr_t rownr, void *dataPtr)
Put the pointer for the given row.
virtual void initData(void *datap, rownr_t nrval)
Initialize the data (after an open).
virtual void putBool(rownr_t rownr, const Bool *dataPtr)
Put a scalar value into the given row.
virtual void getInt64(rownr_t rownr, Int64 *dataPtr)
virtual void getDComplex(rownr_t rownr, DComplex *dataPtr)
Block< void * > data_p
The assembly of all extensions (actually Block<T*>).
Definition MSMColumn.h:197
virtual void putdouble(rownr_t rownr, const double *dataPtr)
virtual void getInt(rownr_t rownr, Int *dataPtr)
virtual void getShort(rownr_t rownr, Short *dataPtr)
virtual void putFile(rownr_t nrval, AipsIO &)
Make it possible to write the column data.
virtual void getuInt(rownr_t rownr, uInt *dataPtr)
virtual void putfloat(rownr_t rownr, const float *dataPtr)
void * getArrayPtr(rownr_t rownr)
Get the pointer for the given row.
virtual Bool ok() const
Check if the class invariants still hold.
virtual void putuInt(rownr_t rownr, const uInt *dataPtr)
virtual void getuChar(rownr_t rownr, uChar *dataPtr)
virtual void putuChar(rownr_t rownr, const uChar *dataPtr)
void * allocData(rownr_t nrval, Bool byPtr)
Allocate an extension with the data type of the column.
virtual void getScalarColumnV(ArrayBase &data)
Get all scalar values in the column.
virtual void putInt64(rownr_t rownr, const Int64 *dataPtr)
MSMColumn & operator=(const MSMColumn &)
Forbid assignment.
virtual void getBool(rownr_t rownr, Bool *dataPtr)
Get a scalar value in the given row.
virtual void putShort(rownr_t rownr, const Short *dataPtr)
virtual void putInt(rownr_t rownr, const Int *dataPtr)
virtual void getfloat(rownr_t rownr, float *dataPtr)
virtual void doCreate(rownr_t nrrow)
Create the number of rows in a new table.
void removeData(void *datap, rownr_t inx, rownr_t nrvalAfter)
Remove an entry (i.e.
virtual void getFile(rownr_t nrval, AipsIO &)
Make it possible to read the column data.
virtual void reopenRW()
Reopen the storage manager files for read/write.
virtual void putScalarColumnV(const ArrayBase &data)
Put all scalar values in the column.
MSMBase * stmanPtr_p
Definition MSMColumn.h:189
uInt nrext_p
The nr of extensions in use.
Definition MSMColumn.h:195
void deleteData(void *datap, Bool byPtr)
Delete an extension.
rownr_t nralloc_p
The number of allocated rows in the column.
Definition MSMColumn.h:193
virtual void getString(rownr_t rownr, String *dataPtr)
MSMColumn(const MSMColumn &)
Forbid copy constructor.
virtual int dataType() const
Return the data type of the column.
String: the storage and methods of handling collections of characters.
Definition String.h:225
this file contains all the compiler specific defines
Definition mainpage.dox:28
unsigned char uChar
Definition aipstype.h:47
short Short
Definition aipstype.h:48
unsigned int uInt
Definition aipstype.h:51
unsigned short uShort
Definition aipstype.h:49
long long Int64
Define the extra non-standard types used by Casacore (like proposed uSize, Size)
Definition aipsxtype.h:38
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