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