Line | Branch | Exec | Source |
---|---|---|---|
1 | // SPDX-FileCopyrightText: 2022-2023 Dennis Gläser <dennis.glaeser@iws.uni-stuttgart.de> | ||
2 | // SPDX-License-Identifier: MIT | ||
3 | /*! | ||
4 | * \file | ||
5 | * \ingroup Common | ||
6 | * \copydoc GridFormat::Field | ||
7 | */ | ||
8 | #ifndef GRIDFORMAT_COMMON_FIELD_HPP_ | ||
9 | #define GRIDFORMAT_COMMON_FIELD_HPP_ | ||
10 | |||
11 | #include <memory> | ||
12 | #include <cstddef> | ||
13 | #include <concepts> | ||
14 | #include <type_traits> | ||
15 | #include <utility> | ||
16 | #include <ranges> | ||
17 | #include <cmath> | ||
18 | |||
19 | #include <gridformat/common/md_layout.hpp> | ||
20 | #include <gridformat/common/precision.hpp> | ||
21 | #include <gridformat/common/serialization.hpp> | ||
22 | #include <gridformat/common/type_traits.hpp> | ||
23 | #include <gridformat/common/exceptions.hpp> | ||
24 | #include <gridformat/common/concepts.hpp> | ||
25 | #include <gridformat/common/ranges.hpp> | ||
26 | |||
27 | namespace GridFormat { | ||
28 | |||
29 | //! \addtogroup Common | ||
30 | //! \{ | ||
31 | |||
32 | /*! | ||
33 | * \brief Abstract interface for fields of values that is used by writers/readers to store fields. | ||
34 | * \details Allows you to obtain information on the layout of the field, the precision of its value type, | ||
35 | * and to retrieve its values in serialized form or to export them into containers. | ||
36 | */ | ||
37 | class Field { | ||
38 | public: | ||
39 | //! Can be used as a flag to disable resizing upon export (e.g. to write to the beginning of larger range) | ||
40 | static constexpr struct DisableResize {} no_resize{}; | ||
41 | |||
42 | 622398 | virtual ~Field() = default; | |
43 | |||
44 | 159852 | Field() = default; | |
45 | 151344 | Field(Field&&) = default; | |
46 | Field(const Field&) = delete; | ||
47 | Field& operator=(Field&&) = default; | ||
48 | Field& operator=(const Field&) = delete; | ||
49 | |||
50 | //! Return the layout of this field | ||
51 | 1061806 | MDLayout layout() const { | |
52 | 1061806 | return _layout(); | |
53 | } | ||
54 | |||
55 | //! Return the precision of the scalar field values | ||
56 | 548320 | DynamicPrecision precision() const { | |
57 | 548320 | return _precision(); | |
58 | } | ||
59 | |||
60 | //! Return the size of all field values in serialized form | ||
61 | 185017 | std::size_t size_in_bytes() const { | |
62 |
4/8✓ Branch 1 taken 185017 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 185017 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 185017 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 185017 times.
✗ Branch 11 not taken.
|
185017 | return layout().number_of_entries()*precision().size_in_bytes(); |
63 | } | ||
64 | |||
65 | //! Return the field values in serialized form | ||
66 | 163336 | Serialization serialized() const { | |
67 | 163336 | auto result = _serialized(); | |
68 |
3/4✓ Branch 2 taken 163336 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 163335 times.
|
163336 | if (result.size() != size_in_bytes()) |
69 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
1 | throw SizeError("Serialized size does not match expected number of bytes"); |
70 | 163335 | return result; | |
71 | 1 | } | |
72 | |||
73 | //! Visit the scalar values of the field in the form of an std::span | ||
74 | template<typename Visitor> | ||
75 | 97919 | decltype(auto) visit_field_values(Visitor&& visitor) const { | |
76 |
2/4✓ Branch 1 taken 48958 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 48958 times.
✗ Branch 5 not taken.
|
146880 | return precision().visit([&] <typename T> (const Precision<T>&) { |
77 |
73/286✓ Branch 1 taken 1791 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 212 times.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 13 taken 39 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 32 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 896 times.
✗ Branch 20 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✓ Branch 25 taken 126 times.
✗ Branch 26 not taken.
✓ Branch 28 taken 6536 times.
✗ Branch 29 not taken.
✓ Branch 31 taken 1755 times.
✗ Branch 32 not taken.
✓ Branch 34 taken 164 times.
✗ Branch 35 not taken.
✓ Branch 37 taken 98 times.
✗ Branch 38 not taken.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✓ Branch 43 taken 36 times.
✗ Branch 44 not taken.
✗ Branch 46 not taken.
✗ Branch 47 not taken.
✓ Branch 49 taken 880 times.
✗ Branch 50 not taken.
✗ Branch 52 not taken.
✗ Branch 53 not taken.
✗ Branch 55 not taken.
✗ Branch 56 not taken.
✓ Branch 58 taken 6399 times.
✗ Branch 59 not taken.
✓ Branch 61 taken 875 times.
✗ Branch 62 not taken.
✓ Branch 64 taken 96 times.
✗ Branch 65 not taken.
✗ Branch 67 not taken.
✗ Branch 68 not taken.
✗ Branch 70 not taken.
✗ Branch 71 not taken.
✓ Branch 73 taken 11 times.
✗ Branch 74 not taken.
✓ Branch 76 taken 98 times.
✗ Branch 77 not taken.
✓ Branch 79 taken 440 times.
✗ Branch 80 not taken.
✗ Branch 82 not taken.
✗ Branch 83 not taken.
✗ Branch 85 not taken.
✗ Branch 86 not taken.
✓ Branch 88 taken 3195 times.
✗ Branch 89 not taken.
✓ Branch 91 taken 5268 times.
✗ Branch 92 not taken.
✓ Branch 94 taken 5244 times.
✗ Branch 95 not taken.
✓ Branch 97 taken 2720 times.
✗ Branch 98 not taken.
✗ Branch 100 not taken.
✗ Branch 101 not taken.
✓ Branch 103 taken 69 times.
✗ Branch 104 not taken.
✗ Branch 106 not taken.
✗ Branch 107 not taken.
✓ Branch 109 taken 1 times.
✗ Branch 110 not taken.
✗ Branch 112 not taken.
✗ Branch 113 not taken.
✗ Branch 115 not taken.
✗ Branch 116 not taken.
✓ Branch 118 taken 1 times.
✗ Branch 119 not taken.
✗ Branch 121 not taken.
✗ Branch 122 not taken.
✗ Branch 124 not taken.
✗ Branch 125 not taken.
✓ Branch 127 taken 280 times.
✗ Branch 128 not taken.
✓ Branch 130 taken 7 times.
✗ Branch 131 not taken.
✓ Branch 133 taken 4 times.
✗ Branch 134 not taken.
✓ Branch 136 taken 201 times.
✗ Branch 137 not taken.
✓ Branch 139 taken 2 times.
✗ Branch 140 not taken.
✓ Branch 142 taken 67 times.
✗ Branch 143 not taken.
✓ Branch 145 taken 28 times.
✗ Branch 146 not taken.
✓ Branch 148 taken 6 times.
✗ Branch 149 not taken.
✓ Branch 151 taken 2 times.
✗ Branch 152 not taken.
✗ Branch 154 not taken.
✗ Branch 155 not taken.
✓ Branch 157 taken 5 times.
✗ Branch 158 not taken.
✓ Branch 160 taken 76 times.
✗ Branch 161 not taken.
✓ Branch 163 taken 111 times.
✗ Branch 164 not taken.
✓ Branch 166 taken 8 times.
✗ Branch 167 not taken.
✗ Branch 169 not taken.
✗ Branch 170 not taken.
✓ Branch 172 taken 8 times.
✗ Branch 173 not taken.
✓ Branch 175 taken 51 times.
✗ Branch 176 not taken.
✓ Branch 178 taken 2 times.
✗ Branch 179 not taken.
✗ Branch 181 not taken.
✗ Branch 182 not taken.
✗ Branch 184 not taken.
✗ Branch 185 not taken.
✗ Branch 187 not taken.
✗ Branch 188 not taken.
✓ Branch 190 taken 17 times.
✗ Branch 191 not taken.
✓ Branch 193 taken 17 times.
✗ Branch 194 not taken.
✓ Branch 196 taken 1 times.
✗ Branch 197 not taken.
✗ Branch 199 not taken.
✗ Branch 200 not taken.
✓ Branch 202 taken 12 times.
✗ Branch 203 not taken.
✗ Branch 205 not taken.
✗ Branch 206 not taken.
✗ Branch 208 not taken.
✗ Branch 209 not taken.
✗ Branch 211 not taken.
✗ Branch 212 not taken.
✓ Branch 214 taken 24 times.
✗ Branch 215 not taken.
✗ Branch 217 not taken.
✗ Branch 218 not taken.
✓ Branch 220 taken 108 times.
✗ Branch 221 not taken.
✗ Branch 223 not taken.
✗ Branch 224 not taken.
✓ Branch 226 taken 120 times.
✗ Branch 227 not taken.
✓ Branch 229 taken 84 times.
✗ Branch 230 not taken.
✗ Branch 232 not taken.
✗ Branch 233 not taken.
✗ Branch 235 not taken.
✗ Branch 236 not taken.
✗ Branch 238 not taken.
✗ Branch 239 not taken.
✗ Branch 241 not taken.
✗ Branch 242 not taken.
✗ Branch 244 not taken.
✗ Branch 245 not taken.
✗ Branch 247 not taken.
✗ Branch 248 not taken.
✗ Branch 250 not taken.
✗ Branch 251 not taken.
✗ Branch 253 not taken.
✗ Branch 254 not taken.
✓ Branch 256 taken 12 times.
✗ Branch 257 not taken.
✓ Branch 259 taken 5 times.
✗ Branch 260 not taken.
✓ Branch 262 taken 2 times.
✗ Branch 263 not taken.
✗ Branch 265 not taken.
✗ Branch 266 not taken.
✗ Branch 268 not taken.
✗ Branch 269 not taken.
✓ Branch 271 taken 780 times.
✗ Branch 272 not taken.
✓ Branch 274 taken 834 times.
✗ Branch 275 not taken.
✗ Branch 277 not taken.
✗ Branch 278 not taken.
✗ Branch 280 not taken.
✗ Branch 281 not taken.
✗ Branch 283 not taken.
✗ Branch 284 not taken.
✗ Branch 286 not taken.
✗ Branch 287 not taken.
✗ Branch 289 not taken.
✗ Branch 290 not taken.
✓ Branch 292 taken 960 times.
✗ Branch 293 not taken.
✗ Branch 295 not taken.
✗ Branch 296 not taken.
✗ Branch 298 not taken.
✗ Branch 299 not taken.
✗ Branch 301 not taken.
✗ Branch 302 not taken.
✗ Branch 304 not taken.
✗ Branch 305 not taken.
✗ Branch 307 not taken.
✗ Branch 308 not taken.
✓ Branch 310 taken 1391 times.
✗ Branch 311 not taken.
✓ Branch 313 taken 97 times.
✗ Branch 314 not taken.
✓ Branch 316 taken 2 times.
✗ Branch 317 not taken.
✓ Branch 319 taken 2 times.
✗ Branch 320 not taken.
✓ Branch 322 taken 282 times.
✗ Branch 323 not taken.
✗ Branch 325 not taken.
✗ Branch 326 not taken.
✗ Branch 328 not taken.
✗ Branch 329 not taken.
✗ Branch 331 not taken.
✗ Branch 332 not taken.
✗ Branch 334 not taken.
✗ Branch 335 not taken.
✗ Branch 337 not taken.
✗ Branch 338 not taken.
✓ Branch 340 taken 1521 times.
✗ Branch 341 not taken.
✓ Branch 343 taken 26 times.
✗ Branch 344 not taken.
✗ Branch 346 not taken.
✗ Branch 347 not taken.
✗ Branch 349 not taken.
✗ Branch 350 not taken.
✓ Branch 352 taken 3 times.
✗ Branch 353 not taken.
✗ Branch 355 not taken.
✗ Branch 356 not taken.
✗ Branch 358 not taken.
✗ Branch 359 not taken.
✓ Branch 361 taken 16 times.
✗ Branch 362 not taken.
✗ Branch 364 not taken.
✗ Branch 365 not taken.
✓ Branch 367 taken 204 times.
✗ Branch 368 not taken.
✗ Branch 370 not taken.
✗ Branch 371 not taken.
✓ Branch 373 taken 31 times.
✗ Branch 374 not taken.
✗ Branch 376 not taken.
✗ Branch 377 not taken.
✓ Branch 379 taken 145 times.
✗ Branch 380 not taken.
✗ Branch 382 not taken.
✗ Branch 383 not taken.
✗ Branch 385 not taken.
✗ Branch 386 not taken.
✓ Branch 388 taken 480 times.
✗ Branch 389 not taken.
✗ Branch 391 not taken.
✗ Branch 392 not taken.
✗ Branch 394 not taken.
✗ Branch 395 not taken.
✗ Branch 397 not taken.
✗ Branch 398 not taken.
✓ Branch 400 taken 1176 times.
✗ Branch 401 not taken.
✓ Branch 403 taken 720 times.
✗ Branch 404 not taken.
✗ Branch 406 not taken.
✗ Branch 407 not taken.
✗ Branch 409 not taken.
✗ Branch 410 not taken.
✗ Branch 412 not taken.
✗ Branch 413 not taken.
✓ Branch 415 taken 1728 times.
✗ Branch 416 not taken.
✓ Branch 418 taken 252 times.
✗ Branch 419 not taken.
✗ Branch 421 not taken.
✗ Branch 422 not taken.
✓ Branch 424 taken 69 times.
✗ Branch 425 not taken.
✗ Branch 427 not taken.
✗ Branch 428 not taken.
|
48961 | const auto serialization = serialized(); |
78 |
161/796✓ Branch 1 taken 1791 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1791 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 212 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 212 times.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 32 times.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✓ Branch 25 taken 40 times.
✗ Branch 26 not taken.
✓ Branch 28 taken 39 times.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✓ Branch 37 taken 895 times.
✗ Branch 38 not taken.
✓ Branch 40 taken 895 times.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
✗ Branch 46 not taken.
✗ Branch 47 not taken.
✗ Branch 48 not taken.
✓ Branch 49 taken 126 times.
✗ Branch 50 not taken.
✓ Branch 51 taken 16 times.
✓ Branch 52 taken 126 times.
✗ Branch 53 not taken.
✓ Branch 54 taken 16 times.
✓ Branch 55 taken 6536 times.
✗ Branch 56 not taken.
✗ Branch 57 not taken.
✓ Branch 58 taken 6536 times.
✗ Branch 59 not taken.
✗ Branch 60 not taken.
✓ Branch 61 taken 1755 times.
✗ Branch 62 not taken.
✗ Branch 63 not taken.
✓ Branch 64 taken 1755 times.
✗ Branch 65 not taken.
✗ Branch 66 not taken.
✓ Branch 67 taken 164 times.
✗ Branch 68 not taken.
✗ Branch 69 not taken.
✓ Branch 70 taken 164 times.
✗ Branch 71 not taken.
✗ Branch 72 not taken.
✓ Branch 73 taken 82 times.
✗ Branch 74 not taken.
✗ Branch 75 not taken.
✓ Branch 76 taken 82 times.
✓ Branch 77 taken 1 times.
✗ Branch 78 not taken.
✗ Branch 79 not taken.
✓ Branch 80 taken 1 times.
✗ Branch 81 not taken.
✗ Branch 82 not taken.
✗ Branch 83 not taken.
✗ Branch 84 not taken.
✓ Branch 85 taken 36 times.
✗ Branch 86 not taken.
✗ Branch 87 not taken.
✓ Branch 88 taken 36 times.
✗ Branch 89 not taken.
✗ Branch 90 not taken.
✗ Branch 91 not taken.
✗ Branch 92 not taken.
✗ Branch 93 not taken.
✗ Branch 94 not taken.
✗ Branch 95 not taken.
✗ Branch 96 not taken.
✓ Branch 97 taken 879 times.
✗ Branch 98 not taken.
✗ Branch 99 not taken.
✓ Branch 100 taken 879 times.
✗ Branch 101 not taken.
✗ Branch 102 not taken.
✗ Branch 103 not taken.
✗ Branch 104 not taken.
✗ Branch 105 not taken.
✗ Branch 106 not taken.
✗ Branch 107 not taken.
✗ Branch 108 not taken.
✗ Branch 109 not taken.
✗ Branch 110 not taken.
✗ Branch 111 not taken.
✗ Branch 112 not taken.
✗ Branch 113 not taken.
✗ Branch 114 not taken.
✓ Branch 115 taken 6399 times.
✗ Branch 116 not taken.
✗ Branch 117 not taken.
✓ Branch 118 taken 6399 times.
✗ Branch 119 not taken.
✗ Branch 120 not taken.
✓ Branch 121 taken 875 times.
✗ Branch 122 not taken.
✗ Branch 123 not taken.
✓ Branch 124 taken 875 times.
✗ Branch 125 not taken.
✗ Branch 126 not taken.
✓ Branch 127 taken 96 times.
✗ Branch 128 not taken.
✓ Branch 129 taken 16 times.
✓ Branch 130 taken 96 times.
✗ Branch 131 not taken.
✓ Branch 132 taken 16 times.
✗ Branch 133 not taken.
✗ Branch 134 not taken.
✗ Branch 135 not taken.
✗ Branch 136 not taken.
✓ Branch 137 taken 1 times.
✗ Branch 138 not taken.
✗ Branch 139 not taken.
✓ Branch 140 taken 1 times.
✗ Branch 141 not taken.
✗ Branch 142 not taken.
✗ Branch 143 not taken.
✗ Branch 144 not taken.
✓ Branch 145 taken 11 times.
✗ Branch 146 not taken.
✗ Branch 147 not taken.
✓ Branch 148 taken 11 times.
✗ Branch 149 not taken.
✗ Branch 150 not taken.
✓ Branch 151 taken 82 times.
✗ Branch 152 not taken.
✗ Branch 153 not taken.
✓ Branch 154 taken 82 times.
✗ Branch 155 not taken.
✗ Branch 156 not taken.
✓ Branch 157 taken 439 times.
✗ Branch 158 not taken.
✗ Branch 159 not taken.
✓ Branch 160 taken 439 times.
✗ Branch 161 not taken.
✗ Branch 162 not taken.
✗ Branch 163 not taken.
✗ Branch 164 not taken.
✗ Branch 165 not taken.
✗ Branch 166 not taken.
✗ Branch 167 not taken.
✗ Branch 168 not taken.
✗ Branch 169 not taken.
✗ Branch 170 not taken.
✓ Branch 171 taken 16 times.
✗ Branch 172 not taken.
✗ Branch 173 not taken.
✓ Branch 174 taken 16 times.
✓ Branch 175 taken 3195 times.
✗ Branch 176 not taken.
✗ Branch 177 not taken.
✓ Branch 178 taken 3195 times.
✗ Branch 179 not taken.
✗ Branch 180 not taken.
✓ Branch 181 taken 5268 times.
✗ Branch 182 not taken.
✗ Branch 183 not taken.
✓ Branch 184 taken 5268 times.
✗ Branch 185 not taken.
✗ Branch 186 not taken.
✓ Branch 187 taken 5244 times.
✗ Branch 188 not taken.
✗ Branch 189 not taken.
✓ Branch 190 taken 5244 times.
✗ Branch 191 not taken.
✗ Branch 192 not taken.
✓ Branch 193 taken 2704 times.
✗ Branch 194 not taken.
✗ Branch 195 not taken.
✓ Branch 196 taken 2704 times.
✗ Branch 197 not taken.
✗ Branch 198 not taken.
✗ Branch 199 not taken.
✗ Branch 200 not taken.
✗ Branch 201 not taken.
✗ Branch 202 not taken.
✗ Branch 203 not taken.
✗ Branch 204 not taken.
✓ Branch 205 taken 69 times.
✗ Branch 206 not taken.
✗ Branch 207 not taken.
✓ Branch 208 taken 69 times.
✗ Branch 209 not taken.
✗ Branch 210 not taken.
✗ Branch 211 not taken.
✗ Branch 212 not taken.
✓ Branch 213 taken 1 times.
✗ Branch 214 not taken.
✗ Branch 215 not taken.
✓ Branch 216 taken 1 times.
✓ Branch 217 taken 1 times.
✗ Branch 218 not taken.
✗ Branch 219 not taken.
✓ Branch 220 taken 1 times.
✗ Branch 221 not taken.
✗ Branch 222 not taken.
✗ Branch 223 not taken.
✗ Branch 224 not taken.
✗ Branch 225 not taken.
✗ Branch 226 not taken.
✗ Branch 227 not taken.
✗ Branch 228 not taken.
✗ Branch 229 not taken.
✗ Branch 230 not taken.
✗ Branch 231 not taken.
✗ Branch 232 not taken.
✗ Branch 233 not taken.
✗ Branch 234 not taken.
✗ Branch 235 not taken.
✗ Branch 236 not taken.
✗ Branch 237 not taken.
✗ Branch 238 not taken.
✗ Branch 239 not taken.
✗ Branch 240 not taken.
✗ Branch 241 not taken.
✗ Branch 242 not taken.
✗ Branch 243 not taken.
✗ Branch 244 not taken.
✗ Branch 245 not taken.
✗ Branch 246 not taken.
✗ Branch 247 not taken.
✗ Branch 248 not taken.
✗ Branch 249 not taken.
✗ Branch 250 not taken.
✗ Branch 251 not taken.
✗ Branch 252 not taken.
✓ Branch 253 taken 280 times.
✗ Branch 254 not taken.
✗ Branch 255 not taken.
✓ Branch 256 taken 280 times.
✗ Branch 257 not taken.
✗ Branch 258 not taken.
✓ Branch 259 taken 7 times.
✗ Branch 260 not taken.
✗ Branch 261 not taken.
✓ Branch 262 taken 7 times.
✗ Branch 263 not taken.
✗ Branch 264 not taken.
✓ Branch 265 taken 4 times.
✗ Branch 266 not taken.
✗ Branch 267 not taken.
✓ Branch 268 taken 4 times.
✗ Branch 269 not taken.
✗ Branch 270 not taken.
✓ Branch 271 taken 201 times.
✗ Branch 272 not taken.
✓ Branch 273 taken 6 times.
✓ Branch 274 taken 201 times.
✗ Branch 275 not taken.
✓ Branch 276 taken 6 times.
✓ Branch 277 taken 2 times.
✗ Branch 278 not taken.
✓ Branch 279 taken 2 times.
✓ Branch 280 taken 2 times.
✗ Branch 281 not taken.
✓ Branch 282 taken 2 times.
✓ Branch 283 taken 67 times.
✗ Branch 284 not taken.
✗ Branch 285 not taken.
✓ Branch 286 taken 67 times.
✗ Branch 287 not taken.
✗ Branch 288 not taken.
✓ Branch 289 taken 28 times.
✗ Branch 290 not taken.
✗ Branch 291 not taken.
✓ Branch 292 taken 28 times.
✗ Branch 293 not taken.
✗ Branch 294 not taken.
✗ Branch 295 not taken.
✗ Branch 296 not taken.
✗ Branch 297 not taken.
✗ Branch 298 not taken.
✗ Branch 299 not taken.
✗ Branch 300 not taken.
✓ Branch 301 taken 35 times.
✗ Branch 302 not taken.
✗ Branch 303 not taken.
✗ Branch 304 not taken.
✓ Branch 305 taken 22 times.
✗ Branch 306 not taken.
✗ Branch 307 not taken.
✓ Branch 308 taken 22 times.
✗ Branch 309 not taken.
✗ Branch 310 not taken.
✗ Branch 311 not taken.
✗ Branch 312 not taken.
✓ Branch 313 taken 5 times.
✗ Branch 314 not taken.
✗ Branch 315 not taken.
✓ Branch 316 taken 5 times.
✗ Branch 317 not taken.
✗ Branch 318 not taken.
✓ Branch 319 taken 41 times.
✗ Branch 320 not taken.
✗ Branch 321 not taken.
✓ Branch 322 taken 41 times.
✗ Branch 323 not taken.
✗ Branch 324 not taken.
✓ Branch 325 taken 89 times.
✗ Branch 326 not taken.
✗ Branch 327 not taken.
✓ Branch 328 taken 89 times.
✗ Branch 329 not taken.
✗ Branch 330 not taken.
✓ Branch 331 taken 8 times.
✗ Branch 332 not taken.
✓ Branch 333 taken 2 times.
✓ Branch 334 taken 8 times.
✗ Branch 335 not taken.
✓ Branch 336 taken 2 times.
✗ Branch 337 not taken.
✗ Branch 338 not taken.
✗ Branch 339 not taken.
✗ Branch 340 not taken.
✗ Branch 341 not taken.
✗ Branch 342 not taken.
✓ Branch 343 taken 8 times.
✗ Branch 344 not taken.
✗ Branch 345 not taken.
✓ Branch 346 taken 8 times.
✗ Branch 347 not taken.
✗ Branch 348 not taken.
✓ Branch 349 taken 51 times.
✗ Branch 350 not taken.
✗ Branch 351 not taken.
✓ Branch 352 taken 51 times.
✗ Branch 353 not taken.
✗ Branch 354 not taken.
✗ Branch 355 not taken.
✗ Branch 356 not taken.
✗ Branch 357 not taken.
✗ Branch 358 not taken.
✗ Branch 359 not taken.
✗ Branch 360 not taken.
✓ Branch 361 taken 10 times.
✗ Branch 362 not taken.
✓ Branch 363 taken 1 times.
✗ Branch 364 not taken.
✓ Branch 365 taken 4 times.
✓ Branch 366 taken 1 times.
✗ Branch 367 not taken.
✓ Branch 368 taken 4 times.
✗ Branch 369 not taken.
✗ Branch 370 not taken.
✗ Branch 371 not taken.
✗ Branch 372 not taken.
✗ Branch 373 not taken.
✗ Branch 374 not taken.
✗ Branch 375 not taken.
✗ Branch 376 not taken.
✗ Branch 377 not taken.
✗ Branch 378 not taken.
✓ Branch 379 taken 7 times.
✗ Branch 380 not taken.
✗ Branch 381 not taken.
✓ Branch 382 taken 7 times.
✗ Branch 383 not taken.
✗ Branch 384 not taken.
✓ Branch 385 taken 12 times.
✗ Branch 386 not taken.
✗ Branch 387 not taken.
✓ Branch 388 taken 12 times.
✗ Branch 389 not taken.
✗ Branch 390 not taken.
✓ Branch 391 taken 1 times.
✗ Branch 392 not taken.
✗ Branch 393 not taken.
✓ Branch 394 taken 1 times.
✗ Branch 395 not taken.
✗ Branch 396 not taken.
✗ Branch 397 not taken.
✗ Branch 398 not taken.
✗ Branch 399 not taken.
✗ Branch 400 not taken.
✗ Branch 401 not taken.
✗ Branch 402 not taken.
✓ Branch 403 taken 12 times.
✗ Branch 404 not taken.
✗ Branch 405 not taken.
✓ Branch 406 taken 12 times.
✗ Branch 407 not taken.
✗ Branch 408 not taken.
✗ Branch 409 not taken.
✗ Branch 410 not taken.
✗ Branch 411 not taken.
✗ Branch 412 not taken.
✗ Branch 413 not taken.
✗ Branch 414 not taken.
✗ Branch 415 not taken.
✗ Branch 416 not taken.
✓ Branch 417 taken 24 times.
✗ Branch 418 not taken.
✓ Branch 419 taken 108 times.
✗ Branch 420 not taken.
✗ Branch 421 not taken.
✓ Branch 422 taken 108 times.
✗ Branch 423 not taken.
✗ Branch 424 not taken.
✗ Branch 425 not taken.
✗ Branch 426 not taken.
✗ Branch 427 not taken.
✗ Branch 428 not taken.
✗ Branch 429 not taken.
✗ Branch 430 not taken.
✗ Branch 431 not taken.
✗ Branch 432 not taken.
✓ Branch 433 taken 120 times.
✗ Branch 434 not taken.
✗ Branch 435 not taken.
✗ Branch 436 not taken.
✓ Branch 437 taken 84 times.
✗ Branch 438 not taken.
✗ Branch 439 not taken.
✓ Branch 440 taken 84 times.
✗ Branch 441 not taken.
✗ Branch 442 not taken.
✗ Branch 443 not taken.
✗ Branch 444 not taken.
✗ Branch 445 not taken.
✗ Branch 446 not taken.
✗ Branch 447 not taken.
✗ Branch 448 not taken.
✗ Branch 449 not taken.
✗ Branch 450 not taken.
✗ Branch 451 not taken.
✗ Branch 452 not taken.
✗ Branch 453 not taken.
✗ Branch 454 not taken.
✗ Branch 455 not taken.
✗ Branch 456 not taken.
✗ Branch 457 not taken.
✗ Branch 458 not taken.
✗ Branch 459 not taken.
✗ Branch 460 not taken.
✗ Branch 461 not taken.
✗ Branch 462 not taken.
✗ Branch 463 not taken.
✗ Branch 464 not taken.
✗ Branch 465 not taken.
✗ Branch 466 not taken.
✗ Branch 467 not taken.
✗ Branch 468 not taken.
✗ Branch 469 not taken.
✗ Branch 470 not taken.
✗ Branch 471 not taken.
✗ Branch 472 not taken.
✗ Branch 473 not taken.
✗ Branch 474 not taken.
✗ Branch 475 not taken.
✗ Branch 476 not taken.
✗ Branch 477 not taken.
✗ Branch 478 not taken.
✗ Branch 479 not taken.
✗ Branch 480 not taken.
✗ Branch 481 not taken.
✗ Branch 482 not taken.
✗ Branch 483 not taken.
✗ Branch 484 not taken.
✗ Branch 485 not taken.
✗ Branch 486 not taken.
✗ Branch 487 not taken.
✗ Branch 488 not taken.
✓ Branch 489 taken 12 times.
✗ Branch 490 not taken.
✗ Branch 491 not taken.
✓ Branch 492 taken 12 times.
✗ Branch 493 not taken.
✗ Branch 494 not taken.
✗ Branch 495 not taken.
✗ Branch 496 not taken.
✗ Branch 497 not taken.
✗ Branch 498 not taken.
✓ Branch 499 taken 5 times.
✗ Branch 500 not taken.
✗ Branch 501 not taken.
✗ Branch 502 not taken.
✓ Branch 503 taken 2 times.
✗ Branch 504 not taken.
✗ Branch 505 not taken.
✓ Branch 506 taken 2 times.
✗ Branch 507 not taken.
✗ Branch 508 not taken.
✗ Branch 509 not taken.
✗ Branch 510 not taken.
✗ Branch 511 not taken.
✗ Branch 512 not taken.
✗ Branch 513 not taken.
✗ Branch 514 not taken.
✗ Branch 515 not taken.
✗ Branch 516 not taken.
✗ Branch 517 not taken.
✗ Branch 518 not taken.
✓ Branch 519 taken 780 times.
✗ Branch 520 not taken.
✗ Branch 521 not taken.
✓ Branch 522 taken 780 times.
✗ Branch 523 not taken.
✗ Branch 524 not taken.
✓ Branch 525 taken 834 times.
✗ Branch 526 not taken.
✗ Branch 527 not taken.
✓ Branch 528 taken 834 times.
✗ Branch 529 not taken.
✗ Branch 530 not taken.
✗ Branch 531 not taken.
✗ Branch 532 not taken.
✗ Branch 533 not taken.
✗ Branch 534 not taken.
✗ Branch 535 not taken.
✗ Branch 536 not taken.
✗ Branch 537 not taken.
✗ Branch 538 not taken.
✗ Branch 539 not taken.
✗ Branch 540 not taken.
✗ Branch 541 not taken.
✗ Branch 542 not taken.
✗ Branch 543 not taken.
✗ Branch 544 not taken.
✗ Branch 545 not taken.
✗ Branch 546 not taken.
✗ Branch 547 not taken.
✗ Branch 548 not taken.
✗ Branch 549 not taken.
✗ Branch 550 not taken.
✗ Branch 551 not taken.
✗ Branch 552 not taken.
✗ Branch 553 not taken.
✗ Branch 554 not taken.
✗ Branch 555 not taken.
✗ Branch 556 not taken.
✗ Branch 557 not taken.
✗ Branch 558 not taken.
✗ Branch 559 not taken.
✗ Branch 560 not taken.
✓ Branch 561 taken 960 times.
✗ Branch 562 not taken.
✗ Branch 563 not taken.
✓ Branch 564 taken 960 times.
✗ Branch 565 not taken.
✗ Branch 566 not taken.
✗ Branch 567 not taken.
✗ Branch 568 not taken.
✗ Branch 569 not taken.
✗ Branch 570 not taken.
✗ Branch 571 not taken.
✗ Branch 572 not taken.
✗ Branch 573 not taken.
✗ Branch 574 not taken.
✗ Branch 575 not taken.
✗ Branch 576 not taken.
✗ Branch 577 not taken.
✗ Branch 578 not taken.
✗ Branch 579 not taken.
✗ Branch 580 not taken.
✗ Branch 581 not taken.
✗ Branch 582 not taken.
✗ Branch 583 not taken.
✗ Branch 584 not taken.
✗ Branch 585 not taken.
✗ Branch 586 not taken.
✓ Branch 587 taken 1391 times.
✗ Branch 588 not taken.
✓ Branch 589 taken 2 times.
✗ Branch 590 not taken.
✓ Branch 591 taken 97 times.
✓ Branch 592 taken 2 times.
✗ Branch 593 not taken.
✗ Branch 594 not taken.
✗ Branch 595 not taken.
✗ Branch 596 not taken.
✗ Branch 597 not taken.
✗ Branch 598 not taken.
✗ Branch 599 not taken.
✗ Branch 600 not taken.
✗ Branch 601 not taken.
✗ Branch 602 not taken.
✗ Branch 603 not taken.
✗ Branch 604 not taken.
✗ Branch 605 not taken.
✗ Branch 606 not taken.
✗ Branch 607 not taken.
✗ Branch 608 not taken.
✗ Branch 609 not taken.
✗ Branch 610 not taken.
✗ Branch 611 not taken.
✗ Branch 612 not taken.
✗ Branch 613 not taken.
✗ Branch 614 not taken.
✓ Branch 615 taken 2 times.
✗ Branch 616 not taken.
✗ Branch 617 not taken.
✓ Branch 618 taken 2 times.
✗ Branch 619 not taken.
✗ Branch 620 not taken.
✓ Branch 621 taken 282 times.
✗ Branch 622 not taken.
✗ Branch 623 not taken.
✓ Branch 624 taken 282 times.
✗ Branch 625 not taken.
✗ Branch 626 not taken.
✗ Branch 627 not taken.
✗ Branch 628 not taken.
✗ Branch 629 not taken.
✗ Branch 630 not taken.
✗ Branch 631 not taken.
✗ Branch 632 not taken.
✗ Branch 633 not taken.
✗ Branch 634 not taken.
✗ Branch 635 not taken.
✗ Branch 636 not taken.
✓ Branch 637 taken 5 times.
✗ Branch 638 not taken.
✗ Branch 639 not taken.
✓ Branch 640 taken 5 times.
✗ Branch 641 not taken.
✗ Branch 642 not taken.
✗ Branch 643 not taken.
✗ Branch 644 not taken.
✗ Branch 645 not taken.
✗ Branch 646 not taken.
✓ Branch 647 taken 1512 times.
✗ Branch 648 not taken.
✗ Branch 649 not taken.
✗ Branch 650 not taken.
✓ Branch 651 taken 26 times.
✗ Branch 652 not taken.
✗ Branch 653 not taken.
✗ Branch 654 not taken.
✗ Branch 655 not taken.
✗ Branch 656 not taken.
✓ Branch 657 taken 4 times.
✗ Branch 658 not taken.
✗ Branch 659 not taken.
✓ Branch 660 taken 4 times.
✓ Branch 661 taken 3 times.
✗ Branch 662 not taken.
✗ Branch 663 not taken.
✓ Branch 664 taken 3 times.
✗ Branch 665 not taken.
✗ Branch 666 not taken.
✗ Branch 667 not taken.
✗ Branch 668 not taken.
✗ Branch 669 not taken.
✗ Branch 670 not taken.
✗ Branch 671 not taken.
✗ Branch 672 not taken.
✗ Branch 673 not taken.
✗ Branch 674 not taken.
✗ Branch 675 not taken.
✗ Branch 676 not taken.
✗ Branch 677 not taken.
✗ Branch 678 not taken.
✓ Branch 679 taken 16 times.
✗ Branch 680 not taken.
✗ Branch 681 not taken.
✓ Branch 682 taken 16 times.
✗ Branch 683 not taken.
✗ Branch 684 not taken.
✗ Branch 685 not taken.
✗ Branch 686 not taken.
✗ Branch 687 not taken.
✗ Branch 688 not taken.
✗ Branch 689 not taken.
✗ Branch 690 not taken.
✓ Branch 691 taken 204 times.
✗ Branch 692 not taken.
✗ Branch 693 not taken.
✓ Branch 694 taken 204 times.
✗ Branch 695 not taken.
✗ Branch 696 not taken.
✗ Branch 697 not taken.
✗ Branch 698 not taken.
✗ Branch 699 not taken.
✗ Branch 700 not taken.
✗ Branch 701 not taken.
✓ Branch 703 taken 31 times.
✗ Branch 704 not taken.
✓ Branch 706 taken 31 times.
✗ Branch 707 not taken.
✗ Branch 708 not taken.
✗ Branch 709 not taken.
✗ Branch 710 not taken.
✗ Branch 711 not taken.
✗ Branch 712 not taken.
✗ Branch 713 not taken.
✓ Branch 715 taken 144 times.
✗ Branch 716 not taken.
✓ Branch 718 taken 144 times.
✗ Branch 719 not taken.
✗ Branch 720 not taken.
✗ Branch 721 not taken.
✗ Branch 722 not taken.
✓ Branch 723 taken 1 times.
✗ Branch 724 not taken.
✗ Branch 725 not taken.
✗ Branch 727 not taken.
✗ Branch 728 not taken.
✗ Branch 730 not taken.
✗ Branch 731 not taken.
✗ Branch 732 not taken.
✓ Branch 733 taken 480 times.
✗ Branch 734 not taken.
✗ Branch 735 not taken.
✓ Branch 736 taken 480 times.
✗ Branch 737 not taken.
✗ Branch 738 not taken.
✗ Branch 739 not taken.
✗ Branch 740 not taken.
✗ Branch 741 not taken.
✗ Branch 742 not taken.
✗ Branch 743 not taken.
✗ Branch 744 not taken.
✗ Branch 745 not taken.
✗ Branch 746 not taken.
✗ Branch 747 not taken.
✗ Branch 748 not taken.
✗ Branch 749 not taken.
✗ Branch 750 not taken.
✗ Branch 751 not taken.
✗ Branch 752 not taken.
✗ Branch 753 not taken.
✗ Branch 754 not taken.
✗ Branch 755 not taken.
✗ Branch 756 not taken.
✓ Branch 757 taken 1176 times.
✗ Branch 758 not taken.
✗ Branch 759 not taken.
✓ Branch 760 taken 1176 times.
✗ Branch 761 not taken.
✗ Branch 762 not taken.
✓ Branch 763 taken 720 times.
✗ Branch 764 not taken.
✗ Branch 765 not taken.
✓ Branch 766 taken 720 times.
✗ Branch 767 not taken.
✗ Branch 768 not taken.
✗ Branch 769 not taken.
✗ Branch 770 not taken.
✗ Branch 771 not taken.
✗ Branch 772 not taken.
✗ Branch 773 not taken.
✗ Branch 774 not taken.
✗ Branch 775 not taken.
✗ Branch 776 not taken.
✗ Branch 777 not taken.
✗ Branch 778 not taken.
✗ Branch 779 not taken.
✗ Branch 780 not taken.
✗ Branch 781 not taken.
✗ Branch 782 not taken.
✗ Branch 783 not taken.
✗ Branch 784 not taken.
✗ Branch 785 not taken.
✗ Branch 786 not taken.
✓ Branch 787 taken 1728 times.
✗ Branch 788 not taken.
✗ Branch 789 not taken.
✓ Branch 790 taken 1728 times.
✗ Branch 791 not taken.
✗ Branch 792 not taken.
✓ Branch 793 taken 252 times.
✗ Branch 794 not taken.
✗ Branch 795 not taken.
✓ Branch 796 taken 252 times.
✗ Branch 797 not taken.
✗ Branch 798 not taken.
✗ Branch 799 not taken.
✗ Branch 800 not taken.
✗ Branch 801 not taken.
✓ Branch 803 taken 69 times.
✗ Branch 804 not taken.
✓ Branch 806 taken 69 times.
✗ Branch 807 not taken.
✗ Branch 809 not taken.
✗ Branch 810 not taken.
✗ Branch 812 not taken.
✗ Branch 813 not taken.
|
97922 | return visitor(serialization.template as_span_of<T>()); |
79 | 146880 | }); | |
80 | } | ||
81 | |||
82 | //! Export the field values into the provided range, resize if necessary, and return it | ||
83 | template<std::ranges::range R> requires(Concepts::Scalar<MDRangeValueType<R>>) | ||
84 | 17513 | decltype(auto) export_to(R&& output_range) const { | |
85 | 17513 | return _export_to<true>(std::forward<R>(output_range)); | |
86 | } | ||
87 | |||
88 | //! Export the field values into the provided range without resizing (given range must be large enough) | ||
89 | template<std::ranges::range R> requires(Concepts::Scalar<MDRangeValueType<R>>) | ||
90 | 2 | decltype(auto) export_to(R&& output_range, DisableResize) const { | |
91 | 2 | return _export_to<false>(std::forward<R>(output_range)); | |
92 | } | ||
93 | |||
94 | //! Export the field as a scalar (works only if the field is a scalar field) | ||
95 | template<Concepts::Scalar S> | ||
96 | 6453 | void export_to(S& out) const { | |
97 |
1/2✓ Branch 1 taken 3256 times.
✗ Branch 2 not taken.
|
6453 | const auto my_layout = layout(); |
98 |
1/2✓ Branch 1 taken 3256 times.
✗ Branch 2 not taken.
|
6453 | const auto serialization = serialized(); |
99 |
3/4✓ Branch 1 taken 3256 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 3254 times.
|
6453 | if (my_layout.number_of_entries() != 1) |
100 |
1/2✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
|
2 | throw TypeError("Field cannot be exported into a scalar"); |
101 |
1/2✓ Branch 1 taken 3254 times.
✗ Branch 2 not taken.
|
13073 | visit_field_values([&] <typename T> (std::span<const T> data) { |
102 | 3254 | out = static_cast<S>(data[0]); | |
103 | }); | ||
104 | 6455 | } | |
105 | |||
106 | //! Export the field as a scalar (works only if the field is a scalar field) | ||
107 | template<Concepts::Scalar S> | ||
108 | 6383 | S export_to() const { | |
109 | S out; | ||
110 |
2/2✓ Branch 1 taken 3219 times.
✓ Branch 2 taken 1 times.
|
6383 | export_to(out); |
111 | 6382 | return out; | |
112 | } | ||
113 | |||
114 | //! Export the field into a resizable range (e.g. std::vector) | ||
115 | template<Concepts::ResizableMDRange R> | ||
116 | requires(Concepts::StaticallySizedMDRange<std::ranges::range_value_t<R>> or | ||
117 | Concepts::Scalar<std::ranges::range_value_t<R>>) | ||
118 | 16412 | R export_to() const { | |
119 |
2/2✓ Branch 2 taken 8218 times.
✓ Branch 3 taken 2 times.
|
16412 | return export_to(R{}); |
120 | } | ||
121 | |||
122 | private: | ||
123 | DynamicPrecision _prec; | ||
124 | |||
125 | virtual MDLayout _layout() const = 0; | ||
126 | virtual DynamicPrecision _precision() const = 0; | ||
127 | virtual Serialization _serialized() const = 0; | ||
128 | |||
129 | //! Export the field values into the provided range and return it | ||
130 | template<bool enable_resize, std::ranges::range R> requires(Concepts::Scalar<MDRangeValueType<R>>) | ||
131 | 17517 | decltype(auto) _export_to(R&& output_range) const { | |
132 |
1/2✓ Branch 1 taken 8771 times.
✗ Branch 2 not taken.
|
17517 | const auto my_layout = layout(); |
133 | |||
134 | if constexpr (Concepts::ResizableMDRange<R> && enable_resize) { | ||
135 |
1/2✓ Branch 1 taken 8591 times.
✗ Branch 2 not taken.
|
17157 | const auto num_scalars = my_layout.number_of_entries(); |
136 |
2/4✓ Branch 1 taken 8591 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 8591 times.
✗ Branch 5 not taken.
|
17157 | const auto num_sub_scalars = get_md_layout<std::ranges::range_value_t<R>>().number_of_entries(); |
137 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 8588 times.
|
17157 | if (num_scalars%num_sub_scalars != 0) |
138 |
1/2✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
|
6 | throw TypeError( |
139 | "Cannot export the field into the given range type. " | ||
140 | "Number of entries in the field is not divisible by the " | ||
141 | "number of entries in the value_type of the provided range." | ||
142 | ); | ||
143 | |||
144 |
1/2✓ Branch 1 taken 645 times.
✗ Branch 2 not taken.
|
17151 | output_range.resize( |
145 | num_scalars/num_sub_scalars, | ||
146 |
2/3✓ Branch 1 taken 533 times.
✓ Branch 2 taken 7943 times.
✗ Branch 3 not taken.
|
17151 | DefaultValue<std::ranges::range_value_t<R>>::get() |
147 | ); | ||
148 | } else { | ||
149 |
1/2✓ Branch 1 taken 180 times.
✗ Branch 2 not taken.
|
360 | const auto output_range_layout = get_md_layout(output_range); |
150 |
4/6✓ Branch 1 taken 180 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 180 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 179 times.
|
360 | if (output_range_layout.number_of_entries() < my_layout.number_of_entries()) |
151 |
1/2✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
|
4 | throw SizeError( |
152 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
4 | std::string{"Cannot fill the given range. Too few entries. "} + |
153 |
5/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
|
8 | "Number of field entries: '" + std::to_string(my_layout.number_of_entries()) + "'; " + |
154 |
4/8✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
|
8 | "Number of range entries: '" + std::to_string(output_range_layout.number_of_entries()) + "'" |
155 | ); | ||
156 | 360 | } | |
157 | |||
158 | 17509 | std::size_t offset = 0; | |
159 |
1/2✓ Branch 1 taken 8767 times.
✗ Branch 2 not taken.
|
35093 | visit_field_values([&] <typename T> (std::span<const T> data) { |
160 | 8767 | _export_to(output_range, data, offset); | |
161 | }); | ||
162 | |||
163 | 35018 | return std::forward<R>(output_range); | |
164 | 17517 | } | |
165 | |||
166 | template<std::ranges::range R, Concepts::Scalar T> | ||
167 | 55042 | void _export_to(R& range, | |
168 | std::span<const T> data, | ||
169 | std::size_t& offset) const { | ||
170 | if constexpr (mdrange_dimension<R> > 1) | ||
171 |
1/2✓ Branch 1 taken 533 times.
✗ Branch 2 not taken.
|
38574 | std::ranges::for_each(range, [&] (std::ranges::range auto& sub_range) { |
172 | 18754 | _export_to(sub_range, data, offset); | |
173 | }); | ||
174 | else | ||
175 |
3/5✓ Branch 1 taken 178 times.
✓ Branch 2 taken 26810 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 178 times.
✗ Branch 5 not taken.
|
53976 | std::ranges::for_each_n( |
176 | std::ranges::begin(range), | ||
177 |
1/2✓ Branch 2 taken 178 times.
✗ Branch 3 not taken.
|
53976 | std::min(Ranges::size(range), data.size() - offset), |
178 | 566554 | [&] <typename V> (V& value) { | |
179 | 283277 | value = static_cast<V>(data[offset++]); | |
180 | } | ||
181 | ); | ||
182 | 55042 | } | |
183 | }; | ||
184 | |||
185 | //! Pointer type used by writers/readers for fields | ||
186 | using FieldPtr = std::shared_ptr<const Field>; | ||
187 | |||
188 | //! Factory function for field pointers | ||
189 | template<typename F> requires( | ||
190 | std::derived_from<std::remove_cvref_t<F>, Field> and | ||
191 | !std::is_lvalue_reference_v<F>) | ||
192 | 151344 | FieldPtr make_field_ptr(F&& f) { | |
193 |
1/2✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
|
151344 | return std::make_shared<std::add_const_t<F>>(std::forward<F>(f)); |
194 | } | ||
195 | |||
196 | //! \} group Common | ||
197 | |||
198 | } // namespace GridFormat | ||
199 | |||
200 | #endif // GRIDFORMAT_COMMON_FIELD_HPP_ | ||
201 |