16 #ifndef SURGSIM_DATASTRUCTURES_OPTIONALVALUE_H 17 #define SURGSIM_DATASTRUCTURES_OPTIONALVALUE_H 23 namespace DataStructures
40 explicit OptionalValue(
const T& value) : m_hasValue(true), m_value(value)
50 m_value = other.m_value;
80 SURGSIM_ASSERT(m_hasValue) <<
"Tried to fetch a value from an invalid OptionalValue";
91 SURGSIM_ASSERT(m_hasValue) <<
"Tried to fetch a value from an invalid OptionalValue";
100 if (m_hasValue ==
true && rhs.m_hasValue ==
true)
102 return m_value == rhs.m_value;
106 return m_hasValue == rhs.m_hasValue;
118 return m_value == rhs;
131 return !(*
this == rhs);
139 return !(*
this == rhs);
147 m_hasValue = rhs.m_hasValue;
150 m_value = rhs.m_value;
const T & operator*() const
Gets the value.
Definition: OptionalValue.h:89
Wraps glewInit() to separate the glew opengl definitions from the osg opengl definitions only imgui n...
Definition: AddRandomSphereBehavior.cpp:36
bool operator!=(const OptionalValue< T > &rhs) const
Inequality operator.
Definition: OptionalValue.h:129
void invalidate()
Mark this object as invalid.
Definition: OptionalValue.h:62
OptionalValue(const T &value)
Constructor that assigns a value.
Definition: OptionalValue.h:40
Container class that can indicate whether the object has been assigned a value.
Definition: OptionalValue.h:29
#define SURGSIM_ASSERT(condition)
Assert that condition is true.
Definition: Assert.h:77
OptionalValue()
Default Constructor, no value.
Definition: OptionalValue.h:34
bool operator!=(const T &rhs) const
Inequality operator.
Definition: OptionalValue.h:137
OptionalValue & operator=(const OptionalValue &rhs)
Assignment operator.
Definition: OptionalValue.h:145
OptionalValue(const OptionalValue &other)
Copy constructor.
Definition: OptionalValue.h:46
The header that provides the assertion API.
OptionalValue & operator=(const T &rhs)
Assignment operator from template type, after this hasValue() is true even if the right hand side was...
Definition: OptionalValue.h:159
bool operator==(const T &rhs) const
Equality operator.
Definition: OptionalValue.h:114
bool hasValue() const
Query if this object has been assigned a value.
Definition: OptionalValue.h:56
void setValue(const T &val)
Set the value of this object, and mark it as valid.
Definition: OptionalValue.h:69
bool operator==(const OptionalValue< T > &rhs) const
Equality operator.
Definition: OptionalValue.h:98
const T & getValue() const
Gets the value.
Definition: OptionalValue.h:78