Added CallOnExit::CallAndReset()
Former-commit-id: 045ff61445203999757971deeeafee719fc5506a
This commit is contained in:
@@ -19,6 +19,7 @@ class NzCallOnExit : NzNonCopyable
|
||||
NzCallOnExit(Func func = nullptr);
|
||||
~NzCallOnExit();
|
||||
|
||||
void CallAndReset(Func func = nullptr);
|
||||
void Reset(Func func = nullptr);
|
||||
|
||||
private:
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user