casacore
Loading...
Searching...
No Matches
MSMDirColumn.h
Go to the documentation of this file.
1// # MSMDirColumn.h: Memory storage manager for fixed shape 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_MSMDIRCOLUMN_H
27#define TABLES_MSMDIRCOLUMN_H
28
29// # Includes
30#include <casacore/casa/aips.h>
31#include <casacore/tables/DataMan/MSMColumn.h>
32#include <casacore/casa/Arrays/Array.h>
33
34namespace casacore { // # NAMESPACE CASACORE - BEGIN
35
36// <summary>
37// Memory storage manager for table arrays
38// </summary>
39
40// <use visibility=local>
41
42// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
43// </reviewed>
44
45// <prerequisite>
46// # Classes you should understand before using this one.
47// <li> MSMBase
48// <li> MSMColumn
49// </prerequisite>
50
51// <synopsis>
52// MSMDirColumn handles arrays in a table column.
53// It only keeps them in memory, so they are not persistent.
54// </synopsis>
55
56// # <todo asof="$DATE:$">
57// # A List of bugs, limitations, extensions or planned refinements.
58// # </todo>
59
60class MSMDirColumn : public MSMColumn {
61 public:
62 // Create a column of the given type.
64
65 // Frees up the storage.
66 virtual ~MSMDirColumn();
67
68 // Forbid copy constructor.
69 MSMDirColumn(const MSMDirColumn&) = delete;
70
71 // Forbid assignment.
73
74 // Set the (fixed) shape of the arrays in the entire column.
75 virtual void setShapeColumn(const IPosition& shape);
76
77 // Add (newNrrow-oldNrrow) rows to the column.
78 // Allocate the data arrays in these rows if the shape is fixed.
79 virtual void addRow(rownr_t newNrrow, rownr_t oldNrrow);
80
81 // Get the dimensionality of the item in the given row.
82 // 0 is returned if there is no array.
83 virtual uInt ndim(rownr_t rownr);
84
85 // Get the shape of the array in the given row.
86 // An zero-length IPosition is returned if there is no array.
87 virtual IPosition shape(rownr_t rownr);
88
89 // Get an array value in the given row.
90 // The buffer given by <src>arr</src> has to have the correct length
91 // (which is guaranteed by the ArrayColumn get function).
92 virtual void getArrayV(rownr_t rownr, ArrayBase& arr);
93
94 // Put an array value into the given row.
95 // The buffer given by <src>arr</src> has to have the correct length
96 // (which is guaranteed by the ArrayColumn put function).
97 virtual void putArrayV(rownr_t rownr, const ArrayBase& arr);
98
99 // Get a section of the array in the given row.
100 // The buffer given by <src>arr</src> has to have the correct length
101 // (which is guaranteed by the ArrayColumn getSlice function).
102 virtual void getSliceV(rownr_t rownr, const Slicer&, ArrayBase& arr);
103
104 // Put into a section of the array in the given row.
105 // The buffer given by <src>arr</src> has to have the correct length
106 // (which is guaranteed by the ArrayColumn putSlice function).
107 virtual void putSliceV(rownr_t rownr, const Slicer&, const ArrayBase& arr);
108
109 // Remove the value in the given row.
110 void remove(rownr_t rownr);
111
112 // Let the column create its arrays.
113 void doCreate(rownr_t nrrow);
114
115 private:
116 template <typename T>
117 inline void doGetSlice(rownr_t rownr, const Slicer& slicer, Array<T>& data) {
118 Array<T> arr(shape_p, static_cast<T*>(getArrayPtr(rownr)), SHARE);
119 data = arr(slicer);
120 }
121
122 template <typename T>
123 inline void doPutSlice(rownr_t rownr, const Slicer& slicer, const Array<T>& data) {
124 Array<T> arr(shape_p, static_cast<T*>(getArrayPtr(rownr)), SHARE);
125 arr(slicer) = data;
126 }
127
128 // Delete the array in the given row.
129 void deleteArray(rownr_t rownr);
130
131 // The shape of the array.
133 // The nr of elements in the array.
135};
136
137} // namespace casacore
138
139#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.
void * getArrayPtr(rownr_t rownr)
Get the pointer for the given row.
virtual void getSliceV(rownr_t rownr, const Slicer &, ArrayBase &arr)
Get a section of the array in the given row.
virtual void getArrayV(rownr_t rownr, ArrayBase &arr)
Get an array value in the given row.
virtual void setShapeColumn(const IPosition &shape)
Set the (fixed) shape of the arrays in the entire column.
void doPutSlice(rownr_t rownr, const Slicer &slicer, const Array< T > &data)
void doGetSlice(rownr_t rownr, const Slicer &slicer, Array< T > &data)
MSMDirColumn & operator=(const MSMDirColumn &)=delete
Forbid assignment.
void doCreate(rownr_t nrrow)
Let the column create its arrays.
IPosition shape_p
The shape of the array.
virtual IPosition shape(rownr_t rownr)
Get the shape of the array in the given row.
void remove(rownr_t rownr)
Remove the value in the given row.
virtual void addRow(rownr_t newNrrow, rownr_t oldNrrow)
Add (newNrrow-oldNrrow) rows to the column.
virtual ~MSMDirColumn()
Frees up the storage.
void deleteArray(rownr_t rownr)
Delete the array in the given row.
MSMDirColumn(MSMBase *smptr, int dataType)
Create a column of the given type.
virtual uInt ndim(rownr_t rownr)
Get the dimensionality of the item in the given row.
virtual void putArrayV(rownr_t rownr, const ArrayBase &arr)
Put an array value into the given row.
MSMDirColumn(const MSMDirColumn &)=delete
Forbid copy constructor.
rownr_t nrelem_p
The nr of elements in the array.
virtual void putSliceV(rownr_t rownr, const Slicer &, const ArrayBase &arr)
Put into a section of the array in the given row.
@ SHARE
Share means that the Array will just use the pointer (no copy), however the Array will NOT delete it ...
Definition ArrayBase.h:59
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
unsigned int uInt
Definition aipstype.h:49
uInt64 rownr_t
Define the type of a row number in a table.
Definition aipsxtype.h:44
DataType dataType(const RecordFieldId &) const