BEM++  2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
collection_of_2d_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_2d_arrays_hpp
22 #define fiber_collection_of_2d_arrays_hpp
23 
24 #include "_2d_array.hpp"
25 
26 #include <boost/scoped_array.hpp>
27 
28 namespace Fiber
29 {
30 
32 template <typename T> class CollectionOf1dSlicesOf2dArrays;
33 template <typename T> class CollectionOf1dSlicesOfConst2dArrays;
36 template <typename T>
38 {
39 public:
41  explicit CollectionOf2dArrays(size_t arrayCount);
43  CollectionOf2dArrays& operator=(const CollectionOf2dArrays& rhs);
44 
45  void set_size(size_t new_size);
46  size_t size() const;
47 
48  _2dArray<T>& operator[](size_t index);
49  const _2dArray<T>& operator[](size_t index) const;
50 
51  void fill(const T& value);
52 
53  CollectionOf1dSlicesOf2dArrays<T> slice(size_t index1);
54  CollectionOf1dSlicesOfConst2dArrays<T> const_slice(size_t index1) const;
55 
56 private:
57  _2dArray<T>& array(size_t index);
58  const _2dArray<T>& array(size_t index) const;
59  void check_array_index(size_t array_index) const;
60 
61 private:
62  size_t m_size;
63  boost::scoped_array<_2dArray<T> > m_arrays;
64 };
65 
66 
67 template <typename T>
69 {
70 public:
72  size_t index1);
73 
76 
86 
87  _1dSliceOfConst2dArray<T> operator[](size_t index) const;
88  _1dSliceOf2dArray<T> operator[](size_t index);
89 
90  size_t size() const;
91 
92 private:
93  CollectionOf2dArrays<T>& m_collection;
94  size_t m_index1;
95 };
96 
97 template <typename T>
99 {
100 public:
102  const CollectionOf2dArrays<T>& collection, size_t index1);
103 
105 
106  _1dSliceOfConst2dArray<T> operator[](size_t index) const;
107 
108  size_t size() const;
109 
110 private:
111  const CollectionOf2dArrays<T>& m_collection;
112  size_t m_index1;
113 };
114 
115 } // namespace Fiber
116 
117 #include "collection_of_2d_arrays_imp.hpp"
118 
119 #endif
Definition: collection_of_2d_arrays.hpp:68
Lightweight encapsulation of a 1D slice of a 2D array.
Definition: _2d_array.hpp:89
Definition: collection_of_2d_arrays.hpp:98
Simple implementation of a 2D Fortran-ordered array.
Definition: _2d_array.hpp:41
Definition: collection_of_2d_arrays.hpp:37
Lightweight encapsulation of a 1D slice of a constant 2D array.
Definition: _2d_array.hpp:119