Webdar 1.0.0
Web user interface to libdar
html_form_mask_bool.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_FORM_MASK_BOOL_HPP
25#define HTML_FORM_MASK_BOOL_HPP
26
27 // C system header files
28#include "my_config.h"
29extern "C"
30{
31
32}
33
34 // C++ system header files
35#include <dar/libdar.hpp>
36#include <memory>
37#include <list>
38#include <map>
39#include <deque>
40
41 // webdar headers
42#include "body_builder.hpp"
43#include "html_mask.hpp"
44#include "actor.hpp"
45#include "jsoner.hpp"
46#include "bibliotheque_subconfig.hpp"
47#include "html_form_fieldset.hpp"
48#include "html_form_select.hpp"
49#include "html_table.hpp"
50#include "html_form_input.hpp"
51#include "html_form.hpp"
52#include "html_text.hpp"
53#include "html_form_dynamic_table.hpp"
54#include "events.hpp"
55
56
58
66
83 public html_mask,
84 public actor,
85 public jsoner,
87 public events
88{
89public:
90
91 // events
92
93 static const std::string changed;
94
95 // bool modes
96
97 static constexpr const char* and_op = "and_op";
98 static constexpr const char* or_op = "or_op";
99
100
102
104 html_form_mask_bool(const std::string & initial_mode = and_op);
105 html_form_mask_bool(const html_form_mask_bool & ref) = delete;
106 html_form_mask_bool(html_form_mask_bool && ref) noexcept = delete;
107 html_form_mask_bool & operator = (const html_form_mask_bool & ref) = delete;
108 html_form_mask_bool & operator = (html_form_mask_bool && ref) noexcept = delete;
109 ~html_form_mask_bool() = default;
110
112 virtual std::unique_ptr<libdar::mask> get_mask() const override;
113
115 virtual bool is_relative() const override;
116
118 virtual void on_event(const std::string & event_name) override;
119
121
125
127
130 std::shared_ptr<body_builder> manually_add_object(unsigned int num_type);
131
132
134
137 void add_mask_type(const std::string & label) { table.add_obj_type(label); };
138
140
144
146 const std::string & get_bool_mode() const { return current_bool_mode; };
147
149
153 void manually_set_bool_mode(const std::string & mode);
154
156
162 static std::string invert_logic(const std::string & logic);
163
165 virtual void load_json(const json & source) override;
166
168 virtual json save_json() const override;
169
171 virtual void clear_json() override;
172
174 virtual bibliotheque::using_set get_using_set() const override;
175
176protected:
178 virtual std::string inherited_get_body_part(const chemin & path,
179 const request & req) override;
180
182 virtual void new_css_library_available() override;
183
184
185private:
186 static constexpr const char* bool_changed_event = "bool_changed";
187
188 std::string current_bool_mode;
189 bool ignore_events;
190
192 html_form_select mask_type;
194
195 std::string bool_op_to_name(const std::string & op);
196
198
200 void update_table_content_logic(bool unconditionally);
201 std::string tell_action() const;
202 void trigger_change();
203
204 static constexpr const unsigned int format_version = 1;
205 static constexpr const char* myclass_id = "html_form_mask_bool";
206
207 static constexpr const char* jlabel_logic = "logic";
208 static constexpr const char* jlabel_components = "components";
209};
210
211#endif
class of object that are pointed/triggered to by others
Definition: actor.hpp:55
class bibliotheque_subconfig is an interface (pure virtual class)
Definition: bibliotheque_subconfig.hpp:50
std::set< coordinates > using_set
list of configs a given config depends on
Definition: bibliotheque.hpp:117
class body_builder is the root class of object generating HTML body
Definition: body_builder.hpp:99
class chemin definition
Definition: chemin.hpp:51
class events
Definition: events.hpp:52
class html_form_dynamic_table_object_provider
Definition: html_form_dynamic_table.hpp:60
class html_form_dynamic_table web user dynamically add new lines in a table
Definition: html_form_dynamic_table.hpp:121
void set_obj_type_provider(const html_form_dynamic_table_object_provider *provider)
define a object provider
Definition: html_form_dynamic_table.cpp:79
void clear_obj_type()
clear all object types added by mean of add_obj_type
Definition: html_form_dynamic_table.cpp:87
void add_obj_type(const std::string &label)
add a new object type to be proposed to the user from the "adder" selector
Definition: html_form_dynamic_table.cpp:93
class html_form_fieldset implements HTML fieldset feature
Definition: html_form_fieldset.hpp:51
class html_form_mask_bool provide mean to combines with OR and AND different html_masks
Definition: html_form_mask_bool.hpp:88
virtual bibliotheque::using_set get_using_set() const override
inherited from bibliotheque_subconfig
Definition: html_form_mask_bool.cpp:284
void add_mask_type(const std::string &label)
component type that will proposed to the web user
Definition: html_form_mask_bool.hpp:137
std::shared_ptr< body_builder > manually_add_object(unsigned int num_type)
programmatically add a new object and return a pointer to it
Definition: html_form_mask_bool.cpp:181
void set_obj_type_provider(const html_form_dynamic_table_object_provider *provider)
the object provider will create the objects (masks) of the requested types defined by add_mask_type()
Definition: html_form_mask_bool.hpp:124
void manually_set_bool_mode(const std::string &mode)
manually change the bool mode
Definition: html_form_mask_bool.cpp:199
static std::string invert_logic(const std::string &logic)
return the and_op or or_op inverted logic of the provided argument
Definition: html_form_mask_bool.cpp:205
virtual void new_css_library_available() override
inherited from body_builder
Definition: html_form_mask_bool.cpp:308
html_form_mask_bool(const std::string &initial_mode=and_op)
constructor
Definition: html_form_mask_bool.cpp:44
const std::string & get_bool_mode() const
get the current boolean combining mode
Definition: html_form_mask_bool.hpp:146
void clear_all_masks_type()
clear all mask type added by mean of add_mask_type() method
Definition: html_form_mask_bool.hpp:143
virtual std::unique_ptr< libdar::mask > get_mask() const override
inherited from html_mask
Definition: html_form_mask_bool.cpp:83
virtual void load_json(const json &source) override
inherited from jsoner
Definition: html_form_mask_bool.cpp:215
virtual bool is_relative() const override
inherited from html_mask
Definition: html_form_mask_bool.cpp:144
virtual void clear_json() override
inherited from jsoner
Definition: html_form_mask_bool.cpp:278
virtual json save_json() const override
inherited from jsoner
Definition: html_form_mask_bool.cpp:264
virtual void on_event(const std::string &event_name) override
inherited from actor
Definition: html_form_mask_bool.cpp:167
virtual std::string inherited_get_body_part(const chemin &path, const request &req) override
inherited methods from body_builder
Definition: html_form_mask_bool.cpp:302
class html_form_select implements HTML input of type "select"
Definition: html_form_select.hpp:53
class html_mask defines the interface of all masks
Definition: html_mask.hpp:44
class jsoner
Definition: jsoner.hpp:73
class holding fields of an HTTP request (method, URI, header, cookies, and so on)
Definition: request.hpp:45
defines the event class
defines jsoner class and class exception_json