6 #ifndef ECHELON_MULTI_ARRAY_ADAPTER_HPP 7 #define ECHELON_MULTI_ARRAY_ADAPTER_HPP 9 #include <echelon/range.hpp> 11 #include <echelon/hdf5/container_adaption.hpp> 12 #include <echelon/dataset.hpp> 13 #include <echelon/detail/map_indices.hpp> 14 #include <echelon/detail/all_integral.hpp> 20 #include <type_traits> 31 template <
typename Container>
49 : container_(container_), shape_(std::move(shape_))
68 template <
typename... Indices,
typename Enabler =
typename std::enable_if<
69 detail::all_integral<Indices...>::value>
::type>
72 static_assert(detail::all_integral<Indices...>::value,
73 "All indices must be of integral type.");
75 return container_[detail::map_indices(shape_, indices...)];
92 template <
typename... Indices,
typename Enabler =
typename std::enable_if<
93 detail::all_integral<Indices...>::value>
::type>
96 static_assert(detail::all_integral<Indices...>::value,
97 "All indices must be of integral type.");
99 return container_[detail::map_indices(shape_, indices...)];
110 template <
typename... Args,
typename Enabler =
typename std::enable_if<
111 !detail::all_integral<Args...>::value>
::type>
112 echelon::hdf5::array_slice<value_type>
operator()(Args... args)
114 return echelon::make_slice(*
this, std::forward<Args>(args)...);
123 typename Container::iterator
begin()
125 return container_.begin();
134 typename Container::iterator
end()
136 return container_.end();
145 typename Container::const_iterator
begin()
const 147 return container_.begin();
156 typename Container::const_iterator
end()
const 158 return container_.end();
167 using ::echelon::hdf5::data;
169 return data(container_);
178 using ::echelon::hdf5::data;
180 return data(container_);
185 const std::vector<std::size_t>&
shape()
const 191 Container& container_;
192 std::vector<std::size_t> shape_;
echelon's core namespace
Definition: attribute.cpp:10
Container::iterator begin()
Returns an iterator, which points to the first element of the flattened array.
Definition: multi_array_adapter.hpp:123
Container::value_type value_type
value type of the array
Definition: multi_array_adapter.hpp:36
echelon::hdf5::array_slice< value_type > operator()(Args...args)
Slice the array.
Definition: multi_array_adapter.hpp:112
const std::vector< std::size_t > & shape() const
The shape of the array.
Definition: multi_array_adapter.hpp:185
A handle to an HDF5 type.
Definition: type.hpp:21
Container::const_iterator end() const
Returns an iterator, which points to the last element of the flattened array.
Definition: multi_array_adapter.hpp:156
Container::const_iterator begin() const
Returns an iterator, which points to the first element of the flattened array.
Definition: multi_array_adapter.hpp:145
const value_type & operator()(Indices...indices) const
Accesses a specified element.
Definition: multi_array_adapter.hpp:70
value_type * data()
Direct access to the underlying array.
Definition: multi_array_adapter.hpp:176
An adapter, around a random-access sequence container, which behaves like a multidimensional array...
Definition: multi_array_adapter.hpp:32
value_type & operator()(Indices...indices)
Accesses a specified element.
Definition: multi_array_adapter.hpp:94
const value_type * data() const
Direct access to the underlying array.
Definition: multi_array_adapter.hpp:165
multi_array_adapter(Container &container_, std::vector< std::size_t > shape_)
Constructs a new adapter around a given container using a given shape.
Definition: multi_array_adapter.hpp:48
Container::iterator end()
Returns an iterator, which points to the last element of the flattened array.
Definition: multi_array_adapter.hpp:134