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