The Original CHomP Software
Public Member Functions | Private Attributes | List of all members
chomp::homology::local_var< varType > Class Template Reference

Local variable guardian. More...

#include <localvar.h>

Public Member Functions

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

Private Attributes

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

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 53 of file localvar.h.

Constructor & Destructor Documentation

◆ local_var() [1/2]

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

The constructor of a local variable guardian.

Definition at line 79 of file localvar.h.

79 :
80 var (_variable), value (_variable)
81{
82 return;
83} /* local_var */
const varType value
The original value of the variable which is going to be restored upon destruction of the guardian obj...
Definition: localvar.h:72
varType & var
Reference to the global variable.
Definition: localvar.h:68

◆ local_var() [2/2]

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 86 of file localvar.h.

87 : var (_variable), value (_variable)
88{
89 _variable = _newValue;
90 return;
91} /* local_var */

◆ ~local_var()

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

The destructor of a local variable guardian.

Definition at line 94 of file localvar.h.

95{
96 var = value;
97 return;
98} /* ~local_var */

Member Data Documentation

◆ value

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 72 of file localvar.h.

◆ var

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

Reference to the global variable.

Definition at line 68 of file localvar.h.


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