ModifyRestore.h
1 //-*-C++-*-
2 /***************************************************************************
3  *
4  * Copyright (C) 2005 by Willem van Straten
5  * Licensed under the Academic Free License version 2.1
6  *
7  ***************************************************************************/
8 
9 // psrchive/Util/units/ModifyRestore.h
10 
11 #ifndef __ModifyRestore_h
12 #define __ModifyRestore_h
13 
15 template<class T>
17 {
18  public:
19 
21  ModifyRestore (T& value, const T& modified_value) : the_value (value)
22  { restore_value = value; the_value = modified_value; }
23 
25  ModifyRestore (T& value) : the_value (value)
26  { restore_value = value; }
27 
31 
32  protected:
33 
35  T& the_value;
36 
38  T restore_value;
39 
40 };
41 
42 #endif
Modifies a value on construction and restores it on destruction.
Definition: ModifyRestore.h:16
ModifyRestore(T &value, const T &modified_value)
Modify constructor.
Definition: ModifyRestore.h:26
T & the_value
Reference to the value to be restored.
Definition: ModifyRestore.h:40
~ModifyRestore()
Restore destructor.
Definition: ModifyRestore.h:34
T restore_value
Copy of the value before modification.
Definition: ModifyRestore.h:43

Generated using doxygen 1.8.17