Webdar 1.0.0
Web user interface to libdar
html_libdar_running_page.hpp
1/*********************************************************************/
2// webdar - a web server and interface program to libdar
3// Copyright (C) 2013-2025 Denis Corbin
4//
5// This file is part of Webdar
6//
7// Webdar is free software: you can redistribute it and/or modify
8// it under the terms of the GNU General Public License as published by
9// the Free Software Foundation, either version 3 of the License, or
10// (at your option) any later version.
11//
12// Webdar is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU General Public License for more details.
16//
17// You should have received a copy of the GNU General Public License
18// along with Webdar. If not, see <http://www.gnu.org/licenses/>
19//
20//----
21// to contact the author: dar.linux@free.fr
22/*********************************************************************/
23
24#ifndef HTML_LIBDAR_RUNNING_PAGE_HPP
25#define HTML_LIBDAR_RUNNING_PAGE_HPP
26
27 // C system header files
28#include "my_config.h"
29extern "C"
30{
31
32}
33
34 // C++ system header files
35
36 // webdar headers
37#include "html_page.hpp"
38#include "events.hpp"
39#include "actor.hpp"
40#include "html_web_user_interaction.hpp"
41
43
45
46class html_libdar_running_page : public html_page, public events, public actor
47{
48public:
49 // this class generates the following events:
50 static const std::string libdar_has_finished;
51
52 // constructor
55 html_libdar_running_page(html_libdar_running_page && ref) noexcept = delete;
56 html_libdar_running_page & operator = (const html_libdar_running_page & ref) = delete;
57 html_libdar_running_page & operator = (html_libdar_running_page && ref) noexcept = delete;
58 ~html_libdar_running_page() = default;
59
61 virtual void on_event(const std::string & event_name) override;
62
64 void set_session_name(const std::string & name) { sessname = name; set_title(webdar_tools_get_title(sessname, "Libdar is running")); };
65
67 std::shared_ptr<html_web_user_interaction> get_html_user_interaction() { return web_ui; };
68
70 void run_and_control_thread(libthreadar::thread* arg) { web_ui->run_and_control_thread(arg); };
71
73 void join_controlled_thread() { web_ui->join_controlled_thread(); };
74
76 bool is_libdar_running() const { return web_ui->is_libdar_running(); };
77
79 bool has_libdar_been_aborted() const { return web_ui->has_libdar_been_aborted(); };
80
81
82protected:
84 virtual std::string inherited_get_body_part(const chemin & path,
85 const request & req) override;
86
87private:
88 std::string sessname;
89 std::shared_ptr<html_web_user_interaction> web_ui;
90 bool enable_refresh;
91};
92
93#endif
class of object that are pointed/triggered to by others
Definition: actor.hpp:55
class chemin definition
Definition: chemin.hpp:51
class events
Definition: events.hpp:52
html_libdar_running_page wraps up an html_web_user_interaction in a html_page
Definition: html_libdar_running_page.hpp:47
bool is_libdar_running() const
whether a libdar thread is running under "this" management
Definition: html_libdar_running_page.hpp:76
void run_and_control_thread(libthreadar::thread *arg)
propagate request to web_ui
Definition: html_libdar_running_page.hpp:70
void join_controlled_thread()
propagate request to web_ui
Definition: html_libdar_running_page.hpp:73
static const std::string libdar_has_finished
libdar execution has ended and user has acknoledged it
Definition: html_libdar_running_page.hpp:50
virtual std::string inherited_get_body_part(const chemin &path, const request &req) override
inherited from body_builder
Definition: html_libdar_running_page.cpp:63
virtual void on_event(const std::string &event_name) override
inherited from actor
Definition: html_libdar_running_page.cpp:76
bool has_libdar_been_aborted() const
whether libdar thread has been aborted (to be checked by the caller upon libdar_has_finished event)
Definition: html_libdar_running_page.hpp:79
void set_session_name(const std::string &name)
defines the name of the session
Definition: html_libdar_running_page.hpp:64
std::shared_ptr< html_web_user_interaction > get_html_user_interaction()
propagate request to web_ui
Definition: html_libdar_running_page.hpp:67
html page root component
Definition: html_page.hpp:45
void set_title(const std::string &title)
change page title
Definition: html_page.cpp:43
class holding fields of an HTTP request (method, URI, header, cookies, and so on)
Definition: request.hpp:45
defines the event class