Loading...
Searching...
No Matches
piercedStorageRange.hpp
1/*---------------------------------------------------------------------------*\
2 *
3 * bitpit
4 *
5 * Copyright (C) 2015-2021 OPTIMAD engineering Srl
6 *
7 * -------------------------------------------------------------------------
8 * License
9 * This file is part of bitpit.
10 *
11 * bitpit is free software: you can redistribute it and/or modify it
12 * under the terms of the GNU Lesser General Public License v3 (LGPL)
13 * as published by the Free Software Foundation.
14 *
15 * bitpit is distributed in the hope that it will be useful, but WITHOUT
16 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
18 * License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public License
21 * along with bitpit. If not, see <http://www.gnu.org/licenses/>.
22 *
23\*---------------------------------------------------------------------------*/
24
25#ifndef __BITPIT_PIERCED_STORAGE_RANGE_HPP__
26#define __BITPIT_PIERCED_STORAGE_RANGE_HPP__
27
28#include <stdexcept>
29
30#include "piercedKernel.hpp"
31#include "piercedKernelRange.hpp"
32
33namespace bitpit {
34
35template<typename PKR_id_t>
36class PiercedKernelRange;
37
38template<typename PS_value_t, typename PS_id_t>
39class PiercedStorage;
40
45template<typename value_t, typename id_t = long,
46 typename value_no_cv_t = typename std::remove_cv<value_t>::type>
48{
49
50friend class PiercedStorageRange<value_no_cv_t, id_t, value_no_cv_t>;
51
52template<typename PS_value_t, typename PS_id_t>
53friend class PiercedStorage;
54
55private:
59 template<typename PS_value_t, typename PS_id_t>
61
68 typedef
69 typename std::conditional<std::is_const<value_t>::value,
72 >::type
73
74 storage_t;
75
76 /*
77 * Iterator type
78 *
79 * When building a const_iterator the pointer to the container has to
80 * be declared const.
81 */
82 typedef
83 typename std::conditional<std::is_const<value_t>::value,
84 typename storage_t::const_iterator,
85 typename storage_t::iterator
86 >::type
87
88 iterator_t;
89
90 /*
91 * Const iterator type
92 *
93 * When building a const_iterator the pointer to the container has to
94 * be declared const.
95 */
96 typedef typename storage_t::const_iterator const_iterator_t;
97
98public:
100 typedef storage_t storage_type;
101
103 typedef value_t value_type;
104
106 typedef id_t id_type;
107
109 typedef iterator_t iterator;
110
112 typedef const_iterator_t const_iterator;
113
114 // Constructors
116 PiercedStorageRange(storage_t *storage);
117 PiercedStorageRange(storage_t *storage, id_t first, id_t last);
119
120 // General methods
121 void initialize(const storage_t *storage);
122 void initialize(const storage_t *storage, id_t first, id_t last);
123 void initialize(const iterator &begin, const iterator &end);
124
126
127 void swap(PiercedStorageRange &other) noexcept;
128
130
131 // Methods to get begin and end
132 template<typename U = value_t, typename U_no_cv = value_no_cv_t,
133 typename std::enable_if<std::is_same<U, U_no_cv>::value, int>::type = 0>
134 iterator begin() noexcept;
135
136 template<typename U = value_t, typename U_no_cv = value_no_cv_t,
137 typename std::enable_if<std::is_same<U, U_no_cv>::value, int>::type = 0>
138 iterator end() noexcept;
139
140 const_iterator begin() const noexcept;
141 const_iterator end() const noexcept;
142
143 const_iterator cbegin() const noexcept;
144 const_iterator cend() const noexcept;
145
149 template<typename other_value_t, typename other_id_t = long>
150 bool operator==(const PiercedStorageRange<other_value_t, other_id_t> &rhs) const
151 {
153 return false;
154 }
155
156 return true;
157 }
158
162 template<typename other_value_t, typename other_id_t = long>
164 {
166 return true;
167 }
168
169 return false;
170 }
171
172private:
173 iterator m_begin;
174 iterator m_end;
175
176};
177
178}
179
180// Include the implementation
181#include "piercedStorageRange.tpp"
182
183#endif
The PiercedKernelRange allow to iterate using range-based loops over a PiercedStorage.
The PiercedStorageRange allow to iterate using range-based loops over a PiercedStorage.
void swap(PiercedStorageRange &other) noexcept
const_iterator cbegin() const noexcept
const PiercedKernelRange< id_t > & getKernelRange() const
const_iterator cend() const noexcept
void initialize(const storage_t *storage)
bool operator!=(const PiercedStorageRange< other_value_t, other_id_t > &rhs) const
Metafunction for generating a pierced storage.
--- layout: doxygen_footer ---