Core: Add SignalHandlerAppComponent
This commit is contained in:
committed by
Jérôme Leclercq
parent
8eefb2f101
commit
40bb69bc60
@@ -27,7 +27,7 @@ namespace Nz
|
||||
ApplicationBase(int argc, const Pointer<const char>* argv);
|
||||
ApplicationBase(const ApplicationBase&) = delete;
|
||||
ApplicationBase(ApplicationBase&&) = delete;
|
||||
~ApplicationBase() = default;
|
||||
~ApplicationBase();
|
||||
|
||||
inline void AddUpdater(std::unique_ptr<ApplicationUpdater>&& functor);
|
||||
template<typename F> void AddUpdaterFunc(F&& functor);
|
||||
@@ -48,6 +48,8 @@ namespace Nz
|
||||
ApplicationBase& operator=(const ApplicationBase&) = delete;
|
||||
ApplicationBase& operator=(ApplicationBase&&) = delete;
|
||||
|
||||
static inline ApplicationBase* Instance();
|
||||
|
||||
protected:
|
||||
template<typename T, typename... Args> T& AddComponent(Args&&... args);
|
||||
|
||||
@@ -66,6 +68,8 @@ namespace Nz
|
||||
std::vector<Updater> m_updaters;
|
||||
HighPrecisionClock m_clock;
|
||||
Time m_currentTime;
|
||||
|
||||
static ApplicationBase* s_instance;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +74,12 @@ namespace Nz
|
||||
{
|
||||
m_running = false;
|
||||
}
|
||||
|
||||
|
||||
inline ApplicationBase* ApplicationBase::Instance()
|
||||
{
|
||||
return s_instance;
|
||||
}
|
||||
|
||||
template<typename T, typename... Args>
|
||||
T& ApplicationBase::AddComponent(Args&&... args)
|
||||
{
|
||||
|
||||
35
include/Nazara/Core/SignalHandlerAppComponent.hpp
Normal file
35
include/Nazara/Core/SignalHandlerAppComponent.hpp
Normal file
@@ -0,0 +1,35 @@
|
||||
// Copyright (C) 2023 Jérôme "Lynix" Leclercq (lynix680@gmail.com)
|
||||
// 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_CORE_SIGNALHANDLERAPPCOMPONENT_HPP
|
||||
#define NAZARA_CORE_SIGNALHANDLERAPPCOMPONENT_HPP
|
||||
|
||||
#include <NazaraUtils/Prerequisites.hpp>
|
||||
#include <Nazara/Core/ApplicationComponent.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class NAZARA_CORE_API SignalHandlerAppComponent : public ApplicationComponent
|
||||
{
|
||||
public:
|
||||
inline SignalHandlerAppComponent(ApplicationBase& app);
|
||||
SignalHandlerAppComponent(const SignalHandlerAppComponent&) = delete;
|
||||
SignalHandlerAppComponent(SignalHandlerAppComponent&&) = delete;
|
||||
~SignalHandlerAppComponent() = default;
|
||||
|
||||
SignalHandlerAppComponent& operator=(const SignalHandlerAppComponent&) = delete;
|
||||
SignalHandlerAppComponent& operator=(SignalHandlerAppComponent&&) = delete;
|
||||
|
||||
private:
|
||||
void InstallSignalHandler();
|
||||
|
||||
static void HandleInterruptSignal(const char* signalName);
|
||||
};
|
||||
}
|
||||
|
||||
#include <Nazara/Core/SignalHandlerAppComponent.inl>
|
||||
|
||||
#endif // NAZARA_CORE_SIGNALHANDLERAPPCOMPONENT_HPP
|
||||
16
include/Nazara/Core/SignalHandlerAppComponent.inl
Normal file
16
include/Nazara/Core/SignalHandlerAppComponent.inl
Normal file
@@ -0,0 +1,16 @@
|
||||
// Copyright (C) 2023 Jérôme "Lynix" Leclercq (lynix680@gmail.com)
|
||||
// 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>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
SignalHandlerAppComponent::SignalHandlerAppComponent(ApplicationBase& app) :
|
||||
ApplicationComponent(app)
|
||||
{
|
||||
InstallSignalHandler();
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Core/DebugOff.hpp>
|
||||
Reference in New Issue
Block a user