![]() |
Disk ARchive
2.5.2
Full featured and portable backup and archiving tool
|
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 00025 00026 #ifndef CAT_ETOILE_HPP 00027 #define CAT_ETOILE_HPP 00028 00029 #include "../my_config.h" 00030 00031 extern "C" 00032 { 00033 } // end extern "C" 00034 00035 #include <list> 00036 #include "on_pool.hpp" 00037 #include "cat_inode.hpp" 00038 00039 namespace libdar 00040 { 00043 00044 00046 class cat_etoile : public on_pool 00047 { 00048 public: 00049 00051 00055 cat_etoile(cat_inode *host, const infinint & etiquette_number); 00056 cat_etoile(const cat_etoile & ref) { throw SRC_BUG; }; // copy constructor not allowed for this class 00057 const cat_etoile & operator = (const cat_etoile & ref) { throw SRC_BUG; }; // assignment not allowed for this class 00058 ~cat_etoile() { delete hosted; }; 00059 00060 void add_ref(void *ref); 00061 void drop_ref(void *ref); 00062 infinint get_ref_count() const { return refs.size(); }; 00063 cat_inode *get_inode() const { return hosted; }; 00064 infinint get_etiquette() const { return etiquette; }; 00065 void change_etiquette(const infinint & new_val) { etiquette = new_val; }; 00066 00067 00068 bool is_counted() const { return tags.counted; }; 00069 bool is_wrote() const { return tags.wrote; }; 00070 bool is_dumped() const { return tags.dumped; }; 00071 void set_counted(bool val) { tags.counted = val ? 1 : 0; }; 00072 void set_wrote(bool val) { tags.wrote = val ? 1 : 0; }; 00073 void set_dumped(bool val) { tags.dumped = val ? 1 : 0; }; 00074 00075 // return the address of the first mirage that triggered the creation of this mirage 00076 // if this object is destroyed afterward this call returns nullptr 00077 const void *get_first_ref() const { if(refs.size() == 0) throw SRC_BUG; return refs.front(); }; 00078 00079 00080 private: 00081 struct bool_tags 00082 { 00083 unsigned counted : 1; //< whether the inode has been counted 00084 unsigned wrote : 1; //< whether the inode has its data copied to archive 00085 unsigned dumped : 1; //< whether the inode information has been dumped in the catalogue 00086 unsigned : 5; //< padding to get byte boundary and reserved for future use. 00087 00088 bool_tags() { counted = wrote = dumped = 0; }; 00089 }; 00090 00091 std::list<void *> refs; //< list of pointers to the mirages objects, in the order of their creation 00092 cat_inode *hosted; 00093 infinint etiquette; 00094 bool_tags tags; 00095 }; 00096 00097 00099 00100 } // end of namespace 00101 00102 #endif