casacore
Loading...
Searching...
No Matches
MSMIndColumn.h
Go to the documentation of this file.
1// # MSMIndColumn.h: Memory storage manager for variable shaped table arrays
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: 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_MSMINDCOLUMN_H
27#define TABLES_MSMINDCOLUMN_H
28
29// # Includes
30#include <casacore/casa/aips.h>
31#include <casacore/tables/DataMan/MSMColumn.h>
32#include <casacore/tables/DataMan/MSMBase.h>
33#include <casacore/casa/Arrays/IPosition.h>
34
35namespace casacore { // # NAMESPACE CASACORE - BEGIN
36
37// <summary>
38// Mmeory storage manager for variable shaped table arrays
39// </summary>
40
41// <use visibility=local>
42
43// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
44// </reviewed>
45
46// <prerequisite>
47// # Classes you should understand before using this one.
48// <li> MSMBase
49// <li> MSMColumn
50// </prerequisite>
51
52// <synopsis>
53// StManColumnArrayAipsIO handles indirect arrays in a table column.
54//
55// An array (or section of an array) is only read when needed.
56// It, however, caches the array shape using the helper class
57// StIndArray. Pointers to these objects
58// are maintained using the standard StManColumnAipsIO facilities.
59// When the column gets written, the offsets in the StManArrayFile file
60// get written. Those will be read back when the column is read in.
61//
62// When a row gets deleted or when the array gets bigger, the file space
63// is lost. This storage manager is a simple one and no attempts
64// are done to make it smart.
65// </synopsis>
66
67// # <todo asof="$DATE:$">
68// # A List of bugs, limitations, extensions or planned refinements.
69// # </todo>
70
71class MSMIndColumn : public MSMColumn {
72 public:
73 // Create a column of the given type.
75
76 // Frees up the storage.
78
79 // Forbid copy constructor.
80 MSMIndColumn(const MSMIndColumn&) = delete;
81
82 // Forbid assignment.
84
85 // Set the (fixed) shape of the arrays in the entire column.
87
88 // Get the column shape.
89 const IPosition& columnShape() const { return fixedShape_p; }
90
91 // Set the shape of the array in the given row and allocate the array
92 // in the file.
93 void setShape(rownr_t rownr, const IPosition& shape);
94
95 // Is the shape defined (i.e. is there an array) in this row?
97
98 // Get the dimensionality of the item in the given row.
99 // 0 is returned if there is no array.
101
102 // Get the shape of the array in the given row.
103 // An zero-length IPosition is returned if there is no array.
105
106 // This storage manager can handle changing array shapes.
108
109 // Get an array value in the given row.
110 // The buffer given by <src>arr</src> has to have the correct length
111 // (which is guaranteed by the ArrayColumn get function).
112 void getArrayV(rownr_t rownr, ArrayBase& arr);
113
114 // Put an array value into the given row.
115 // The buffer given by <src>arr</src> has to have the correct length
116 // (which is guaranteed by the ArrayColumn put function).
117 void putArrayV(rownr_t rownr, const ArrayBase& arr);
118
119 // Get a section of the array in the given row.
120 // The buffer given by <src>arr</src> has to have the correct length
121 // (which is guaranteed by the ArrayColumn getSlice function).
122 void getSliceV(rownr_t rownr, const Slicer&, ArrayBase& arr);
123
124 // Put into a section of the array in the given row.
125 // The buffer given by <src>arr</src> has to have the correct length
126 // (which is guaranteed by the ArrayColumn putSlice function).
127 void putSliceV(rownr_t rownr, const Slicer&, const ArrayBase& arr);
128
129 // Remove the value in the given row.
130 // This will result in lost file space.
131 void remove(rownr_t rownr);
132
133 private:
134 class Data {
135 public:
136 Data(const IPosition& shape, int dtype, int elemSize);
138 Data(const Data&) = delete;
139 Data& operator=(const Data&) = delete;
140 const IPosition& shape() const { return shape_p; }
141 void* data() { return data_p; }
142
143 private:
145 void* data_p;
147 };
148 // The shape of all arrays in case it is fixed.
150 // The size at the start of the data (for the IPosition).
152
153 // Delete the array in the given row.
154 void deleteArray(rownr_t rownr);
155
156 // Read the shape at the given row.
157 // It throws an exception if undefined.
159
160 // Get a pointer to the data array.
161 void* getDataPtr(rownr_t rownr) { return (char*)(getShape(rownr)) + startSize_p; }
162};
163
164} // namespace casacore
165
166#endif
Non-templated base class for templated Array class.
Definition ArrayBase.h:69
MSMColumn(MSMBase *smptr, int dataType, Bool byPtr)
Create a column of the given type.
Data(const IPosition &shape, int dtype, int elemSize)
Data(const Data &)=delete
Data & operator=(const Data &)=delete
const IPosition & shape() const
void remove(rownr_t rownr)
Remove the value in the given row.
Bool canChangeShape() const
This storage manager can handle changing array shapes.
Bool isShapeDefined(rownr_t rownr)
Is the shape defined (i.e.
void putSliceV(rownr_t rownr, const Slicer &, const ArrayBase &arr)
Put into a section of the array in the given row.
void getArrayV(rownr_t rownr, ArrayBase &arr)
Get an array value in the given row.
void setShapeColumn(const IPosition &shape)
Set the (fixed) shape of the arrays in the entire column.
~MSMIndColumn()
Frees up the storage.
MSMIndColumn & operator=(const MSMIndColumn &)=delete
Forbid assignment.
Data * getShape(rownr_t rownr)
Read the shape at the given row.
void getSliceV(rownr_t rownr, const Slicer &, ArrayBase &arr)
Get a section of the array in the given row.
void setShape(rownr_t rownr, const IPosition &shape)
Set the shape of the array in the given row and allocate the array in the file.
void putArrayV(rownr_t rownr, const ArrayBase &arr)
Put an array value into the given row.
const IPosition & columnShape() const
Get the column shape.
void deleteArray(rownr_t rownr)
Delete the array in the given row.
IPosition fixedShape_p
The shape of all arrays in case it is fixed.
IPosition shape(rownr_t rownr)
Get the shape of the array in the given row.
MSMIndColumn(MSMBase *, int dataType)
Create a column of the given type.
uInt startSize_p
The size at the start of the data (for the IPosition).
void * getDataPtr(rownr_t rownr)
Get a pointer to the data array.
uInt ndim(rownr_t rownr)
Get the dimensionality of the item in the given row.
MSMIndColumn(const MSMIndColumn &)=delete
Forbid copy constructor.
Int elemSize() const
Return the size of an element of the column's data type.
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
unsigned int uInt
Definition aipstype.h:49
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
DataType dataType(const RecordFieldId &) const