rcpp_framework/platform/platform_initializer.cpp

59 lines
1.1 KiB
C++
Raw Permalink Normal View History

#include "platform_initializer.h"
#include "core/error_macros.h"
#if PLATFORM_LINUX
#include "linux/crash_handler_linux.h"
2021-11-09 17:47:51 +01:00
#include "linux/platform_linux.h"
#endif
void PlatformInitializer::arg_setup(int argc, char **argv, char **envp) {
if (_platform) {
_platform->arg_setup(argc, argv, envp);
}
}
2021-11-09 17:47:51 +01:00
void PlatformInitializer::allocate_platform() {
ERR_FAIL_COND(_platform);
#if PLATFORM_LINUX
_platform = new PlatformLinux();
#endif
}
void PlatformInitializer::free_platform() {
if (_platform) {
delete _platform;
_platform = nullptr;
}
}
void PlatformInitializer::allocate_crash_handler() {
ERR_FAIL_COND(_crash_handler);
#if PLATFORM_LINUX
_crash_handler = new CrashHandlerLinux();
_crash_handler->enable();
#endif
}
void PlatformInitializer::free_crash_handler() {
if (_crash_handler) {
delete _crash_handler;
_crash_handler = nullptr;
}
}
void PlatformInitializer::allocate_all() {
2021-11-09 17:47:51 +01:00
allocate_platform();
allocate_crash_handler();
}
void PlatformInitializer::free_all() {
2021-11-09 17:47:51 +01:00
free_platform();
free_crash_handler();
}
2021-11-09 17:47:51 +01:00
Platform *PlatformInitializer::_platform = nullptr;
CrashHandler *PlatformInitializer::_crash_handler = nullptr;