Added CallOnExit class
Former-commit-id: d4b6bb17a8183f46e4631d727fc8056eb2fcb254
This commit is contained in:
parent
4df6c30a26
commit
c42eff2db0
|
|
@ -0,0 +1,28 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Core module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_CALLONEXIT_HPP
|
||||
#define NAZARA_CALLONEXIT_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
|
||||
class NzCallOnExit
|
||||
{
|
||||
using Func = void (*)();
|
||||
|
||||
public:
|
||||
NzCallOnExit(Func func = nullptr);
|
||||
~NzCallOnExit();
|
||||
|
||||
void Reset(Func func = nullptr);
|
||||
|
||||
private:
|
||||
Func m_func;
|
||||
};
|
||||
|
||||
#include <Nazara/Core/CallOnExit.inl>
|
||||
|
||||
#endif // NAZARA_CALLONEXIT_HPP
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// 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/Debug.hpp>
|
||||
|
||||
inline NzCallOnExit::NzCallOnExit(Func func) :
|
||||
m_func(func)
|
||||
{
|
||||
}
|
||||
|
||||
inline NzCallOnExit::~NzCallOnExit()
|
||||
{
|
||||
if (m_func)
|
||||
m_func();
|
||||
}
|
||||
|
||||
inline void NzCallOnExit::Reset(Func func)
|
||||
{
|
||||
m_func = func;
|
||||
}
|
||||
|
||||
#include <Nazara/Core/DebugOff.hpp>
|
||||
Loading…
Reference in New Issue