| Disk ARchive 2.8.3 Full featured and portable backup and archiving tool

Loading...
Searching...
No Matches
dar64-2.8.3-win64/include/dar/crit_action.hpp
Go to the documentation of this file.
1/*********************************************************************/
2// dar - disk archive - a backup/restoration program
3// Copyright (C) 2002-2026 Denis Corbin
4//
5// This program is free software; you can redistribute it and/or
6// modify it under the terms of the GNU General Public License
7// as published by the Free Software Foundation; either version 2
8// of the License, or (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with this program; if not, write to the Free Software
17// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18//
19// to contact the author, see the AUTHOR file
20/*********************************************************************/
21
25
26#ifndef CRIT_ACTION_HPP
27#define CRIT_ACTION_HPP
28
29#include "//include/dar/libdar_my_config.h"
30
31#include <deque>
32
33#include "//include/dar/criterium.hpp"
34
35 namespace libdar
36{
37
40
42 class cat_nomme;
43
45
46 enum over_action_data
47 {
48 data_preserve,
49 data_overwrite,
50 data_preserve_mark_already_saved,
51 data_overwrite_mark_already_saved,
52 data_remove,
53 data_undefined,
54 data_ask
55 };
56
57
59
61 enum over_action_ea
62 {
63 EA_preserve,
64 EA_overwrite,
65 EA_clear,
66 EA_preserve_mark_already_saved,
67 EA_overwrite_mark_already_saved,
68 EA_merge_preserve,
69 EA_merge_overwrite,
70 EA_undefined,
71 EA_ask
72 };
73
74
76
79
80 class crit_action
81 {
82 public:
83 crit_action() {};
84 crit_action(const crit_action & ref) = default;
85 crit_action(crit_action && ref) noexcept = default;
86 crit_action & operator = (const crit_action & ref) = default;
87 crit_action & operator = (crit_action && ref) noexcept = default;
88
90 virtual ~crit_action() = default;
91
93
98 virtual void get_action(const cat_nomme & first, const cat_nomme & second, over_action_data & data, over_action_ea & ea) const = 0;
99
101
105 virtual crit_action *clone() const = 0;
106 };
107
108
110
113
114 class crit_constant_action : public crit_action
115 {
116 public:
118
121 crit_constant_action(over_action_data data, over_action_ea ea) { x_data = data; x_ea = ea; };
122 crit_constant_action(const crit_constant_action & ref) = default;
123 crit_constant_action & operator = (const crit_constant_action & ref) = default;
124 ~crit_constant_action() = default;
125
126
128 virtual void get_action(const cat_nomme & first, const cat_nomme & second, over_action_data & data, over_action_ea & ea) const override { data = x_data; ea = x_ea; };
129 virtual crit_action *clone() const override { return new (std::nothrow) crit_constant_action(*this); };
130
131 private:
132 over_action_data x_data;
133 over_action_ea x_ea;
134 };
135
136
138
141
142 class testing : public crit_action
143 {
144 public:
146
150 testing(const criterium & input, const crit_action & go_true, const crit_action & go_false);
151 testing(const testing & ref) : crit_action(ref) { copy_from(ref); if(!check()) throw Ememory("testing::testing(const testing &)"); };
152 testing(testing && ref) noexcept : crit_action(std::move(ref)) { nullifyptr(); move_from(std::move(ref)); };
153 testing & operator = (const testing & ref) { free(); copy_from(ref); if(!check()) throw Ememory("testing::testing(const testing &)"); return *this; };
154 testing & operator = (testing && ref) noexcept { crit_action::operator = (std::move(ref)); move_from(std::move(ref)); return *this; };
155 ~testing() { free(); };
156
157
159 virtual void get_action(const cat_nomme & first, const cat_nomme & second, over_action_data & data, over_action_ea & ea) const override
160 {
161 if(x_input->evaluate(first, second))
162 x_go_true->get_action(first, second, data, ea);
163 else
164 x_go_false->get_action(first, second, data, ea);
165 };
166
167 virtual crit_action *clone() const override { return new (std::nothrow) testing(*this); };
168
169 private:
170 criterium *x_input;
171 crit_action *x_go_true;
172 crit_action *x_go_false;
173
174 void nullifyptr() noexcept { x_input = nullptr; x_go_true = x_go_false = nullptr; };
175 void free() noexcept;
176 void copy_from(const testing & ref);
177 void move_from(testing && ref) noexcept;
178 bool check() const;
179 };
180
181
183
186
187 class crit_chain : public crit_action
188 {
189 public:
190 crit_chain() { sequence.clear(); };
191 crit_chain(const crit_chain & ref) : crit_action(ref) { copy_from(ref); };
192 crit_chain(crit_chain && ref) noexcept : crit_action(std::move(ref)) { sequence = std::move(ref.sequence); };
193 crit_chain & operator = (const crit_chain & ref) { destroy(); copy_from(ref); return *this; };
194 crit_chain & operator = (crit_chain && ref) noexcept { crit_action::operator = (std::move(ref)); sequence = std::move(ref.sequence); return *this; };
195 ~crit_chain() { destroy(); };
196
197 void add(const crit_action & act);
198 void clear() { destroy(); };
199 void gobe(crit_chain & to_be_voided);
200
201 virtual void get_action(const cat_nomme & first, const cat_nomme & second, over_action_data & data, over_action_ea & ea) const override;
202
203 virtual crit_action *clone() const override { return new (std::nothrow) crit_chain(*this); };
204
205 private:
206 std::deque<crit_action *> sequence;
207
208 void destroy();
209 void copy_from(const crit_chain & ref);
210 };
211
213
214} // end of namespace
215
216#endif
libdar::Ememory
exception used when memory has been exhausted
Definition dar64-2.8.3-win64/include/dar/erreurs.hpp:127
libdar::cat_nomme
the base class for all entry that have a name
Definition cat_nomme.hpp:45
libdar::crit_action
the global action for overwriting
Definition dar64-2.8.3-win64/include/dar/crit_action.hpp:81
libdar::crit_action::~crit_action
virtual ~crit_action()=default
the destructor
libdar::crit_action::get_action
virtual void get_action(const cat_nomme &first, const cat_nomme &second, over_action_data &data, over_action_ea &ea) const =0
the action to take based on the files to compare
libdar::crit_action::clone
virtual crit_action * clone() const =0
clone construction method
libdar::crit_chain
the crit_chain class sequences crit_actions up to full definition of the action
Definition dar64-2.8.3-win64/include/dar/crit_action.hpp:188
libdar::crit_chain::clone
virtual crit_action * clone() const override
clone construction method
Definition dar64-2.8.3-win64/include/dar/crit_action.hpp:203
libdar::crit_chain::get_action
virtual void get_action(const cat_nomme &first, const cat_nomme &second, over_action_data &data, over_action_ea &ea) const override
the action to take based on the files to compare
libdar::crit_constant_action
the basic constant action
Definition dar64-2.8.3-win64/include/dar/crit_action.hpp:115
libdar::crit_constant_action::crit_constant_action
crit_constant_action(over_action_data data, over_action_ea ea)
the constuctor
Definition dar64-2.8.3-win64/include/dar/crit_action.hpp:121
libdar::crit_constant_action::get_action
virtual void get_action(const cat_nomme &first, const cat_nomme &second, over_action_data &data, over_action_ea &ea) const override
the inherited pure virtual methods from class action that must be implemented
Definition dar64-2.8.3-win64/include/dar/crit_action.hpp:128
libdar::crit_constant_action::clone
virtual crit_action * clone() const override
clone construction method
Definition dar64-2.8.3-win64/include/dar/crit_action.hpp:129
libdar::criterium
the generic criterium class, parent of all criterium
Definition dar64-2.8.3-win64/include/dar/criterium.hpp:52
libdar::testing
the testing class binds criterium to actions
Definition dar64-2.8.3-win64/include/dar/crit_action.hpp:143
libdar::testing::clone
virtual crit_action * clone() const override
clone construction method
Definition dar64-2.8.3-win64/include/dar/crit_action.hpp:167
libdar::testing::get_action
virtual void get_action(const cat_nomme &first, const cat_nomme &second, over_action_data &data, over_action_ea &ea) const override
the inherited pure virtual method from class crit_action that must be implemented
Definition dar64-2.8.3-win64/include/dar/crit_action.hpp:159
libdar::testing::check
bool check() const
returns false if an field is nullptr
libdar::testing::testing
testing(const criterium &input, const crit_action &go_true, const crit_action &go_false)
the constructor
libdar::over_action_ea
over_action_ea
the possible action for overwriting EA
Definition dar64-2.8.3-win64/include/dar/crit_action.hpp:62
libdar::over_action_data
over_action_data
the possible actions for overwriting data
Definition dar64-2.8.3-win64/include/dar/crit_action.hpp:47
libdar::EA_merge_overwrite
@ EA_merge_overwrite
merge EA but if both inode share an EA with the same name, take keep the one of the 'to be added' ino...
Definition dar64-2.8.3-win64/include/dar/crit_action.hpp:69
libdar::EA_clear
@ EA_clear
drop the EA for the elected entry
Definition dar64-2.8.3-win64/include/dar/crit_action.hpp:65
libdar::EA_undefined
@ EA_undefined
action still undefined at this step of the evaluation
Definition dar64-2.8.3-win64/include/dar/crit_action.hpp:70
libdar::EA_ask
@ EA_ask
ask for user decision about EA
Definition dar64-2.8.3-win64/include/dar/crit_action.hpp:71
libdar::EA_overwrite_mark_already_saved
@ EA_overwrite_mark_already_saved
drop any EA but mark them as already saved in the archive of reference (ctime is the one of the 'to b...
Definition dar64-2.8.3-win64/include/dar/crit_action.hpp:67
libdar::EA_overwrite
@ EA_overwrite
keep the EA of the 'to be added' entry
Definition dar64-2.8.3-win64/include/dar/crit_action.hpp:64
libdar::EA_merge_preserve
@ EA_merge_preserve
merge EA but do not overwrite existing EA of 'in place' by one of the same name of 'to be added' inod...
Definition dar64-2.8.3-win64/include/dar/crit_action.hpp:68
libdar::EA_preserve_mark_already_saved
@ EA_preserve_mark_already_saved
drop any EA but mark them as already saved in the archive of reference (ctime is the one of the 'in p...
Definition dar64-2.8.3-win64/include/dar/crit_action.hpp:66
libdar::EA_preserve
@ EA_preserve
keep the EA of the 'in place' entry
Definition dar64-2.8.3-win64/include/dar/crit_action.hpp:63
libdar::data_remove
@ data_remove
remove the original data/EA (file is completely deleted)
Definition dar64-2.8.3-win64/include/dar/crit_action.hpp:52
libdar::data_undefined
@ data_undefined
action still undefined at this step of the evaluation
Definition dar64-2.8.3-win64/include/dar/crit_action.hpp:53
libdar::data_overwrite_mark_already_saved
@ data_overwrite_mark_already_saved
overwrite the 'in place' but mark the 'to be added' as already saved in the archive of reference
Definition dar64-2.8.3-win64/include/dar/crit_action.hpp:51
libdar::data_preserve_mark_already_saved
@ data_preserve_mark_already_saved
keep the 'in place' but mark it as already saved in the archive of reference
Definition dar64-2.8.3-win64/include/dar/crit_action.hpp:50
libdar::data_preserve
@ data_preserve
do not overwrite (keep the 'in place' entry)
Definition dar64-2.8.3-win64/include/dar/crit_action.hpp:48
libdar::data_ask
@ data_ask
ask for user decision about file's data
Definition dar64-2.8.3-win64/include/dar/crit_action.hpp:54
libdar::data_overwrite
@ data_overwrite
overwirte the 'in place' entry by the 'to be added' one
Definition dar64-2.8.3-win64/include/dar/crit_action.hpp:49
libdar
libdar namespace encapsulate all libdar symbols
Definition dar64-2.8.3-win64/include/dar/archive.hpp:47