25 #ifndef INCLUDED_TypeSafeId_h_GUID_137CA336_382A_4796_7735_4521F02D5AC2 26 #define INCLUDED_TypeSafeId_h_GUID_137CA336_382A_4796_7735_4521F02D5AC2 46 namespace typesafeid_traits {
49 template <
typename Tag>
struct WrappedType {
typedef uint32_t type; };
55 enum { value =
true };
67 enum { value =
false };
82 typedef typename WrappedType<Tag>::type wrapped_type;
83 static wrapped_type
get() {
84 return std::numeric_limits<wrapped_type>::max();
110 typedef typename typesafeid_traits::WrappedType<Tag>::type
wrapped_type;
126 bool empty()
const {
return m_val == sentinel(); }
129 wrapped_type
value()
const {
return m_val; }
143 typedef typename typesafeid_traits::WrappedType<Tag>::type
wrapped_type;
152 wrapped_type &
value() {
return Base::m_val; }
161 typedef typename typesafeid_traits::ComputeBaseClass<Tag>::type
Base;
162 typedef typename typesafeid_traits::WrappedType<Tag>::type wrapped_type;
164 explicit TypeSafeId(wrapped_type val) : Base(val) {}
170 template <
typename Tag>
172 return a.value() == b.value();
177 template <
typename Tag>
179 return a.value() != b.value();
185 #endif // INCLUDED_TypeSafeId_h_GUID_137CA336_382A_4796_7735_4521F02D5AC2 Definition: gtest_unittest.cc:5031
Class for your specialization of ProvideReferenceAccessor to inherit from if you want to provide a no...
Definition: TypeSafeId.h:54
Definition: RunLoopManager.h:42
Header wrapping the C99 standard stdint header.
The main namespace for all C++ elements of the framework, internal and external.
Definition: namespace_osvr.dox:3
wrapped_type & value()
Non-const reference accessor to the (non-type-safe!) wrapped value - only available if specifically p...
Definition: TypeSafeId.h:152
Quick C++11-aligned conditional (if/then/elese) implementation.
Definition: BasicTypeTraits.h:48
bool operator!=(TypeSafeId< Tag > const a, TypeSafeId< Tag > const b)
Inequality comparison operator for type-safe IDs.
Definition: TypeSafeId.h:178
Header containing some basic, C++11-aligned implementations of functionality provided by <type_traits...
static type invalid()
Static factory method to return an invalid/empty ID.
Definition: TypeSafeId.h:113
Definition: TypeSafeId.h:41
typesafeid_traits::WrappedType< Tag >::type wrapped_type
The contained/wrapped type.
Definition: TypeSafeId.h:110
static wrapped_type sentinel()
Utility function to access the SentinelValue trait.
Definition: TypeSafeId.h:133
TypeSafeIdBase(wrapped_type val)
Explicit constructor from the wrapped type.
Definition: TypeSafeId.h:120
typesafeid_traits::ComputeBaseClass< Tag >::type Base
The implementation base.
Definition: TypeSafeId.h:161
Explicitly specialize for your tag type if you want a different signal value for invalid/empty: defau...
Definition: TypeSafeId.h:81
TypeSafeId< Tag > type
The "public" type of the current class.
Definition: TypeSafeId.h:107
TypeSafeId< Tag > type
The type of the current class.
Definition: TypeSafeId.h:159
Selects one of the base classes based on whether we need that reference accessor. ...
Definition: TypeSafeId.h:72
wrapped_type value() const
Read-only accessor to the (non-type-safe!) wrapped value.
Definition: TypeSafeId.h:129
bool empty() const
Check whether the ID is empty/invalid.
Definition: TypeSafeId.h:126
Explicitly specialize this for your tag type to derive from ProvideLValueReferenceAccessor if you wan...
Definition: TypeSafeId.h:66
Definition: TypeSafeId.h:43
bool operator==(TypeSafeId< Tag > const a, TypeSafeId< Tag > const b)
Equality comparison operator for type-safe IDs.
Definition: TypeSafeId.h:171
Explicitly specialize for your tag type if you want a different underlying type.
Definition: TypeSafeId.h:49
TypeSafeIdBase()
Default constructor which will set m_val to the empty/invalid value.
Definition: TypeSafeId.h:117
TypeSafeIdBase(TypeSafeIdBase const &other)
Copy constructor.
Definition: TypeSafeId.h:123
A generic typesafe (as long as you use differing tag types) wrapper for identifiers (typically intege...
Definition: TypeSafeId.h:42