27 inline ETeidManager_InvalidNumberOfRangeBits::ETeidManager_InvalidNumberOfRangeBits(){
28 setText(
"The range bits must be between 0 and 7");
35 setTextf(
"The TEID range value must be between %u and %u", min, max);
49 if (bits_ < 0 || bits_ > 7)
50 throw ETeidManager_InvalidNumberOfRangeBits();
53 Int maxRange = (bits_ == 0) ? 0 : ((1 << (bits_)) - 1);
55 if (rangeValue > maxRange)
58 min_ =
static_cast<ULongLong
>(rangeValue) << ((
sizeof(ULong)*8) - bits_);
59 max_ = ((1ull << (32 - bits_)) - 1) | min_;
68 ULong
min()
const {
return min_; }
69 ULong
max()
const {
return max_; }
74 unsigned long long nxt;
75 while ((nxt=next_.fetch_add(1)) > max_)
76 next_.compare_exchange_strong(++nxt, min_);
77 return static_cast<ULong
>(nxt);
81 std::atomic_ullong next_;
Int rangeValue() const
Definition: eteid.h:67
ETeidManager(Int rangeBits=0, Int rangeValue=0)
Definition: eteid.h:45
Void setTextf(cpStr pszFormat,...)
Sets the text associated with this error.
Definition: eerror.cpp:29
Defines base class for exceptions and declaration helper macros.
The base class for exceptions derived from std::exception.
Definition: eerror.h:94
ULong alloc()
Definition: eteid.h:71
ULong min() const
Definition: eteid.h:68
ULong max() const
Definition: eteid.h:69
Int rangeBits() const
Definition: eteid.h:66
#define DECLARE_ERROR_ADVANCED(__e__)
Declares exception class derived from EError with no constructor parameters and developer defined con...
Definition: eerror.h:61
ETeidManager_InvalidRangeValue(UChar min, UChar max)
Definition: eteid.h:34