Added CallOnExit::CallAndReset()

Former-commit-id: 045ff61445203999757971deeeafee719fc5506a
This commit is contained in:
Lynix 2015-01-04 18:57:01 +01:00
parent 911e10fa84
commit 0f033eaed9
2 changed files with 10 additions and 0 deletions

View File

@ -19,6 +19,7 @@ class NzCallOnExit : NzNonCopyable
NzCallOnExit(Func func = nullptr);
~NzCallOnExit();
void CallAndReset(Func func = nullptr);
void Reset(Func func = nullptr);
private:

View File

@ -2,6 +2,7 @@
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Core/Error.hpp>
#include <Nazara/Core/Debug.hpp>
inline NzCallOnExit::NzCallOnExit(Func func) :
@ -15,6 +16,14 @@ inline NzCallOnExit::~NzCallOnExit()
m_func();
}
inline void NzCallOnExit::CallAndReset(Func func)
{
if (m_func)
m_func();
Reset(func);
}
inline void NzCallOnExit::Reset(Func func)
{
m_func = func;