The Sparta Modeling Framework
Loading...
Searching...
No Matches
sparta::utils::ValidValue< T > Class Template Reference

Provides a wrapper around a value to ensure that the value is assigned. More...

#include <ValidValue.hpp>

Public Types

typedef T value_type
 Convenient typedef for the value type.
 

Public Member Functions

 ValidValue ()
 Construct with no validity (not valid, uninitialized)
 
template<typename ... ArgsT>
 ValidValue (ArgsT &&...args)
 Construct with a valid starting value.
 
 ValidValue (ValidValue &)=default
 
 ValidValue (ValidValue &&v)
 Allow moves.
 
 ValidValue (const ValidValue &)=default
 Allow copies.
 
ValidValueoperator= (const ValidValue &)=default
 Allow assignments.
 
ValidValueoperator= (ValidValue &&)=default
 
value_type operator= (const value_type &val)
 Assignment.
 
value_type operator= (value_type &&val)
 Assignment.
 
bool operator== (const value_type &val) const
 Compare equal.
 
bool operator!= (const value_type &val) const
 Compare not equal.
 
bool isValid () const
 Is this value valid.
 
 operator const value_type & () const
 Convert the ValidValue to the object it is.
 
 operator value_type & ()
 Convert the ValidValue to the object it is.
 
const value_typegetValue () const
 Get the value - const version.
 
value_typegetValue ()
 Get the value.
 
void clearValid ()
 Clear the validity of this object.
 

Detailed Description

template<typename T>
class sparta::utils::ValidValue< T >

Provides a wrapper around a value to ensure that the value is assigned.

Definition at line 25 of file ValidValue.hpp.

Member Typedef Documentation

◆ value_type

template<typename T >
typedef T sparta::utils::ValidValue< T >::value_type

Convenient typedef for the value type.

Definition at line 29 of file ValidValue.hpp.

Constructor & Destructor Documentation

◆ ValidValue() [1/4]

template<typename T >
sparta::utils::ValidValue< T >::ValidValue ( )
inline

Construct with no validity (not valid, uninitialized)

Definition at line 32 of file ValidValue.hpp.

◆ ValidValue() [2/4]

template<typename T >
template<typename ... ArgsT>
sparta::utils::ValidValue< T >::ValidValue ( ArgsT &&...  args)
inline

Construct with a valid starting value.

Parameters
argsThe value to start with

This constructor will not be used when constructing with another sparta::ValidValue. The const/non-const copy constructors below should/will be used instead

Definition at line 46 of file ValidValue.hpp.

◆ ValidValue() [3/4]

template<typename T >
sparta::utils::ValidValue< T >::ValidValue ( ValidValue< T > &  )
default

Allow copies of direct ValidValue – non-const. This is to prevent the variatic template constructor from being used when the rvalue is another ValidValue

◆ ValidValue() [4/4]

template<typename T >
sparta::utils::ValidValue< T >::ValidValue ( ValidValue< T > &&  v)
inline

Allow moves.

Definition at line 57 of file ValidValue.hpp.

Member Function Documentation

◆ clearValid()

template<typename T >
void sparta::utils::ValidValue< T >::clearValid ( )
inline

Clear the validity of this object.

Definition at line 161 of file ValidValue.hpp.

◆ getValue() [1/2]

template<typename T >
value_type & sparta::utils::ValidValue< T >::getValue ( )
inline

Get the value.

Returns
The internal value by reference, asserts if this ValidValue is NOT valid

Definition at line 153 of file ValidValue.hpp.

◆ getValue() [2/2]

template<typename T >
const value_type & sparta::utils::ValidValue< T >::getValue ( ) const
inline

Get the value - const version.

Returns
The internal value, asserts if this ValidValue is NOT valid

Definition at line 143 of file ValidValue.hpp.

◆ isValid()

template<typename T >
bool sparta::utils::ValidValue< T >::isValid ( ) const
inline

Is this value valid.

Returns
true if valid

Definition at line 114 of file ValidValue.hpp.

◆ operator const value_type &()

template<typename T >
sparta::utils::ValidValue< T >::operator const value_type & ( ) const
inline

Convert the ValidValue to the object it is.

Returns
The internal value, asserts if this ValidValue is NOT valid

Definition at line 123 of file ValidValue.hpp.

◆ operator value_type &()

template<typename T >
sparta::utils::ValidValue< T >::operator value_type & ( )
inline

Convert the ValidValue to the object it is.

Returns
The internal value by reference, asserts if this ValidValue is NOT valid

Definition at line 134 of file ValidValue.hpp.

◆ operator!=()

template<typename T >
bool sparta::utils::ValidValue< T >::operator!= ( const value_type val) const
inline

Compare not equal.

Parameters
valThe value to compare, asserts if this valid isn't valid
Returns
true if not equal

Definition at line 106 of file ValidValue.hpp.

Here is the call graph for this function:

◆ operator=() [1/2]

template<typename T >
value_type sparta::utils::ValidValue< T >::operator= ( const value_type val)
inline

Assignment.

Parameters
valThe value to assign, becomes immediately valid
Returns
The value after assignment

Definition at line 76 of file ValidValue.hpp.

◆ operator=() [2/2]

template<typename T >
value_type sparta::utils::ValidValue< T >::operator= ( value_type &&  val)
inline

Assignment.

Parameters
valThe value to assign, becomes immediately valid
Returns
The value after assignment

Definition at line 86 of file ValidValue.hpp.

◆ operator==()

template<typename T >
bool sparta::utils::ValidValue< T >::operator== ( const value_type val) const
inline

Compare equal.

Parameters
valThe value to compare, asserts if this valid isn't valid
Returns
true if equal

Definition at line 96 of file ValidValue.hpp.


The documentation for this class was generated from the following file: