11 class PairElementToken;
29 bool isValid()
const {
return token_ !=
nullptr; }
32 void invalidate() { token_ =
nullptr; }
34 PairElementToken * token_;
36 friend PairElementToken;
54 other.otherPairElement_ =
nullptr;
56 otherPairElement_->notifyMove(
this);
65 h.token_->otherPairElement_ =
this;
74 otherPairElement_->notifyDeath();
75 otherPairElement_ = other.otherPairElement_;
76 other.otherPairElement_ =
nullptr;
78 otherPairElement_->notifyMove(
this);
90 otherPairElement_->notifyDeath();
91 otherPairElement_ = h.token_;
92 h.token_->otherPairElement_ =
this;
100 otherPairElement_->notifyDeath();
107 throw std::runtime_error(
"Can only pair if both tokens are unpaired.");
108 otherPairElement_ = &other;
109 other.otherPairElement_ =
this;
113 bool isPaired()
const {
return otherPairElement_ !=
nullptr; }
122 throw std::runtime_error(
"This token is not paired.");
123 return *otherPairElement_;
131 other->otherPairElement_ =
this;
134 void notifyMove(
PairElementToken * newAddress) { otherPairElement_ = newAddress; }
136 void notifyDeath() { otherPairElement_ =
nullptr; }
142 { assert(!t.isPaired() &&
"Input token is already paired."); }
Definition: PairElementToken.h:19
PairElementTokenHandle & operator=(PairElementTokenHandle &&)=delete
PairElementTokenHandle()=delete
bool isValid() const
Definition: PairElementToken.h:29
PairElementTokenHandle(PairElementTokenHandle &&)=delete
PairElementTokenHandle(const PairElementTokenHandle &)=delete
PairElementTokenHandle & operator=(const PairElementTokenHandle &)=delete
Definition: PairElementToken.h:45
PairElementToken(const PairElementToken &)=delete
PairElementToken(PairElementTokenHandle &&h) noexcept
Definition: PairElementToken.h:62
PairElementToken & operator=(PairElementTokenHandle &&h) noexcept
Definition: PairElementToken.h:85
PairElementToken & operator=(PairElementToken &&other) noexcept
Definition: PairElementToken.h:70
PairElementToken(PairElementToken &&other) noexcept
Definition: PairElementToken.h:52
PairElementToken() noexcept
Definition: PairElementToken.h:47
void pairWith(PairElementToken &other)
Definition: PairElementToken.h:104
bool isPaired() const
Definition: PairElementToken.h:113
bool isPairedWith(const PairElementToken &other) const
Definition: PairElementToken.h:116
PairElementToken & operator=(const PairElementToken &)=delete
const PairElementToken & otherPairElement() const
Definition: PairElementToken.h:119
~PairElementToken()
Definition: PairElementToken.h:97
Definition: CallbackManager.h:12