Disk ARchive  2.7.15
Full featured and portable backup and archiving tool
semaphore.hpp
Go to the documentation of this file.
1 /*********************************************************************/
2 // dar - disk archive - a backup/restoration program
3 // Copyright (C) 2002-2024 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 SEMAPHORE_HPP
27 #define SEMAPHORE_HPP
28 
29 #include "../my_config.h"
30 
31 #include "mem_ui.hpp"
32 #include "mask.hpp"
33 
34 namespace libdar
35 {
36 
39 
41 
62 
63  class semaphore : public mem_ui
64  {
65  public:
66 
68 
75  semaphore(const std::shared_ptr<user_interaction> & dialog,
76  const std::string & backup_hook_file_execute,
77  const mask & backup_hook_file_mask);
78 
80  semaphore(const semaphore & ref) : mem_ui(ref) { copy_from(ref); };
81 
83  semaphore(semaphore && ref) noexcept: mem_ui(std::move(ref)) { nullifyptr(); move_from(std::move(ref)); };
84 
86  semaphore & operator = (const semaphore & ref) { detruit(); copy_from(ref); return *this; };
87 
89  semaphore & operator = (semaphore && ref) noexcept { move_from(std::move(ref)); return *this; };
90 
92  ~semaphore() { detruit(); };
93 
95 
105  void raise(const std::string & path,
106  const cat_entree *object,
107  bool data_to_save);
108 
110  void lower();
111 
112  private:
114  std::string chem;
115  std::string filename;
118  unsigned char sig;
119  std::string execute;
120  const mask *match;
121 
122  void nullifyptr() noexcept { match = nullptr; };
123  std::string build_string(const std::string & context);
124  void copy_from(const semaphore & ref);
125  void move_from(semaphore && ref) noexcept;
126  void detruit();
127  };
128 
130 
131 } // end of namespace
132 
133 #endif
the root class from all other inherite for any entry in the catalogue
Definition: cat_entree.hpp:60
the arbitrary large positive integer class
the generic class, parent of all masks
Definition: mask.hpp:62
class mem_ui to keep a copy of a user_interaction object
Definition: mem_ui.hpp:55
mem_ui(const std::shared_ptr< user_interaction > &dialog)
constructor
the class path is here to manipulate paths in the Unix notation: using'/'
Definition: path.hpp:51
class semaphore
Definition: semaphore.hpp:64
infinint gid
GID of that same file.
Definition: semaphore.hpp:117
std::string filename
filename of that same file
Definition: semaphore.hpp:115
unsigned char sig
object type
Definition: semaphore.hpp:118
semaphore(const semaphore &ref)
copy constructor
Definition: semaphore.hpp:80
~semaphore()
destructor
Definition: semaphore.hpp:92
semaphore(semaphore &&ref) noexcept
move constructor
Definition: semaphore.hpp:83
void lower()
to tell that the backup is completed for the last "raised" entry.
std::string chem
path of the file that has to be call in the "end" context when count will drop to zero
Definition: semaphore.hpp:114
std::string execute
command to execute
Definition: semaphore.hpp:119
semaphore(const std::shared_ptr< user_interaction > &dialog, const std::string &backup_hook_file_execute, const mask &backup_hook_file_mask)
constructor
infinint count
is the number of subdirectories currently saved in the last directory that matched the mask
Definition: semaphore.hpp:113
infinint uid
UID of that same file.
Definition: semaphore.hpp:116
semaphore & operator=(const semaphore &ref)
assignment operator
Definition: semaphore.hpp:86
const mask * match
for which file to run the execute command
Definition: semaphore.hpp:120
here lies a collection of mask classes
class mem_ui definition. This class is to be used as parent class to handle user_interaction object m...
libdar namespace encapsulate all libdar symbols
Definition: archive.hpp:47