Disk ARchive  2.4.2
semaphore.hpp
Go to the documentation of this file.
00001 /*********************************************************************/
00002 // dar - disk archive - a backup/restoration program
00003 // Copyright (C) 2002-2052 Denis Corbin
00004 //
00005 // This program is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU General Public License
00007 // as published by the Free Software Foundation; either version 2
00008 // of the License, or (at your option) any later version.
00009 //
00010 // This program is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with this program; if not, write to the Free Software
00017 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00018 //
00019 // to contact the author : http://dar.linux.free.fr/email.html
00020 /*********************************************************************/
00021 // $Id: semaphore.hpp,v 1.4 2011/01/09 17:25:58 edrusb Rel $
00022 //
00023 /*********************************************************************/
00024 //
00025 
00029 
00030 #ifndef SEMAPHORE_HPP
00031 #define SEMAPHORE_HPP
00032 
00033 #include "../my_config.h"
00034 
00035 #include "mem_ui.hpp"
00036 #include "mask.hpp"
00037 #include "catalogue.hpp"
00038 
00039 namespace libdar
00040 {
00041 
00044 
00046 
00067 
00068 
00069     class semaphore : public mem_ui
00070     {
00071     public:
00072 
00074 
00081         semaphore(user_interaction & dialog,
00082                   const std::string & backup_hook_file_execute,
00083                   const mask & backup_hook_file_mask);
00084 
00086         semaphore(const semaphore & ref) : mem_ui(ref.get_ui()) { copy_from(ref); };
00087 
00089         semaphore & operator = (const semaphore & ref) { detruit(); copy_from(ref); return *this; };
00090 
00092         ~semaphore() { detruit(); };
00093 
00095 
00104         void raise(const std::string & path,
00105                    const entree *object,
00106                    bool data_to_save);
00107 
00109         void lower();
00110 
00111     private:
00112         infinint count;       //< is the number of subdirectories currently saved in the last directory that matched the mask
00113         std::string chem;     //< path of the file that has to be call in the "end" context when count will drop to zero
00114         std::string filename; //< filename of that same file
00115         infinint uid;         //< UID of that same file
00116         infinint gid;         //< GID of that same file
00117         std::string execute;  //< command to execute
00118         const mask *match;    //< for which file to run the execute command
00119 
00120         std::string build_string(const std::string & context);
00121         void copy_from(const semaphore & ref);
00122         void detruit();
00123     };
00124 
00126 
00127 } // end of namespace
00128 
00129 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines