Disk ARchive  2.4.15
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules
semaphore.hpp
Go to the documentation of this file.
1 /*********************************************************************/
2 // dar - disk archive - a backup/restoration program
3 // Copyright (C) 2002-2052 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 //
19 // to contact the author : http://dar.linux.free.fr/email.html
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 #include "catalogue.hpp"
34 
35 namespace libdar
36 {
37 
40 
42 
63 
64 
65  class semaphore : public mem_ui
66  {
67  public:
68 
70 
77  semaphore(user_interaction & dialog,
78  const std::string & backup_hook_file_execute,
79  const mask & backup_hook_file_mask);
80 
82  semaphore(const semaphore & ref) : mem_ui(ref.get_ui()) { copy_from(ref); };
83 
85  semaphore & operator = (const semaphore & ref) { detruit(); copy_from(ref); return *this; };
86 
88  ~semaphore() { detruit(); };
89 
91 
100  void raise(const std::string & path,
101  const entree *object,
102  bool data_to_save);
103 
105  void lower();
106 
107 #ifdef LIBDAR_SPECIAL_ALLOC
108  USE_SPECIAL_ALLOC(semaphore);
109 #endif
110  private:
111  infinint count; //< is the number of subdirectories currently saved in the last directory that matched the mask
112  std::string chem; //< path of the file that has to be call in the "end" context when count will drop to zero
113  std::string filename; //< filename of that same file
114  infinint uid; //< UID of that same file
115  infinint gid; //< GID of that same file
116  std::string execute; //< command to execute
117  const mask *match; //< for which file to run the execute command
118 
119  std::string build_string(const std::string & context);
120  void copy_from(const semaphore & ref);
121  void detruit();
122  };
123 
125 
126 } // end of namespace
127 
128 #endif
class semaphore
Definition: semaphore.hpp:65
the generic class, parent of all masks
Definition: mask.hpp:61
class mem_ui definition. This class is to be used as parent class to handle user_interaction object m...
~semaphore()
destructor
Definition: semaphore.hpp:88
semaphore(user_interaction &dialog, const std::string &backup_hook_file_execute, const mask &backup_hook_file_mask)
constructor
the deleted file entry
Definition: catalogue.hpp:906
This is a pure virtual class that is used by libdar when interaction with the user is required...
the root class from all other inherite for any entry in the catalogue
Definition: catalogue.hpp:94
semaphore(const semaphore &ref)
copy constructor
Definition: semaphore.hpp:82
here lies a collection of mask classes
void lower()
to tell that the backup is completed for the last "raised" entry.
class mem_ui to keep a copy of a user_interaction object
Definition: mem_ui.hpp:53
the arbitrary large positive integer class
user_interaction & get_ui() const
get access to the user_interaction cloned object
libdar namespace encapsulate all libdar symbols
Definition: archive.hpp:43
semaphore & operator=(const semaphore &ref)
assignment operator
Definition: semaphore.hpp:85
here is defined the many classed which is build of the catalogue
the class path is here to manipulate paths in the Unix notation: using'/'
Definition: path.hpp:50