Added CallOnExit::CallAndReset()
Former-commit-id: 045ff61445203999757971deeeafee719fc5506a
This commit is contained in:
parent
911e10fa84
commit
0f033eaed9
|
|
@ -19,6 +19,7 @@ class NzCallOnExit : NzNonCopyable
|
||||||
NzCallOnExit(Func func = nullptr);
|
NzCallOnExit(Func func = nullptr);
|
||||||
~NzCallOnExit();
|
~NzCallOnExit();
|
||||||
|
|
||||||
|
void CallAndReset(Func func = nullptr);
|
||||||
void Reset(Func func = nullptr);
|
void Reset(Func func = nullptr);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
// This file is part of the "Nazara Engine - Core module"
|
// This file is part of the "Nazara Engine - Core module"
|
||||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||||
|
|
||||||
|
#include <Nazara/Core/Error.hpp>
|
||||||
#include <Nazara/Core/Debug.hpp>
|
#include <Nazara/Core/Debug.hpp>
|
||||||
|
|
||||||
inline NzCallOnExit::NzCallOnExit(Func func) :
|
inline NzCallOnExit::NzCallOnExit(Func func) :
|
||||||
|
|
@ -15,6 +16,14 @@ inline NzCallOnExit::~NzCallOnExit()
|
||||||
m_func();
|
m_func();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void NzCallOnExit::CallAndReset(Func func)
|
||||||
|
{
|
||||||
|
if (m_func)
|
||||||
|
m_func();
|
||||||
|
|
||||||
|
Reset(func);
|
||||||
|
}
|
||||||
|
|
||||||
inline void NzCallOnExit::Reset(Func func)
|
inline void NzCallOnExit::Reset(Func func)
|
||||||
{
|
{
|
||||||
m_func = func;
|
m_func = func;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue