DASH  0.3.0
CoEventIter.h
1 #ifndef DASH__COARRAY__COEVENTITER_H
2 #define DASH__COARRAY__COEVENTITER_H
3 
4 #include <iterator>
5 
6 #include <dash/Team.h>
7 #include <dash/Atomic.h>
8 #include <dash/coarray/CoEventRef.h>
9 
10 namespace dash {
11 namespace coarray {
12 
13 class CoEventIter {
14 private:
15  using self_t = CoEventIter;
16  //TODO rko: fix this hard coded information it is related to Coevent
17  //which uses dash::Array internally
18  using globmem_t =
21 
22 public:
23  using difference_type = typename gptr_t::gptrdiff_t;
24  using value_type = CoEventRef;
25  using pointer = CoEventRef *;
26  using reference = CoEventRef &;
27  using iterator_category = std::random_access_iterator_tag;
28 
29 public:
30 
31  explicit CoEventIter(
32  const gptr_t & pos,
33  Team & team = dash::Team::Null())
34  : _team(team),
35  _gptr(pos) {}
36 
37  inline Team & team() {
38  return _team;
39  }
40  inline value_type operator[] (int pos) const {
41  return value_type(_gptr + pos, _team);
42  }
43 
44  inline value_type operator* () const {
45  return value_type(_gptr, _team);
46  }
47  /*
48  * Comparison operators
49  */
50  inline bool operator <(const self_t & other) const noexcept {
51  return _gptr < other._gptr;
52  }
53  inline bool operator >(const self_t & other) const noexcept {
54  return _gptr > other._gptr;
55  }
56  inline bool operator <=(const self_t & other) const noexcept {
57  return _gptr <= other._gptr;
58  }
59  inline bool operator >=(const self_t & other) const noexcept {
60  return _gptr >= other._gptr;
61  }
62  inline bool operator ==(const self_t & other) const noexcept {
63  return (_gptr == other._gptr) && (_team == other._team);
64  }
65  inline bool operator !=(const self_t & other) const noexcept {
66  return !(*this == other);
67  }
68  /*
69  * Arith. operators
70  */
71  inline self_t & operator +=(int i) noexcept {
72  _gptr += i;
73  return *this;
74  }
75  inline self_t & operator -=(int i) noexcept {
76  _gptr -= i;
77  return *this;
78  }
79  inline self_t & operator ++() noexcept {
80  ++_gptr;
81  return *this;
82  }
83  inline self_t operator ++(int) noexcept {
84  auto oldptr = _gptr++;
85  return self_t(oldptr);
86  }
87  inline self_t & operator --() noexcept{
88  --_gptr;
89  return *this;
90  }
91  inline self_t operator --(int) noexcept {
92  auto oldptr = _gptr--;
93  return self_t(oldptr);
94  }
95  inline self_t operator +(int i) const noexcept {
96  return self_t(_gptr + i);
97  }
98  inline self_t operator -(int i) const noexcept {
99  return self_t(_gptr - i);
100  }
101 
102 private:
103  Team & _team = dash::Team::Null();
104  gptr_t _gptr;
105 };
106 
107 } // namespace coarray
108 } // namespace dash
109 
110 
111 #endif /* DASH__COARRAY__COEVENTITER_H */
This class is a simple memory pool which holds allocates elements of size ValueType.
Definition: AllOf.h:8
A Team instance specifies a subset of all available units.
Definition: Team.h:41
static Team & Null()
The invariant Team instance representing an undefined team.
Definition: Team.h:229