Added SFWCore class to centralize initialization.

This commit is contained in:
Relintai 2024-01-05 23:42:10 +01:00
parent 4afaa63591
commit c4fc6a7aa0
5 changed files with 61 additions and 7 deletions

View File

@ -43,6 +43,8 @@ ccache g++ -Wall -D_REENTRANT -g -Isfw -c sfw/core/pool_allocator.cpp -o sfw/cor
ccache g++ -Wall -D_REENTRANT -g -Isfw -c sfw/core/mutex.cpp -o sfw/core/mutex.o ccache g++ -Wall -D_REENTRANT -g -Isfw -c sfw/core/mutex.cpp -o sfw/core/mutex.o
ccache g++ -Wall -D_REENTRANT -g -Isfw -c sfw/core/stime.cpp -o sfw/core/stime.o ccache g++ -Wall -D_REENTRANT -g -Isfw -c sfw/core/stime.cpp -o sfw/core/stime.o
ccache g++ -Wall -D_REENTRANT -g -Isfw -c sfw/core/sfw_core.cpp -o sfw/core/sfw_core.o
ccache g++ -Wall -D_REENTRANT -g -Isfw -c sfw/object/object.cpp -o sfw/object/object.o ccache g++ -Wall -D_REENTRANT -g -Isfw -c sfw/object/object.cpp -o sfw/object/object.o
ccache g++ -Wall -D_REENTRANT -g -Isfw -c sfw/object/reference.cpp -o sfw/object/reference.o ccache g++ -Wall -D_REENTRANT -g -Isfw -c sfw/object/reference.cpp -o sfw/object/reference.o
ccache g++ -Wall -D_REENTRANT -g -Isfw -c sfw/object/core_string_names.cpp -o sfw/object/core_string_names.o ccache g++ -Wall -D_REENTRANT -g -Isfw -c sfw/object/core_string_names.cpp -o sfw/object/core_string_names.o
@ -105,7 +107,8 @@ ccache g++ -Wall -lm -ldl -lpthread -lX11 -D_REENTRANT -g sfw/core/aabb.o sfw/c
sfw/core/vector2.o sfw/core/vector2i.o sfw/core/vector3.o \ sfw/core/vector2.o sfw/core/vector2i.o sfw/core/vector3.o \
sfw/core/vector3i.o sfw/core/vector4.o sfw/core/vector4i.o \ sfw/core/vector3i.o sfw/core/vector4.o sfw/core/vector4i.o \
sfw/core/pool_vector.o sfw/core/pool_allocator.o sfw/core/mutex.o sfw/core/stime.o \ sfw/core/pool_vector.o sfw/core/pool_allocator.o sfw/core/mutex.o sfw/core/stime.o \
sfw/core/dir_access.o sfw/core/file_access.o\ sfw/core/dir_access.o sfw/core/file_access.o \
sfw/core/sfw_core.o \
sfw/object/object.o sfw/object/reference.o sfw/object/core_string_names.o \ sfw/object/object.o sfw/object/reference.o sfw/object/core_string_names.o \
sfw/object/variant.o sfw/object/variant_op.o sfw/object/psignal.o \ sfw/object/variant.o sfw/object/variant_op.o sfw/object/psignal.o \
sfw/object/array.o sfw/object/dictionary.o sfw/object/ref_ptr.o \ sfw/object/array.o sfw/object/dictionary.o sfw/object/ref_ptr.o \

31
sfw/core/sfw_core.cpp Normal file
View File

@ -0,0 +1,31 @@
#include "sfw_core.h"
//--STRIP
#include "core/pool_vector.h"
#include "core/string_name.h"
//--STRIP
void SFWCore::setup() {
if (_initialized) {
return;
}
_initialized = true;
StringName::setup();
MemoryPool::setup();
}
void SFWCore::cleanup() {
if (!_initialized) {
return;
}
_initialized = false;
StringName::cleanup();
MemoryPool::cleanup();
}
bool SFWCore::_initialized = false;

14
sfw/core/sfw_core.h Normal file
View File

@ -0,0 +1,14 @@
#ifndef SFW_CORE_H
#define SFW_CORE_H
class SFWCore {
public:
static void setup();
static void cleanup();
protected:
static bool _initialized;
};
#endif

View File

@ -8,8 +8,7 @@
#include "render_core/input_map.h" #include "render_core/input_map.h"
#include "render_core/window.h" #include "render_core/window.h"
#include "core/pool_vector.h" #include "core/sfw_core.h"
#include "core/string_name.h"
#include "object/core_string_names.h" #include "object/core_string_names.h"
//--STRIP //--STRIP
@ -89,9 +88,10 @@ Application::Application() {
_time_scale = 1; _time_scale = 1;
SFWCore::setup();
// TODO Move these to a central place in core! // TODO Move these to a central place in core!
StringName::setup();
MemoryPool::setup();
CoreStringNames::create(); CoreStringNames::create();
// TODO add a helper static method // TODO add a helper static method
@ -106,14 +106,15 @@ Application::~Application() {
_instance = NULL; _instance = NULL;
// TODO Move these to a central place in core! // TODO Move these to a central place in core!
StringName::cleanup();
MemoryPool::cleanup();
CoreStringNames::free(); CoreStringNames::free();
// TODO add a helper static method // TODO add a helper static method
memdelete(AppWindow::get_singleton()); memdelete(AppWindow::get_singleton());
memdelete(Input::get_singleton()); memdelete(Input::get_singleton());
memdelete(InputMap::get_singleton()); memdelete(InputMap::get_singleton());
SFWCore::cleanup();
} }
Application *Application::get_singleton() { Application *Application::get_singleton() {

View File

@ -400,6 +400,11 @@
//--STRIP //--STRIP
{{FILE:sfw/core/dir_access.h}} {{FILE:sfw/core/dir_access.h}}
//--STRIP
//no includes
//--STRIP
{{FILE:sfw/core/sfw_core.h}}
//--STRIP //--STRIP
//=================== OBJECT SECTION =================== //=================== OBJECT SECTION ===================
//--STRIP //--STRIP