mirror of
https://github.com/Relintai/rcpp_framework.git
synced 2024-11-14 04:57:21 +01:00
Merged Model and Controller into a new WebNode class.
This commit is contained in:
parent
937d7a3d87
commit
78c5601a9b
@ -1,18 +0,0 @@
|
||||
|
||||
#include "controller.h"
|
||||
|
||||
#include "request.h"
|
||||
|
||||
void Controller::handle_request_main(Request *request) {
|
||||
}
|
||||
|
||||
void Controller::create_validators() {
|
||||
}
|
||||
|
||||
|
||||
Controller::Controller() {
|
||||
create_validators();
|
||||
}
|
||||
|
||||
Controller::~Controller() {
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
#ifndef HTTP_CONTROLLER_H
|
||||
#define HTTP_CONTROLLER_H
|
||||
|
||||
#include "core/object.h"
|
||||
|
||||
class Request;
|
||||
|
||||
class Controller : public Object {
|
||||
public:
|
||||
virtual void handle_request_main(Request *request);
|
||||
virtual void create_validators();
|
||||
|
||||
Controller();
|
||||
~Controller();
|
||||
|
||||
protected:
|
||||
};
|
||||
|
||||
#endif
|
@ -1,20 +0,0 @@
|
||||
|
||||
#include "model.h"
|
||||
|
||||
void Model::create_table() {
|
||||
|
||||
}
|
||||
|
||||
void Model::drop_table() {
|
||||
|
||||
}
|
||||
|
||||
void Model::migrate() {
|
||||
|
||||
}
|
||||
|
||||
Model::Model() {
|
||||
}
|
||||
|
||||
Model::~Model() {
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
#ifndef HTTP_MODEL_H
|
||||
#define HTTP_MODEL_H
|
||||
|
||||
#include "core/object.h"
|
||||
|
||||
class Model : public Object {
|
||||
public:
|
||||
virtual void create_table();
|
||||
virtual void drop_table();
|
||||
virtual void migrate();
|
||||
|
||||
Model();
|
||||
~Model();
|
||||
|
||||
protected:
|
||||
};
|
||||
|
||||
#endif
|
29
core/http/web_node.cpp
Normal file
29
core/http/web_node.cpp
Normal file
@ -0,0 +1,29 @@
|
||||
|
||||
#include "web_node.h"
|
||||
|
||||
#include "request.h"
|
||||
|
||||
void WebNode::handle_request_main(Request *request) {
|
||||
}
|
||||
|
||||
void WebNode::create_validators() {
|
||||
}
|
||||
|
||||
void WebNode::create_table() {
|
||||
|
||||
}
|
||||
|
||||
void WebNode::drop_table() {
|
||||
|
||||
}
|
||||
|
||||
void WebNode::migrate() {
|
||||
|
||||
}
|
||||
|
||||
WebNode::WebNode() {
|
||||
create_validators();
|
||||
}
|
||||
|
||||
WebNode::~WebNode() {
|
||||
}
|
23
core/http/web_node.h
Normal file
23
core/http/web_node.h
Normal file
@ -0,0 +1,23 @@
|
||||
#ifndef WEB_NODE_H
|
||||
#define WEB_NODE_H
|
||||
|
||||
#include "core/object.h"
|
||||
|
||||
class Request;
|
||||
|
||||
class WebNode : public Object {
|
||||
public:
|
||||
virtual void handle_request_main(Request *request);
|
||||
virtual void create_validators();
|
||||
|
||||
virtual void create_table();
|
||||
virtual void drop_table();
|
||||
virtual void migrate();
|
||||
|
||||
WebNode();
|
||||
~WebNode();
|
||||
|
||||
protected:
|
||||
};
|
||||
|
||||
#endif
|
@ -1,32 +0,0 @@
|
||||
#include "admin_controller.h"
|
||||
|
||||
#include "core/html/form_validator.h"
|
||||
#include "core/html/html_builder.h"
|
||||
#include "core/http/cookie.h"
|
||||
#include "core/http/http_session.h"
|
||||
#include "core/http/request.h"
|
||||
#include "core/http/session_manager.h"
|
||||
|
||||
void AdminController::admin_handle_request_main(Request *request) {
|
||||
|
||||
}
|
||||
|
||||
String AdminController::admin_get_section_name() {
|
||||
return "";
|
||||
}
|
||||
|
||||
void AdminController::admin_add_section_links(Vector<AdminSectionLinkInfo> *links) {
|
||||
|
||||
}
|
||||
|
||||
bool AdminController::admin_full_render() {
|
||||
return false;
|
||||
}
|
||||
|
||||
AdminController::AdminController() :
|
||||
Controller() {
|
||||
|
||||
}
|
||||
|
||||
AdminController::~AdminController() {
|
||||
}
|
32
modules/admin_panel/admin_node.cpp
Normal file
32
modules/admin_panel/admin_node.cpp
Normal file
@ -0,0 +1,32 @@
|
||||
#include "admin_node.h"
|
||||
|
||||
#include "core/html/form_validator.h"
|
||||
#include "core/html/html_builder.h"
|
||||
#include "core/http/cookie.h"
|
||||
#include "core/http/http_session.h"
|
||||
#include "core/http/request.h"
|
||||
#include "core/http/session_manager.h"
|
||||
|
||||
void AdminNode::admin_handle_request_main(Request *request) {
|
||||
|
||||
}
|
||||
|
||||
String AdminNode::admin_get_section_name() {
|
||||
return "";
|
||||
}
|
||||
|
||||
void AdminNode::admin_add_section_links(Vector<AdminSectionLinkInfo> *links) {
|
||||
|
||||
}
|
||||
|
||||
bool AdminNode::admin_full_render() {
|
||||
return false;
|
||||
}
|
||||
|
||||
AdminNode::AdminNode() :
|
||||
WebNode() {
|
||||
|
||||
}
|
||||
|
||||
AdminNode::~AdminNode() {
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
#ifndef ADMIN_CONTROLLER_H
|
||||
#define ADMIN_CONTROLLER_H
|
||||
#ifndef ADMIN_NODE_H
|
||||
#define ADMIN_NODE_H
|
||||
|
||||
#include "core/http/controller.h"
|
||||
#include "core/http/web_node.h"
|
||||
|
||||
#include "core/containers/vector.h"
|
||||
#include "core/string.h"
|
||||
@ -22,8 +22,8 @@ struct AdminSectionLinkInfo {
|
||||
}
|
||||
};
|
||||
|
||||
class AdminController : public Controller {
|
||||
RCPP_OBJECT(AdminController, Controller);
|
||||
class AdminNode : public WebNode {
|
||||
RCPP_OBJECT(AdminNode, WebNode);
|
||||
|
||||
public:
|
||||
virtual void admin_handle_request_main(Request *request);
|
||||
@ -31,8 +31,8 @@ public:
|
||||
virtual void admin_add_section_links(Vector<AdminSectionLinkInfo> *links);
|
||||
virtual bool admin_full_render();
|
||||
|
||||
AdminController();
|
||||
~AdminController();
|
||||
AdminNode();
|
||||
~AdminNode();
|
||||
|
||||
protected:
|
||||
};
|
@ -7,7 +7,7 @@
|
||||
#include "core/http/request.h"
|
||||
#include "core/http/session_manager.h"
|
||||
|
||||
#include "admin_controller.h"
|
||||
#include "admin_node.h"
|
||||
|
||||
void AdminPanel::handle_request_main(Request *request) {
|
||||
//todo check permissions
|
||||
@ -23,7 +23,7 @@ void AdminPanel::handle_request_main(Request *request) {
|
||||
AdminPanelSection &s = _controllers[i];
|
||||
|
||||
if (s.section_url == seg) {
|
||||
AdminController *c = s.controller;
|
||||
AdminNode *c = s.controller;
|
||||
|
||||
request->push_path();
|
||||
|
||||
@ -92,14 +92,14 @@ void AdminPanel::render_admin_panel_list(Request *request) {
|
||||
request->compile_and_send_body();
|
||||
}
|
||||
|
||||
void AdminPanel::render_controller_panel(Request *request, AdminController *controller) {
|
||||
void AdminPanel::render_controller_panel(Request *request, AdminNode *controller) {
|
||||
//set up headers
|
||||
controller->admin_handle_request_main(request);
|
||||
//set up footers
|
||||
request->compile_and_send_body();
|
||||
}
|
||||
|
||||
void AdminPanel::register_admin_controller(const String §ion, AdminController *controller) {
|
||||
void AdminPanel::register_admin_controller(const String §ion, AdminNode *controller) {
|
||||
AdminPanelSection sec;
|
||||
|
||||
sec.section_url = section;
|
||||
@ -147,7 +147,7 @@ AdminPanel *AdminPanel::get_singleton() {
|
||||
}
|
||||
|
||||
AdminPanel::AdminPanel() :
|
||||
Controller() {
|
||||
WebNode() {
|
||||
|
||||
if (_self) {
|
||||
printf("AdminPanel::AdminPanel(): Error! self is not null!/n");
|
||||
|
@ -1,25 +1,25 @@
|
||||
#ifndef ADMIN_PANEL_H
|
||||
#define ADMIN_PANEL_H
|
||||
|
||||
#include "core/http/controller.h"
|
||||
#include "core/http/web_node.h"
|
||||
|
||||
#include "core/string.h"
|
||||
#include "core/containers/vector.h"
|
||||
|
||||
class Request;
|
||||
class FormValidator;
|
||||
class AdminController;
|
||||
class AdminNode;
|
||||
|
||||
class AdminPanel : public Controller {
|
||||
RCPP_OBJECT(AdminPanel, Controller);
|
||||
class AdminPanel : public WebNode {
|
||||
RCPP_OBJECT(AdminPanel, WebNode);
|
||||
|
||||
public:
|
||||
void handle_request_main(Request *request);
|
||||
|
||||
virtual void render_admin_panel_list(Request *request);
|
||||
virtual void render_controller_panel(Request *request, AdminController *controller);
|
||||
virtual void render_controller_panel(Request *request, AdminNode *controller);
|
||||
|
||||
void register_admin_controller(const String §ion, AdminController *controller);
|
||||
void register_admin_controller(const String §ion, AdminNode *controller);
|
||||
void clear();
|
||||
|
||||
virtual void render_headers(Request *request);
|
||||
@ -41,7 +41,7 @@ protected:
|
||||
struct AdminPanelSection {
|
||||
String section_url;
|
||||
String name;
|
||||
AdminController *controller;
|
||||
AdminNode *controller;
|
||||
};
|
||||
|
||||
static AdminPanel *_self;
|
||||
|
@ -617,7 +617,7 @@ RBACController *RBACController::get_singleton() {
|
||||
}
|
||||
|
||||
RBACController::RBACController() :
|
||||
AdminController() {
|
||||
AdminNode() {
|
||||
|
||||
if (_self) {
|
||||
printf("RBACController::RBACController(): Error! self is not null!/n");
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "modules/admin_panel/admin_controller.h"
|
||||
#include "modules/admin_panel/admin_node.h"
|
||||
|
||||
#include "core/containers/vector.h"
|
||||
#include "core/string.h"
|
||||
@ -14,8 +14,8 @@
|
||||
class Request;
|
||||
class FormValidator;
|
||||
|
||||
class RBACController : public AdminController {
|
||||
RCPP_OBJECT(RBACController, AdminController);
|
||||
class RBACController : public AdminNode {
|
||||
RCPP_OBJECT(RBACController, AdminNode);
|
||||
|
||||
public:
|
||||
void handle_request_main(Request *request);
|
||||
|
@ -242,7 +242,7 @@ RBACModel *RBACModel::get_singleton() {
|
||||
}
|
||||
|
||||
RBACModel::RBACModel() :
|
||||
Model() {
|
||||
WebNode() {
|
||||
|
||||
if (_self) {
|
||||
printf("RBACModel::RBACModel(): Error! self is not null!/n");
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef RBAC_MODEL_H
|
||||
#define RBAC_MODEL_H
|
||||
|
||||
#include "core/http/model.h"
|
||||
#include "core/http/web_node.h"
|
||||
|
||||
#include <map>
|
||||
#include "core/containers/vector.h"
|
||||
@ -10,8 +10,8 @@
|
||||
#include "rbac_permission.h"
|
||||
#include "rbac_rank.h"
|
||||
|
||||
class RBACModel : public Model {
|
||||
RCPP_OBJECT(RBACModel, Model);
|
||||
class RBACModel : public WebNode {
|
||||
RCPP_OBJECT(RBACModel, WebNode);
|
||||
|
||||
public:
|
||||
virtual std::map<int, Ref<RBACRank> > load_ranks();
|
||||
|
Loading…
Reference in New Issue
Block a user