//
//	Copyright © 2005 Nemetschek North America 
//	All Rights Reserved.
//
// Created by Vladislav Stanev

#pragma once

namespace VWFC
{
	namespace Tools
	{
		template<class TYPE> class ValueRestore
		{
		public:
					ValueRestore(TYPE* pVariable, TYPE newValue);
					~ValueRestore();

		private:
			TYPE*	fpVariable;
			TYPE	fOldValue;
		};

		///////////////////////////////////////////////////////////////////////////////////
		// implementation
		template<class TYPE> ValueRestore<TYPE>::ValueRestore(TYPE* pVariable, TYPE newValue)
		{
			VWFC_ASSERT( pVariable );
			fpVariable		= pVariable;
			fOldValue		= * fpVariable;
			* fpVariable	= newValue;
		}

		template<class TYPE> ValueRestore<TYPE>::~ValueRestore()
		{
			* fpVariable	= fOldValue;
		}

	}
}