preCICE
v3.1.2
Loading...
Searching...
No Matches
src
mesh
RangeAccessor.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include <boost/iterator/iterator_facade.hpp>
4
5
namespace
precice
{
6
namespace
mesh {
14
template
<
typename
Source,
typename
Value>
15
class
IndexRangeIterator
:
public
boost::iterator_facade<
16
IndexRangeIterator<Source, const Value>,
17
const Value,
18
boost::random_access_traversal_tag> {
19
public
:
20
IndexRangeIterator
() =
default
;
21
IndexRangeIterator
(Source *src,
size_t
index
)
22
:
src_
(src),
idx_
(
index
) {}
23
24
const
Value &
dereference
()
const
25
{
26
using
Coord =
decltype
(
src_
->vertex(
idx_
).rawCoords());
27
static_assert
(
28
std::is_reference<Coord>::value
,
29
"Coordinate type must be a reference!"
);
30
static_assert
(
31
std::is_convertible<Coord, Value>::value
,
32
"Exposed and accessed types must match!"
);
33
return
static_cast<
const
Value &
>
(
src_
->vertex(
idx_
).rawCoords());
34
}
35
36
size_t
equal
(
const
IndexRangeIterator<Source, Value>
&other)
const
37
{
38
return
other.
idx_
==
idx_
&& other.
src_
==
src_
;
39
}
40
41
void
increment
()
42
{
43
++
idx_
;
44
}
45
46
void
decrement
()
47
{
48
--
idx_
;
49
}
50
51
void
advance
(
size_t
n)
52
{
53
idx_
+= n;
54
}
55
56
size_t
distance_to
(
const
IndexRangeIterator<Source, Value>
&other)
const
57
{
58
return
other.
idx_
-
idx_
;
59
}
60
61
private
:
62
Source *
src_
{
nullptr
};
63
size_t
idx_
{0};
64
};
65
66
}
// namespace mesh
67
}
// namespace precice
index
unsigned int index
Definition
SocketCommunication.cpp:717
precice::mesh::IndexRangeIterator
Definition
RangeAccessor.hpp:18
precice::mesh::IndexRangeIterator::distance_to
size_t distance_to(const IndexRangeIterator< Source, Value > &other) const
Definition
RangeAccessor.hpp:56
precice::mesh::IndexRangeIterator::equal
size_t equal(const IndexRangeIterator< Source, Value > &other) const
Definition
RangeAccessor.hpp:36
precice::mesh::IndexRangeIterator::increment
void increment()
Definition
RangeAccessor.hpp:41
precice::mesh::IndexRangeIterator::idx_
size_t idx_
the current index to access
Definition
RangeAccessor.hpp:63
precice::mesh::IndexRangeIterator::dereference
const Value & dereference() const
Definition
RangeAccessor.hpp:24
precice::mesh::IndexRangeIterator::IndexRangeIterator
IndexRangeIterator(Source *src, size_t index)
Definition
RangeAccessor.hpp:21
precice::mesh::IndexRangeIterator::decrement
void decrement()
Definition
RangeAccessor.hpp:46
precice::mesh::IndexRangeIterator::advance
void advance(size_t n)
Definition
RangeAccessor.hpp:51
precice::mesh::IndexRangeIterator::IndexRangeIterator
IndexRangeIterator()=default
precice::mesh::IndexRangeIterator::src_
Source * src_
the source to access
Definition
RangeAccessor.hpp:62
std::is_convertible
std::is_reference
precice
Main namespace of the precice library.
Definition
Acceleration.cpp:5