guarded_value< contents > Class Template Reference

Remembers whether a value has actually been initialized. More...

#include <guarded_value.h>

Collaboration diagram for guarded_value< contents >:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 guarded_value ()
 without an initial value, the guarded_value is considered invalid.
 guarded_value (const contents &def)
 the guarded_value with an initial value is considered valid.
 guarded_value (const guarded_value &to_copy)
 Copy constructor makes "this" into a copy of "to_copy".
bool initialized () const
 if the object was initialized and not reset, then this returns true.
void reset ()
 marks the value held by this class as invalid.
guarded_valueoperator= (const guarded_value &t_c)
 assignment operator that takes another guarded value.
guarded_valueoperator= (const contents &t_c)
 assignment operator that takes one of the templated objects.
 operator contents () const
 Operator that returns the held object.
contents & access ()
 A synonym for the contents() operator.

Detailed Description

template<class contents>
class guarded_value< contents >

Remembers whether a value has actually been initialized.

Designed to act identically to the contained class except that it tracks whether the object held is initialized yet or not. The templated class must support a copy constructor.

Definition at line 26 of file guarded_value.h.


Constructor & Destructor Documentation

template<class contents>
guarded_value< contents >::guarded_value (  )  [inline]

without an initial value, the guarded_value is considered invalid.

Definition at line 29 of file guarded_value.h.

template<class contents>
guarded_value< contents >::guarded_value ( const contents &  def  )  [inline]

the guarded_value with an initial value is considered valid.

Definition at line 31 of file guarded_value.h.

template<class contents>
guarded_value< contents >::guarded_value ( const guarded_value< contents > &  to_copy  )  [inline]

Copy constructor makes "this" into a copy of "to_copy".

copying a guarded_value keeps all its characteristics and relies on a properly implemented copy constructor for the <contents>.

Definition at line 33 of file guarded_value.h.


Member Function Documentation

template<class contents>
bool guarded_value< contents >::initialized (  )  const [inline]

if the object was initialized and not reset, then this returns true.

if this returns false, it is a clear sign that the object held cannot be used for any informational purposes.

Definition at line 38 of file guarded_value.h.

Referenced by item_statistics::adjusted_representation().

template<class contents>
void guarded_value< contents >::reset (  )  [inline]

marks the value held by this class as invalid.

if the object had any special destruction requirements (for example, held pointers...), then those need to be taken care of before the reset.

Definition at line 42 of file guarded_value.h.

template<class contents>
guarded_value& guarded_value< contents >::operator= ( const guarded_value< contents > &  t_c  )  [inline]

assignment operator that takes another guarded value.

Definition at line 46 of file guarded_value.h.

template<class contents>
guarded_value& guarded_value< contents >::operator= ( const contents &  t_c  )  [inline]

assignment operator that takes one of the templated objects.

Definition at line 49 of file guarded_value.h.

template<class contents>
guarded_value< contents >::operator contents (  )  const [inline]

Operator that returns the held object.

This conversion (and access()) yields the type of object held here, which re-enables the guarded_value to participate in the normal uses of the templated type.

Definition at line 53 of file guarded_value.h.

template<class contents>
contents& guarded_value< contents >::access (  )  [inline]

A synonym for the contents() operator.

Definition at line 57 of file guarded_value.h.


The documentation for this class was generated from the following file:
Generated on Fri Nov 28 04:30:47 2008 for HOOPLE Libraries by  doxygen 1.5.1