osgEarth 2.1.1
Public Member Functions | Private Types | Private Attributes

osgEarth::optional< T > Struct Template Reference

Collaboration diagram for osgEarth::optional< T >:

List of all members.

Public Member Functions

 optional ()
 optional (T defaultValue)
 optional (T defaultValue, T value)
 optional (const optional< T > &rhs)
virtual ~optional ()
optional< T > & operator= (const optional< T > &rhs)
const T & operator= (const T &value)
bool operator== (const optional< T > &rhs) const
bool operator!= (const optional< T > &rhs) const
bool operator== (const T &value) const
bool operator!= (const T &value) const
bool isSetTo (const T &value) const
bool isSet () const
void unset ()
const T & get () const
const T & value () const
const T & defaultValue () const
T & mutable_value ()
void init (T defValue)
 operator const T * () const
T * operator-> ()
const T * operator-> () const
 operator unspecified_bool_type () const

Private Types

typedef T *optional:: unspecified_bool_type

Private Attributes

bool _set
_value
_defaultValue

Detailed Description

template<typename T>
struct osgEarth::optional< T >

A template for defining "optional" class members. An optional member has a default value and a flag indicating whether the member is "set". This is used extensively in osgEarth's ConfigOptions subsystem.

Definition at line 51 of file Common.


Member Typedef Documentation

template<typename T>
typedef T* optional:: osgEarth::optional< T >::unspecified_bool_type [private]

Definition at line 86 of file Common.


Constructor & Destructor Documentation

template<typename T>
osgEarth::optional< T >::optional ( ) [inline]

Definition at line 52 of file Common.

: _set(false), _value(T()), _defaultValue(T()) { }
template<typename T>
osgEarth::optional< T >::optional ( defaultValue) [inline]

Definition at line 53 of file Common.

template<typename T>
osgEarth::optional< T >::optional ( defaultValue,
value 
) [inline]

Definition at line 54 of file Common.

template<typename T>
osgEarth::optional< T >::optional ( const optional< T > &  rhs) [inline]

Definition at line 55 of file Common.

{ (*this)=rhs; }
template<typename T>
virtual osgEarth::optional< T >::~optional ( ) [inline, virtual]

Definition at line 56 of file Common.

{ }

Member Function Documentation

template<typename T>
const T& osgEarth::optional< T >::defaultValue ( ) const [inline]

Definition at line 70 of file Common.

{ return _defaultValue; }

Here is the caller graph for this function:

template<typename T>
const T& osgEarth::optional< T >::get ( ) const [inline]

Definition at line 68 of file Common.

{ return _value; }

Here is the caller graph for this function:

template<typename T>
void osgEarth::optional< T >::init ( defValue) [inline]

Definition at line 75 of file Common.

{ _value=defValue; _defaultValue=defValue; unset(); }

Here is the caller graph for this function:

template<typename T>
bool osgEarth::optional< T >::isSet ( ) const [inline]

Definition at line 64 of file Common.

{ return _set; }
template<typename T>
bool osgEarth::optional< T >::isSetTo ( const T &  value) const [inline]

Definition at line 63 of file Common.

{ return _set && _value==value; } // differs from == in that the value must be explicity set

Here is the caller graph for this function:

template<typename T>
T& osgEarth::optional< T >::mutable_value ( ) [inline]

Definition at line 73 of file Common.

{ _set = true; return _value; }

Here is the caller graph for this function:

template<typename T>
osgEarth::optional< T >::operator const T * ( ) const [inline]

Definition at line 77 of file Common.

{ return &_value; }
template<typename T>
osgEarth::optional< T >::operator unspecified_bool_type ( ) const [inline]

Definition at line 89 of file Common.

{ return 0; }
template<typename T>
bool osgEarth::optional< T >::operator!= ( const optional< T > &  rhs) const [inline]

Definition at line 60 of file Common.

{ return !( (*this)==rhs); }
template<typename T>
bool osgEarth::optional< T >::operator!= ( const T &  value) const [inline]

Definition at line 62 of file Common.

{ return _value!=value; }
template<typename T>
const T* osgEarth::optional< T >::operator-> ( ) const [inline]

Definition at line 80 of file Common.

{ return &_value; }
template<typename T>
T* osgEarth::optional< T >::operator-> ( ) [inline]

Definition at line 79 of file Common.

{ _set=true; return &_value; }
template<typename T>
const T& osgEarth::optional< T >::operator= ( const T &  value) [inline]

Definition at line 58 of file Common.

{ _set=true; _value=value; return _value; }
template<typename T>
optional<T>& osgEarth::optional< T >::operator= ( const optional< T > &  rhs) [inline]

Definition at line 57 of file Common.

{ _set=rhs._set; _value=rhs._value; _defaultValue=rhs._defaultValue; return *this; }
template<typename T>
bool osgEarth::optional< T >::operator== ( const optional< T > &  rhs) const [inline]

Definition at line 59 of file Common.

{ return _set && rhs._set && _value==rhs._value; }
template<typename T>
bool osgEarth::optional< T >::operator== ( const T &  value) const [inline]

Definition at line 61 of file Common.

{ return _value==value; }
template<typename T>
void osgEarth::optional< T >::unset ( ) [inline]

Definition at line 65 of file Common.

{ _set = false; _value=_defaultValue; }

Here is the caller graph for this function:

template<typename T>
const T& osgEarth::optional< T >::value ( ) const [inline]

Definition at line 69 of file Common.

{ return _value; }

Member Data Documentation

template<typename T>
T osgEarth::optional< T >::_defaultValue [private]

Definition at line 85 of file Common.

template<typename T>
bool osgEarth::optional< T >::_set [private]

Definition at line 83 of file Common.

template<typename T>
T osgEarth::optional< T >::_value [private]

Definition at line 84 of file Common.


The documentation for this struct was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines