casacore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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>
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.
134  MSMDirColumn (const MSMDirColumn&);
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
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:118
virtual ~MSMDirColumn()
Frees up the storage.
uInt seqnr_p
The (unique) sequence number of the column.
Definition: MSMDirColumn.h:141
Non-templated base class for templated Array class.
Definition: ArrayBase.h:72
void doPutSlice(rownr_t rownr, const Slicer &slicer, const Array< T > &data)
Definition: MSMDirColumn.h:124
Memory storage manager for table arrays.
Definition: MSMDirColumn.h:65
virtual void addRow(rownr_t newNrrow, rownr_t oldNrrow)
Add (newNrrow-oldNrrow) rows to the column.
virtual void getSliceV(rownr_t rownr, const Slicer &, ArrayBase &arr)
Get a section of the array in the given row.
Base class for memory-based table storage manager class.
Definition: MSMBase.h:67
MSMDirColumn & operator=(const MSMDirColumn &)
Forbid assignment.
MSMDirColumn(MSMBase *smptr, int dataType)
Create a column of the given type.
virtual void putArrayV(rownr_t rownr, const ArrayBase &arr)
Put an array value into the given row.
virtual void putSliceV(rownr_t rownr, const Slicer &, const ArrayBase &arr)
Put into 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 int dataType() const
Return the data type of the column.
void deleteArray(rownr_t rownr)
Delete the array in the given row.
Column in the Memory table storage manager class.
Definition: MSMColumn.h:103
Specify which elements to extract from an n-dimensional array.
Definition: Slicer.h:288
void * getArrayPtr(rownr_t rownr)
Get the pointer for the given row.
uInt64 rownr_t
Define the type of a row number in a table.
Definition: aipsxtype.h:46
Share means that the Array will just use the pointer (no copy), however the Array will NOT delete it ...
Definition: ArrayBase.h:62
virtual void setShapeColumn(const IPosition &shape)
Set the (fixed) shape of the arrays in the entire column.
IPosition shape_p
The shape of the array.
Definition: MSMDirColumn.h:143
void doCreate(rownr_t nrrow)
Let the column create its arrays.
rownr_t nrelem_p
The nr of elements in the array.
Definition: MSMDirColumn.h:145
void doGetSlice(rownr_t rownr, const Slicer &slicer, Array< T > &data)
Definition: MSMDirColumn.h:117
virtual IPosition shape(rownr_t rownr)
Get the shape of the array in the given row.
virtual uInt ndim(rownr_t rownr)
Get the dimensionality of the item in the given row.
unsigned int uInt
Definition: aipstype.h:51