Alexandria  2.18
Please provide a description of the project.
GridIndexHelper.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2021 Euclid Science Ground Segment
3  *
4  * This library is free software; you can redistribute it and/or modify it under
5  * the terms of the GNU Lesser General Public License as published by the Free
6  * Software Foundation; either version 3.0 of the License, or (at your option)
7  * any later version.
8  *
9  * This library is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12  * details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with this library; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
25 #ifndef GRIDCONTAINER_GRIDINDEXHELPER_H
26 #define GRIDCONTAINER_GRIDINDEXHELPER_H
27 
28 #include "GridContainer/GridAxis.h"
30 #include <tuple>
31 #include <vector>
32 
33 namespace Euclid {
34 namespace GridContainer {
35 
53 template <typename... AxesTypes>
55 
56 public:
64  explicit GridIndexHelper(const std::tuple<GridAxis<AxesTypes>...>& axes_tuple);
65 
69 
71  virtual ~GridIndexHelper() = default;
72 
82  size_t axisIndex(size_t axis, size_t array_index) const;
83 
91  size_t totalIndex(decltype(std::declval<GridAxis<AxesTypes>>().size())... coords) const;
92 
102  size_t totalIndexChecked(decltype(std::declval<GridAxis<AxesTypes>>().size())... coords) const;
103 
105  template <typename Coord>
106  void checkAllFixedAreZero(const std::map<size_t, size_t>& fixed_indices, Coord coord) const;
107 
109  template <typename Coord, typename... RestCoords>
110  void checkAllFixedAreZero(const std::map<size_t, size_t>& fixed_indices, Coord coord, RestCoords... rest_coords) const;
111 
115 };
116 
126 template <typename... AxesTypes>
128  return GridIndexHelper<AxesTypes...>(axes_tuple);
129 }
130 
131 } // end of namespace GridContainer
132 } // end of namespace Euclid
133 
135 
136 #endif /* GRIDCONTAINER_GRIDINDEXHELPER_H */
GridIndexHelper.icpp
Euclid::GridContainer::makeGridIndexHelper
GridIndexHelper< AxesTypes... > makeGridIndexHelper(const std::tuple< GridAxis< AxesTypes >... > &axes_tuple)
Definition: GridIndexHelper.h:127
Euclid::GridContainer::GridAxis
Provides information related with an axis of a GridContainer.
Definition: GridAxis.h:49
Euclid::GridContainer::GridIndexHelper::operator=
GridIndexHelper & operator=(GridIndexHelper< AxesTypes... > &&)=default
GridAxis.h
std::vector< size_t >
Euclid::GridContainer::GridIndexHelper
Helper class for converting multi-dimensional grid coordinates to the index of a long data array and ...
Definition: GridIndexHelper.h:54
Euclid::GridContainer::GridIndexHelper::totalIndex
size_t totalIndex(decltype(std::declval< GridAxis< AxesTypes >>().size())... coords) const
std::tuple
Euclid::GridContainer::GridIndexHelper::checkAllFixedAreZero
void checkAllFixedAreZero(const std::map< size_t, size_t > &fixed_indices, Coord coord, RestCoords... rest_coords) const
Checks if any of the given coordinates is fixed and not zero.
Euclid::GridContainer::GridIndexHelper::m_axes_names
std::vector< std::string > m_axes_names
Definition: GridIndexHelper.h:114
Euclid::GridContainer::GridIndexHelper::m_axes_sizes
std::vector< size_t > m_axes_sizes
Definition: GridIndexHelper.h:112
Euclid::GridContainer::GridIndexHelper::totalIndexChecked
size_t totalIndexChecked(decltype(std::declval< GridAxis< AxesTypes >>().size())... coords) const
Euclid::GridContainer::GridIndexHelper::checkAllFixedAreZero
void checkAllFixedAreZero(const std::map< size_t, size_t > &fixed_indices, Coord coord) const
Checks if any of the given coordinates is fixed and not zero.
Euclid::GridContainer::GridIndexHelper::GridIndexHelper
GridIndexHelper(const std::tuple< GridAxis< AxesTypes >... > &axes_tuple)
std::map< size_t, size_t >
Euclid::GridContainer::GridIndexHelper::~GridIndexHelper
virtual ~GridIndexHelper()=default
Default destructor.
Euclid::GridContainer::GridIndexHelper::axisIndex
size_t axisIndex(size_t axis, size_t array_index) const
GridConstructionHelper.h
Euclid::GridContainer::GridIndexHelper::GridIndexHelper
GridIndexHelper(GridIndexHelper< AxesTypes... > &&)=default
Default move constructor and assignment operator.
Euclid
Definition: InstOrRefHolder.h:29
std::declval
T declval(T... args)
Euclid::GridContainer::GridIndexHelper::m_axes_index_factors
std::vector< size_t > m_axes_index_factors
Definition: GridIndexHelper.h:113