BEM++  2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
collection_of_3d_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_3d_arrays_hpp
22 #define fiber_collection_of_3d_arrays_hpp
23 
24 #include "_3d_array.hpp"
25 
26 #include <boost/scoped_array.hpp>
27 
28 namespace Fiber
29 {
30 
32 template <typename T> class CollectionOf2dSlicesOf3dArrays;
33 template <typename T> class CollectionOf1dSlicesOf3dArrays;
34 template <typename T> class CollectionOf2dSlicesOfConst3dArrays;
35 template <typename T> class CollectionOf1dSlicesOfConst3dArrays;
38 template <typename T>
40 {
41 public:
43  explicit CollectionOf3dArrays(size_t arrayCount);
44 
45  void set_size(size_t new_size);
46  size_t size() const;
47 
48  _3dArray<T>& operator[](size_t index);
49  const _3dArray<T>& operator[](size_t index) const;
50 
51  void fill(const T& value);
52 
53  CollectionOf2dSlicesOf3dArrays<T> slice(size_t index2);
54  CollectionOf2dSlicesOfConst3dArrays<T> const_slice(size_t index2) const;
55  CollectionOf1dSlicesOf3dArrays<T> slice(size_t index1, size_t index2);
56  CollectionOf1dSlicesOfConst3dArrays<T> const_slice(size_t index1, size_t index2) const;
57 
58 private:
59  _3dArray<T>& array(size_t index);
60  const _3dArray<T>& array(size_t index) const;
61  void check_array_index(size_t array_index) const;
62 
63 private:
64  // Disable copy constructor and assignment operator
66  CollectionOf3dArrays& operator=(const CollectionOf3dArrays& rhs);
67 
68 private:
69  size_t m_size;
70  boost::scoped_array<_3dArray<T> > m_arrays;
71 };
72 
73 template <typename T>
75 {
76 public:
77  CollectionOf2dSlicesOf3dArrays(CollectionOf3dArrays<T>& collection, size_t index2);
78 
81 
91 
92  _2dSliceOfConst3dArray<T> operator[](size_t index) const;
93  _2dSliceOf3dArray<T> operator[](size_t index);
94 
95  size_t size() const;
96 
97 private:
98  CollectionOf3dArrays<T>& m_collection;
99  size_t m_index2;
100 };
101 
102 template <typename T>
104 {
105 public:
107  const CollectionOf3dArrays<T>& collection, size_t index2);
108 
110 
111  _2dSliceOfConst3dArray<T> operator[](size_t index) const;
112 
113  size_t size() const;
114 
115 private:
116  const CollectionOf3dArrays<T>& m_collection;
117  size_t m_index2;
118 };
119 
120 template <typename T>
122 {
123 public:
125  size_t index1, size_t index2);
126 
128  typedef _1dSliceOf3dArray<T> Slice;
129 
139 
140  _1dSliceOfConst3dArray<T> operator[](size_t index) const;
141  _1dSliceOf3dArray<T> operator[](size_t index);
142 
143  size_t size() const;
144 
145 private:
146  CollectionOf3dArrays<T>& m_collection;
147  size_t m_index1, m_index2;
148 };
149 
150 template <typename T>
152 {
153 public:
155  const CollectionOf3dArrays<T>& collection, size_t index1, size_t index2);
156 
158 
159  _1dSliceOfConst3dArray<T> operator[](size_t index) const;
160 
161  size_t size() const;
162 
163 private:
164  const CollectionOf3dArrays<T>& m_collection;
165  size_t m_index1, m_index2;
166 };
167 
168 } // namespace Fiber
169 
170 #include "collection_of_3d_arrays_imp.hpp"
171 
172 #endif
Definition: collection_of_3d_arrays.hpp:151
Lightweight encapsulation of a 2D slice of a constant 3D array.
Definition: _3d_array.hpp:136
Lightweight encapsulation of a 1D slice of a constant 3D array.
Definition: _3d_array.hpp:185
Definition: collection_of_3d_arrays.hpp:39
Definition: collection_of_3d_arrays.hpp:103
Lightweight encapsulation of a 2D slice of a 3D array.
Definition: _3d_array.hpp:107
Lightweight encapsulation of a 1D slice of a 3D array.
Definition: _3d_array.hpp:155
Definition: collection_of_3d_arrays.hpp:121
Definition: collection_of_3d_arrays.hpp:74
Simple implementation of a 3D Fortran-ordered array.
Definition: _3d_array.hpp:48