Added VillageInitializer helper.

This commit is contained in:
Relintai 2021-11-14 13:56:56 +01:00
parent 731f45f63d
commit e49b8613e6
2 changed files with 60 additions and 0 deletions

View File

@ -0,0 +1,37 @@
#include "village_initializer.h"
void VillageInitializer::allocate_controller() {
ERR_FAIL_COND(_controller);
_controller = new VillageController();
}
void VillageInitializer::free_controller() {
if (_controller) {
delete _controller;
_controller = nullptr;
}
}
void VillageInitializer::allocate_model() {
ERR_FAIL_COND(_model);
_model = new VillageModel();
}
void VillageInitializer::free_model() {
if (_model) {
delete _model;
_model = nullptr;
}
}
void VillageInitializer::allocate_all() {
allocate_model();
allocate_controller();
}
void VillageInitializer::free_all() {
free_controller();
free_model();
}
VillageController *VillageInitializer::_controller = nullptr;
VillageModel *VillageInitializer::_model = nullptr;

View File

@ -0,0 +1,23 @@
#ifndef VILLAGE_INITIALIZER_H
#define VILLAGE_INITIALIZER_H
#include "village_model.h"
#include "village_controller.h"
class VillageInitializer {
public:
static void allocate_controller();
static void free_controller();
static void allocate_model();
static void free_model();
static void allocate_all();
static void free_all();
protected:
static VillageController *_controller;
static VillageModel *_model;
};
#endif