Public Member Functions | Private Attributes

chomp::homology::local_var< varType > Class Template Reference

Local variable guardian. More...

#include <localvar.h>

List of all members.

Public Member Functions

 local_var (varType &_variable)
 The constructor of a local variable guardian.
 local_var (varType &_variable, const varType &_newValue)
 The constructor of a local variable guardian which assigns a new value upon initialization.
 ~local_var ()
 The destructor of a local variable guardian.

Private Attributes

varType & var
 Reference to the global variable.
const varType value
 The original value of the variable which is going to be restored upon destruction of the guardian object.

Detailed Description

template<class varType>
class chomp::homology::local_var< varType >

Local variable guardian.

This template contains the definition of a class whose object remembers the previous value of a variable provided upon initialization, sets the new value, and restores the previous value upon destruction. This corresponds to certain extent to a local variable in Perl.

Definition at line 54 of file localvar.h.


Constructor & Destructor Documentation

template<class varType >
chomp::homology::local_var< varType >::local_var ( varType &  _variable  )  [inline]

The constructor of a local variable guardian.

Definition at line 80 of file localvar.h.

                                                       :
        var (_variable), value (_variable)
{
        return;
} /* local_var */

template<class varType >
chomp::homology::local_var< varType >::local_var ( varType &  _variable,
const varType &  _newValue 
) [inline]

The constructor of a local variable guardian which assigns a new value upon initialization.

Definition at line 87 of file localvar.h.

                                 : var (_variable), value (_variable)
{
        _variable = _newValue;
        return;
} /* local_var */

template<class varType >
chomp::homology::local_var< varType >::~local_var (  )  [inline]

The destructor of a local variable guardian.

Definition at line 95 of file localvar.h.

References chomp::homology::local_var< varType >::value, and chomp::homology::local_var< varType >::var.

{
        var = value;
        return;
} /* ~local_var */


Member Data Documentation

template<class varType>
const varType chomp::homology::local_var< varType >::value [private]

The original value of the variable which is going to be restored upon destruction of the guardian object.

Definition at line 73 of file localvar.h.

Referenced by chomp::homology::local_var< varType >::~local_var().

template<class varType>
varType& chomp::homology::local_var< varType >::var [private]

Reference to the global variable.

Definition at line 69 of file localvar.h.

Referenced by chomp::homology::local_var< varType >::~local_var().


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