casacore
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: 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: MSMDirColumn.h 20551 2009-03-25 00:11:33Z Malte.Marquarding $
27 
28 #ifndef TABLES_MSMDIRCOLUMN_H
29 #define TABLES_MSMDIRCOLUMN_H
30 
31 
32 //# Includes
33 #include <casacore/casa/aips.h>
34 #include <casacore/tables/DataMan/MSMColumn.h>
35 #include <casacore/casa/Arrays/Array.h>
36 
37 
38 namespace casacore { //# NAMESPACE CASACORE - BEGIN
39 
40 // <summary>
41 // Memory storage manager for table arrays
42 // </summary>
43 
44 // <use visibility=local>
45 
46 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
47 // </reviewed>
48 
49 // <prerequisite>
50 //# Classes you should understand before using this one.
51 // <li> MSMBase
52 // <li> MSMColumn
53 // </prerequisite>
54 
55 // <synopsis>
56 // MSMDirColumn handles arrays in a table column.
57 // It only keeps them in memory, so they are not persistent.
58 // </synopsis>
59 
60 //# <todo asof="$DATE:$">
61 //# A List of bugs, limitations, extensions or planned refinements.
62 //# </todo>
63 
64 
65 class MSMDirColumn: public MSMColumn
66 {
67 public:
68  // Create a column of the given type.
69  MSMDirColumn (MSMBase* smptr, int dataType);
70 
71  // Frees up the storage.
72  virtual ~MSMDirColumn();
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  {
119  Array<T> arr(shape_p, static_cast<T*>(getArrayPtr (rownr)), SHARE);
120  data = arr(slicer);
121  }
122 
123  template<typename T>
124  inline void doPutSlice (rownr_t rownr, const Slicer& slicer, const Array<T>& data)
125  {
126  Array<T> arr(shape_p, static_cast<T*>(getArrayPtr (rownr)), SHARE);
127  arr(slicer) = data;
128  }
129 
130  // Delete the array in the given row.
131  void deleteArray (rownr_t rownr);
132 
133  // Forbid copy constructor.
135 
136  // Forbid assignment.
138 
139 
140  // The (unique) sequence number of the column.
142  // The shape of the array.
144  // The nr of elements in the array.
146 
147 };
148 
149 
150 } //# NAMESPACE CASACORE - END
151 
152 #endif
Non-templated base class for templated Array class.
Definition: ArrayBase.h:73
void * getArrayPtr(rownr_t rownr)
Get the pointer for the given row.
MSMDirColumn & operator=(const MSMDirColumn &)
Forbid assignment.
uInt seqnr_p
The (unique) sequence number of the column.
Definition: MSMDirColumn.h:141
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)
Definition: MSMDirColumn.h:124
void doGetSlice(rownr_t rownr, const Slicer &slicer, Array< T > &data)
Definition: MSMDirColumn.h:117
void doCreate(rownr_t nrrow)
Let the column create its arrays.
IPosition shape_p
The shape of the array.
Definition: MSMDirColumn.h:143
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.
MSMDirColumn(const MSMDirColumn &)
Forbid copy constructor.
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.
rownr_t nrelem_p
The nr of elements in the array.
Definition: MSMDirColumn.h:145
virtual void putSliceV(rownr_t rownr, const Slicer &, const ArrayBase &arr)
Put into a section of the array in the given row.
virtual int dataType() const
Return the data type of the column.
@ SHARE
Share means that the Array will just use the pointer (no copy), however the Array will NOT delete it ...
Definition: ArrayBase.h:62
this file contains all the compiler specific defines
Definition: mainpage.dox:28
unsigned int uInt
Definition: aipstype.h:51
uInt64 rownr_t
Define the type of a row number in a table.
Definition: aipsxtype.h:46