BEM++  2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
collection_of_4d_arrays.hpp
1 // Copyright (C) 2011-2012 by the BEM++ Authors
2 //
3 // Permission is hereby granted, free of charge, to any person obtaining a copy
4 // of this software and associated documentation files (the "Software"), to deal
5 // in the Software without restriction, including without limitation the rights
6 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 // copies of the Software, and to permit persons to whom the Software is
8 // furnished to do so, subject to the following conditions:
9 //
10 // The above copyright notice and this permission notice shall be included in
11 // all copies or substantial portions of the Software.
12 //
13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 // THE SOFTWARE.
20 
21 #ifndef fiber_collection_of_4d_arrays_hpp
22 #define fiber_collection_of_4d_arrays_hpp
23 
24 #include "_4d_array.hpp"
25 
26 #include <boost/scoped_array.hpp>
27 
28 namespace Fiber
29 {
30 
32 template <typename T> class CollectionOf3dSlicesOf4dArrays;
33 template <typename T> class CollectionOf2dSlicesOf4dArrays;
34 template <typename T> class CollectionOf1dSlicesOf4dArrays;
35 template <typename T> class CollectionOf3dSlicesOfConst4dArrays;
36 template <typename T> class CollectionOf2dSlicesOfConst4dArrays;
37 template <typename T> class CollectionOf1dSlicesOfConst4dArrays;
40 template <typename T>
42 {
43 public:
45  explicit CollectionOf4dArrays(size_t arrayCount);
46 
47  void set_size(size_t new_size);
48  size_t size() const;
49 
50  _4dArray<T>& operator[](size_t index);
51  const _4dArray<T>& operator[](size_t index) const;
52 
53  void fill(const T& value);
54 
55  CollectionOf3dSlicesOf4dArrays<T> slice(size_t index3);
56  CollectionOf3dSlicesOfConst4dArrays<T> const_slice(size_t index3) const;
57  CollectionOf2dSlicesOf4dArrays<T> slice(size_t index2, size_t index3);
58  CollectionOf2dSlicesOfConst4dArrays<T> const_slice(size_t index2, size_t index3) const;
59  CollectionOf1dSlicesOf4dArrays<T> slice(size_t index1, size_t index2, size_t index3);
60  CollectionOf1dSlicesOfConst4dArrays<T> const_slice(size_t index1, size_t index2, size_t index3) const;
61 
62 private:
63  _4dArray<T>& array(size_t index);
64  const _4dArray<T>& array(size_t index) const;
65  void check_array_index(size_t array_index) const;
66 
67 private:
68  // Disable copy constructor and assignment operator
70  CollectionOf4dArrays& operator=(const CollectionOf4dArrays& rhs);
71 
72 private:
73  size_t m_size;
74  boost::scoped_array<_4dArray<T> > m_arrays;
75 };
76 
77 template <typename T>
79 {
80 public:
81  CollectionOf3dSlicesOf4dArrays(CollectionOf4dArrays<T>& collection, size_t index3);
82 
92 
93  _3dSliceOfConst4dArray<T> operator[](size_t index) const;
94  _3dSliceOf4dArray<T> operator[](size_t index);
95 
96  size_t size() const;
97 
98 private:
99  CollectionOf4dArrays<T>& m_collection;
100  size_t m_index3;
101 };
102 
103 template <typename T>
105 {
106 public:
108  const CollectionOf4dArrays<T>& collection, size_t index3);
109 
110  _3dSliceOfConst4dArray<T> operator[](size_t index) const;
111 
112  size_t size() const;
113 
114 private:
115  const CollectionOf4dArrays<T>& m_collection;
116  size_t m_index3;
117 };
118 
119 template <typename T>
121 {
122 public:
123  CollectionOf2dSlicesOf4dArrays(CollectionOf4dArrays<T>& collection, size_t index2, size_t index3);
124 
134 
135  _2dSliceOfConst4dArray<T> operator[](size_t index) const;
136  _2dSliceOf4dArray<T> operator[](size_t index);
137 
138  size_t size() const;
139 
140 private:
141  CollectionOf4dArrays<T>& m_collection;
142  size_t m_index2, m_index3;
143 };
144 
145 template <typename T>
147 {
148 public:
150  const CollectionOf4dArrays<T>& collection, size_t index2, size_t index3);
151 
152  _2dSliceOfConst4dArray<T> operator[](size_t index) const;
153 
154  size_t size() const;
155 
156 private:
157  const CollectionOf4dArrays<T>& m_collection;
158  size_t m_index2, m_index3;
159 };
160 
161 template <typename T>
163 {
164 public:
166  size_t index1, size_t index2, size_t index3);
167 
177 
178  _1dSliceOfConst4dArray<T> operator[](size_t index) const;
179  _1dSliceOf4dArray<T> operator[](size_t index);
180 
181  size_t size() const;
182 
183 private:
184  CollectionOf4dArrays<T>& m_collection;
185  size_t m_index1, m_index2, m_index3;
186 };
187 
188 template <typename T>
190 {
191 public:
193  const CollectionOf4dArrays<T>& collection, size_t index1, size_t index2, size_t index3);
194 
195  _1dSliceOfConst4dArray<T> operator[](size_t index) const;
196 
197  size_t size() const;
198 
199 private:
200  const CollectionOf4dArrays<T>& m_collection;
201  size_t m_index1, m_index2, m_index3;
202 };
203 
204 } // namespace Fiber
205 
206 #include "collection_of_4d_arrays_imp.hpp"
207 
208 #endif
Definition: collection_of_4d_arrays.hpp:162
Simple implementation of a 4D Fortran-ordered array.
Definition: _4d_array.hpp:50
Definition: collection_of_4d_arrays.hpp:120
Lightweight encapsulation of a 2D slice of a constant 4d array.
Definition: _4d_array.hpp:176
Lightweight encapsulation of a 2D slice of a constant 4d array.
Definition: _4d_array.hpp:128
Lightweight encapsulation of a 2D slice of a constant 4d array.
Definition: _4d_array.hpp:225
Definition: collection_of_4d_arrays.hpp:104
Definition: collection_of_4d_arrays.hpp:189
Definition: collection_of_4d_arrays.hpp:78
Lightweight encapsulation of a 3D slice of a 4D array.
Definition: _4d_array.hpp:99
Lightweight encapsulation of a 2D slice of a 4d array.
Definition: _4d_array.hpp:147
Definition: collection_of_4d_arrays.hpp:146
Definition: collection_of_4d_arrays.hpp:41
Lightweight encapsulation of a 1D slice of a 4d array.
Definition: _4d_array.hpp:195