1 #ifndef __TTempVarSetter_H__
2 #define __TTempVarSetter_H__
3 
4 /* this class temporarily sets a variable to a value while the object exists */
5 template <typename T> class TTempVarSetter
6 {
7 	T &variable;
8 	const T backupValue;
9 public:
10 	TTempVarSetter(T &_variable,const T &value) :
11 		variable(_variable),
12 		backupValue(variable)
13 	{
14 		variable=value;
15 	}
16 
17 	~TTempVarSetter()
18 	{
19 		variable=backupValue;
20 	}
21 };
22 
23 #endif
24