casacore
LELArray.h
Go to the documentation of this file.
1 //# LELArray.h: Hold an array with a mask in LEL
2 //# Copyright (C) 1999
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$
27 
28 #ifndef LATTICES_LELARRAY_H
29 #define LATTICES_LELARRAY_H
30 
31 
32 //# Includes
33 #include <casacore/casa/aips.h>
34 #include <casacore/lattices/LEL/LELArrayBase.h>
35 
36 
37 namespace casacore { //# NAMESPACE CASACORE - BEGIN
38 
39 // <summary>
40 // This LEL class holds an array with a mask.
41 // </summary>
42 
43 // <use visibility=local>
44 
45 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
46 // </reviewed>
47 
48 // <synopsis>
49 // This LEL class holds an array with a mask.
50 // The mask can be a single Bool valid for all elements of the array.
51 // Otherwise it is a full mask with the same shape as the array.
52 // </synopsis>
53 
54 // <motivation>
55 // It makes it possible to handle an array with its mask as a single object.
56 // </motivation>
57 
58 // <todo asof="1998/01/20">
59 // </todo>
60 
61 
62 template <class T> class LELArray : public LELArrayBase
63 {
64 public:
65 // Constructor takes value.
66 // Its mask is set to all True.
68  : itsValue (value) {}
69 
70 // Constructor takes value and mask.
73 
74 // Constructor takes shape.
75 // Its mask is set to all True.
77 
78 // Copy constructor (reference semantics).
79  LELArray (const LELArray<T>& other);
80 
82 
83  // Assignment (reference semantics).
85 
86 // Get shape (of the value).
87  const IPosition& shape() const
88  { return itsValue.shape(); }
89 
90 // Get value.
91 // <group>
92  const Array<T>& value() const
93  { return itsValue; }
95  { return itsValue; }
96 // </group>
97 
98 private:
100 };
101 
102 
103 
104 
105 // <summary>
106 // This LEL class holds a possible referenced array with a mask.
107 // </summary>
108 
109 // <use visibility=local>
110 
111 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
112 // </reviewed>
113 
114 // <synopsis>
115 // This LEL class is derived from LELArray.
116 // Its purpose is to provide only const access to the array value, so
117 // the array can be a reference to another array.
118 // It is meant for optimization, so references can safely be used
119 // when evaluating a subexpression.
120 // </synopsis>
121 
122 // <motivation>
123 // It makes it possible to use the function evalRef in a safe way.
124 // It would be unsafe to use a LELArray object, because that
125 // gives non-const access to the value.
126 // </motivation>
127 
128 // <todo asof="1998/01/20">
129 // </todo>
130 
131 
132 template <class T> class LELArrayRef : public LELArray<T>
133 {
134 public:
135 // Constructor takes shape.
136 // Its mask is set to all True.
138  : LELArray<T> (shape) {}
139 
141  {}
142 
143 // Get value.
144  const Array<T>& value() const
145  { return LELArray<T>::value(); }
146 
147 private:
148 // Copy constructor is not needed.
149  LELArrayRef (const LELArrayRef<T>& other);
150 // Assignment is not needed.
152 };
153 
154 
155 
156 } //# NAMESPACE CASACORE - END
157 
158 #ifndef CASACORE_NO_AUTO_TEMPLATES
159 #include <casacore/lattices/LEL/LELArray.tcc>
160 #endif //# CASACORE_NO_AUTO_TEMPLATES
161 #endif
const IPosition & shape() const
The length of each axis.
Definition: ArrayBase.h:125
const Array< Bool > & mask() const
Get mask.
Definition: LELArrayBase.h:87
This LEL class holds a possible referenced array with a mask.
Definition: LELArray.h:133
LELArrayRef(const LELArrayRef< T > &other)
Copy constructor is not needed.
const Array< T > & value() const
Get value.
Definition: LELArray.h:144
LELArrayRef< T > & operator=(const LELArrayRef< T > &other)
Assignment is not needed.
LELArrayRef(const IPosition &shape)
Constructor takes shape.
Definition: LELArray.h:137
LELArray(const LELArray< T > &other)
Copy constructor (reference semantics).
LELArray< T > & operator=(const LELArray< T > &other)
Assignment (reference semantics).
LELArray(const IPosition &shape)
Constructor takes shape.
const IPosition & shape() const
Get shape (of the value).
Definition: LELArray.h:87
const Array< T > & value() const
Get value.
Definition: LELArray.h:92
LELArray(const Array< T > &value, const Array< Bool > &mask)
Constructor takes value and mask.
Definition: LELArray.h:71
LELArray(const Array< T > &value)
Constructor takes value.
Definition: LELArray.h:67
Array< T > & value()
Definition: LELArray.h:94
Array< T > itsValue
Definition: LELArray.h:99
this file contains all the compiler specific defines
Definition: mainpage.dox:28