Disk ARchive  2.5.10
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-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 #include "on_pool.hpp"
35 
36 namespace libdar
37 {
38 
41 
43 
64 
65 
66  class semaphore : public mem_ui, public on_pool
67  {
68  public:
69 
71 
78  semaphore(user_interaction & dialog,
79  const std::string & backup_hook_file_execute,
80  const mask & backup_hook_file_mask);
81 
83  semaphore(const semaphore & ref) : mem_ui(ref) { copy_from(ref); };
84 
86  semaphore & operator = (const semaphore & ref) { detruit(); copy_from(ref); return *this; };
87 
89  ~semaphore() { detruit(); };
90 
92 
101  void raise(const std::string & path,
102  const cat_entree *object,
103  bool data_to_save);
104 
106  void lower();
107 
108  private:
109  infinint count; //< is the number of subdirectories currently saved in the last directory that matched the mask
110  std::string chem; //< path of the file that has to be call in the "end" context when count will drop to zero
111  std::string filename; //< filename of that same file
112  infinint uid; //< UID of that same file
113  infinint gid; //< GID of that same file
114  unsigned char sig; //< object type
115  std::string execute; //< command to execute
116  const mask *match; //< for which file to run the execute command
117 
118  std::string build_string(const std::string & context);
119  void copy_from(const semaphore & ref);
120  void detruit();
121  };
122 
124 
125 } // end of namespace
126 
127 #endif
class semaphore
Definition: semaphore.hpp:66
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:89
semaphore(user_interaction &dialog, const std::string &backup_hook_file_execute, const mask &backup_hook_file_mask)
constructor
This is a pure virtual class that is used by libdar when interaction with the user is required...
semaphore(const semaphore &ref)
copy constructor
Definition: semaphore.hpp:83
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
this is the base class of object that can be allocated on a memory pool
the arbitrary large positive integer class
the root class from all other inherite for any entry in the catalogue
Definition: cat_entree.hpp:85
libdar namespace encapsulate all libdar symbols
Definition: archive.hpp:47
semaphore & operator=(const semaphore &ref)
assignment operator
Definition: semaphore.hpp:86
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