mirror of
https://github.com/Relintai/rcpp_framework.git
synced 2024-11-14 04:57:21 +01:00
Added a new UserInitializer helper class.
This commit is contained in:
parent
adf8475804
commit
60e22942e4
37
modules/users/user_initializer.cpp
Normal file
37
modules/users/user_initializer.cpp
Normal file
@ -0,0 +1,37 @@
|
||||
#include "user_initializer.h"
|
||||
|
||||
void UserInitializer::allocate_controller() {
|
||||
ERR_FAIL_COND(_controller);
|
||||
|
||||
_controller = new UserController();
|
||||
}
|
||||
void UserInitializer::free_controller() {
|
||||
if (_controller) {
|
||||
delete _controller;
|
||||
_controller = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void UserInitializer::allocate_model() {
|
||||
ERR_FAIL_COND(_model);
|
||||
|
||||
_model = new UserModel();
|
||||
}
|
||||
void UserInitializer::free_model() {
|
||||
if (_model) {
|
||||
delete _model;
|
||||
_model = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void UserInitializer::allocate_all() {
|
||||
allocate_model();
|
||||
allocate_controller();
|
||||
}
|
||||
void UserInitializer::free_all() {
|
||||
free_controller();
|
||||
free_model();
|
||||
}
|
||||
|
||||
UserController *UserInitializer::_controller = nullptr;
|
||||
UserModel *UserInitializer::_model = nullptr;
|
23
modules/users/user_initializer.h
Normal file
23
modules/users/user_initializer.h
Normal file
@ -0,0 +1,23 @@
|
||||
#ifndef USER_INITIALIZER_H
|
||||
#define USER_INITIALIZER_H
|
||||
|
||||
#include "user_model.h"
|
||||
#include "user_controller.h"
|
||||
|
||||
class UserInitializer {
|
||||
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 UserController *_controller;
|
||||
static UserModel *_model;
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user