#ifndef WEB_NODE_H #define WEB_NODE_H #include "core/hash_map.h" #include "core/reference.h" #include "core/variant.h" #include "scene/main/node.h" class WebServerRequest; #if WEB_SETTINGS_ENABLED class Settings; #endif class WebServer; class WebPermission; #ifdef DATABASES_ENABLED class DataBase; class TableBuilder; class QueryBuilder; #endif //note add an alterative queue_delete() -> (with different name) -> if called node tells parent to stop getting routed to, and when rwlock can be locked gets queue_deleted. class WebNode : public Node { GDCLASS(WebNode, Node); public: enum { NOTIFICATION_WEB_TREE_WRITE_LOCKED = 2000, }; String get_uri_segment(); void set_uri_segment(const String &val); String get_full_uri(const bool slash_at_the_end = true); String get_full_uri_parent(const bool slash_at_the_end = true); //Maybe this settings class could be a resource, also it needs a new name #if WEB_SETTINGS_ENABLED Settings *get_settings(); void set_settings(Settings *settings); #endif Ref get_web_permission(); void set_web_permission(const Ref &wp); bool get_routing_enabled(); void set_routing_enabled(const bool value); #ifdef DATABASES_ENABLED Database *get_database(); Ref get_table_builder(); Ref get_query_builder(); void set_database(Database *db); #endif void handle_request_main(Ref request); virtual void _handle_request_main(Ref request); void handle_request(Ref request); virtual void _handle_request(Ref request); void handle_error_send_request(Ref request, const int error_code); virtual void _handle_error_send_request(Ref request, const int error_code); void render_index(Ref request); void render_preview(Ref request); void render_menu(Ref request); void render_main_menu(Ref request); virtual void _render_index(Ref request); virtual void _render_preview(Ref request); virtual void _render_menu(Ref request); virtual void _render_main_menu(Ref request); void create_table(); void drop_table(); void udpate_table(); void create_default_entries(); virtual void _create_table(); virtual void _drop_table(); virtual void _udpate_table(); virtual void _create_default_entries(); void migrate(const bool clear, const bool seed); virtual void _migrate(const bool clear, const bool seed); bool try_route_request_to_children(Ref request); WebNode *get_request_handler_child(Ref request); void build_handler_map(); void clear_handlers(); void request_write_lock(); WebServer *get_server(); WebNode *get_web_root(); WebNode *get_parent_webnode(); void add_child_notify(Node *p_child); void remove_child_notify(Node *p_child); WebNode(); ~WebNode(); protected: void _notification(const int what); static void _bind_methods(); String _uri_segment; #if WEB_SETTINGS_ENABLED Settings *_settings; #endif #ifdef DATABASES_ENABLED Database *_database; #endif bool _routing_enabled; WebNode *_index_node; HashMap _node_route_map; Ref _web_permission; bool _write_lock_requested; RWLock _rw_lock; }; #endif