Disk ARchive  2.4.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
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 // $Id: semaphore.hpp,v 1.4 2011/01/09 17:25:58 edrusb Rel $
22 //
23 /*********************************************************************/
24 //
25 
29 
30 #ifndef SEMAPHORE_HPP
31 #define SEMAPHORE_HPP
32 
33 #include "../my_config.h"
34 
35 #include "mem_ui.hpp"
36 #include "mask.hpp"
37 #include "catalogue.hpp"
38 
39 namespace libdar
40 {
41 
44 
46 
67 
68 
69  class semaphore : public mem_ui
70  {
71  public:
72 
74 
81  semaphore(user_interaction & dialog,
82  const std::string & backup_hook_file_execute,
83  const mask & backup_hook_file_mask);
84 
86  semaphore(const semaphore & ref) : mem_ui(ref.get_ui()) { copy_from(ref); };
87 
89  semaphore & operator = (const semaphore & ref) { detruit(); copy_from(ref); return *this; };
90 
92  ~semaphore() { detruit(); };
93 
95 
104  void raise(const std::string & path,
105  const entree *object,
106  bool data_to_save);
107 
109  void lower();
110 
111  private:
112  infinint count; //< is the number of subdirectories currently saved in the last directory that matched the mask
113  std::string chem; //< path of the file that has to be call in the "end" context when count will drop to zero
114  std::string filename; //< filename of that same file
115  infinint uid; //< UID of that same file
116  infinint gid; //< GID of that same file
117  std::string execute; //< command to execute
118  const mask *match; //< for which file to run the execute command
119 
120  std::string build_string(const std::string & context);
121  void copy_from(const semaphore & ref);
122  void detruit();
123  };
124 
126 
127 } // end of namespace
128 
129 #endif