mirror of
https://github.com/Relintai/sfw.git
synced 2024-12-20 21:06:49 +01:00
Added SFWCore class to centralize initialization.
This commit is contained in:
parent
4afaa63591
commit
c4fc6a7aa0
@ -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/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/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
|
||||
@ -106,6 +108,7 @@ ccache g++ -Wall -lm -ldl -lpthread -lX11 -D_REENTRANT -g sfw/core/aabb.o sfw/c
|
||||
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/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/variant.o sfw/object/variant_op.o sfw/object/psignal.o \
|
||||
sfw/object/array.o sfw/object/dictionary.o sfw/object/ref_ptr.o \
|
||||
|
31
sfw/core/sfw_core.cpp
Normal file
31
sfw/core/sfw_core.cpp
Normal 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
14
sfw/core/sfw_core.h
Normal 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
|
@ -8,8 +8,7 @@
|
||||
#include "render_core/input_map.h"
|
||||
#include "render_core/window.h"
|
||||
|
||||
#include "core/pool_vector.h"
|
||||
#include "core/string_name.h"
|
||||
#include "core/sfw_core.h"
|
||||
#include "object/core_string_names.h"
|
||||
//--STRIP
|
||||
|
||||
@ -89,9 +88,10 @@ Application::Application() {
|
||||
|
||||
_time_scale = 1;
|
||||
|
||||
SFWCore::setup();
|
||||
|
||||
// TODO Move these to a central place in core!
|
||||
StringName::setup();
|
||||
MemoryPool::setup();
|
||||
|
||||
CoreStringNames::create();
|
||||
|
||||
// TODO add a helper static method
|
||||
@ -106,14 +106,15 @@ Application::~Application() {
|
||||
_instance = NULL;
|
||||
|
||||
// TODO Move these to a central place in core!
|
||||
StringName::cleanup();
|
||||
MemoryPool::cleanup();
|
||||
|
||||
CoreStringNames::free();
|
||||
|
||||
// TODO add a helper static method
|
||||
memdelete(AppWindow::get_singleton());
|
||||
memdelete(Input::get_singleton());
|
||||
memdelete(InputMap::get_singleton());
|
||||
|
||||
SFWCore::cleanup();
|
||||
}
|
||||
|
||||
Application *Application::get_singleton() {
|
||||
|
@ -400,6 +400,11 @@
|
||||
//--STRIP
|
||||
{{FILE:sfw/core/dir_access.h}}
|
||||
|
||||
//--STRIP
|
||||
//no includes
|
||||
//--STRIP
|
||||
{{FILE:sfw/core/sfw_core.h}}
|
||||
|
||||
//--STRIP
|
||||
//=================== OBJECT SECTION ===================
|
||||
//--STRIP
|
||||
|
Loading…
Reference in New Issue
Block a user