mirror of
https://github.com/Relintai/rcpp_framework.git
synced 2024-11-10 00:52:11 +01:00
Added settings and database helpers to WebNode.
This commit is contained in:
parent
3eb128264d
commit
7117cb3988
@ -3,6 +3,63 @@
|
||||
|
||||
#include "request.h"
|
||||
|
||||
#include "core/settings/settings.h"
|
||||
|
||||
#ifdef DATABASES_ENABLED
|
||||
#include "core/database/database.h"
|
||||
#include "core/database/database_manager.h"
|
||||
#include "core/database/query_builder.h"
|
||||
#include "core/database/query_result.h"
|
||||
#include "core/database/table_builder.h"
|
||||
#endif
|
||||
|
||||
Settings *WebNode::get_settings() {
|
||||
if (_settings) {
|
||||
return _settings;
|
||||
}
|
||||
|
||||
return Settings::get_singleton();
|
||||
}
|
||||
void WebNode::set_settings(Settings *settings) {
|
||||
_settings = settings;
|
||||
|
||||
// todo send event to children when it's implemented?
|
||||
}
|
||||
|
||||
#ifdef DATABASES_ENABLED
|
||||
|
||||
Database *WebNode::get_database() {
|
||||
if (_database) {
|
||||
return _database;
|
||||
}
|
||||
|
||||
return DatabaseManager::get_singleton()->ddb;
|
||||
}
|
||||
|
||||
Ref<TableBuilder> WebNode::get_table_builder() {
|
||||
Database *db = get_database();
|
||||
|
||||
ERR_FAIL_COND_V(!db, Ref<TableBuilder>());
|
||||
|
||||
return db->get_table_builder();
|
||||
}
|
||||
|
||||
Ref<QueryBuilder> WebNode::get_query_builder() {
|
||||
Database *db = get_database();
|
||||
|
||||
ERR_FAIL_COND_V(!db, Ref<QueryBuilder>());
|
||||
|
||||
return db->get_query_builder();
|
||||
}
|
||||
|
||||
void WebNode::set_database(Database *db) {
|
||||
_database = db;
|
||||
|
||||
// todo send event to children when it's implemented?
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void WebNode::handle_request_main(Request *request) {
|
||||
}
|
||||
|
||||
@ -10,23 +67,29 @@ void WebNode::create_validators() {
|
||||
}
|
||||
|
||||
void WebNode::create_table() {
|
||||
|
||||
}
|
||||
|
||||
void WebNode::drop_table() {
|
||||
|
||||
}
|
||||
|
||||
void WebNode::migrate() {
|
||||
|
||||
}
|
||||
|
||||
void WebNode::create_default_entries() {
|
||||
|
||||
}
|
||||
|
||||
WebNode::WebNode() : Node() {
|
||||
create_validators();
|
||||
WebNode::WebNode() :
|
||||
Node() {
|
||||
// should look this up in parents when parented (and node parenting is implemented)
|
||||
// should have an event later when a parent gets one
|
||||
#ifdef DATABASES_ENABLED
|
||||
_database = nullptr;
|
||||
#endif
|
||||
|
||||
// same for this
|
||||
_settings = nullptr;
|
||||
|
||||
create_validators();
|
||||
}
|
||||
|
||||
WebNode::~WebNode() {
|
||||
|
@ -2,11 +2,29 @@
|
||||
#define WEB_NODE_H
|
||||
|
||||
#include "core/nodes/node.h"
|
||||
#include "core/reference.h"
|
||||
|
||||
class Request;
|
||||
class Settings;
|
||||
|
||||
#ifdef DATABASES_ENABLED
|
||||
class DataBase;
|
||||
class TableBuilder;
|
||||
class QueryBuilder;
|
||||
#endif
|
||||
|
||||
class WebNode : public Node {
|
||||
public:
|
||||
Settings *get_settings();
|
||||
void set_settings(Settings *settings);
|
||||
|
||||
#ifdef DATABASES_ENABLED
|
||||
Database *get_database();
|
||||
Ref<TableBuilder> get_table_builder();
|
||||
Ref<QueryBuilder> get_query_builder();
|
||||
void set_database(Database *db);
|
||||
#endif
|
||||
|
||||
virtual void handle_request_main(Request *request);
|
||||
virtual void create_validators();
|
||||
|
||||
@ -19,6 +37,11 @@ public:
|
||||
~WebNode();
|
||||
|
||||
protected:
|
||||
Settings *_settings;
|
||||
|
||||
#ifdef DATABASES_ENABLED
|
||||
Database *_database;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user