mirror of
https://github.com/Relintai/mourne_rcpp_fw.git
synced 2024-12-23 21:16:50 +01:00
Added VillageInitializer helper.
This commit is contained in:
parent
731f45f63d
commit
e49b8613e6
37
app/village/village_initializer.cpp
Normal file
37
app/village/village_initializer.cpp
Normal 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;
|
23
app/village/village_initializer.h
Normal file
23
app/village/village_initializer.h
Normal 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
|
Loading…
Reference in New Issue
Block a user