Disk ARchive  2.5.0
Full featured and portable backup and archiving tool
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
cat_etoile.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 CAT_ETOILE_HPP
27 #define CAT_ETOILE_HPP
28 
29 #include "../my_config.h"
30 
31 extern "C"
32 {
33 } // end extern "C"
34 
35 #include <list>
36 #include "on_pool.hpp"
37 #include "cat_inode.hpp"
38 
39 namespace libdar
40 {
43 
44 
46  class cat_etoile : public on_pool
47  {
48  public:
49 
51 
55  cat_etoile(cat_inode *host, const infinint & etiquette_number);
56  cat_etoile(const cat_etoile & ref) { throw SRC_BUG; }; // copy constructor not allowed for this class
57  const cat_etoile & operator = (const cat_etoile & ref) { throw SRC_BUG; }; // assignment not allowed for this class
58  ~cat_etoile() { delete hosted; };
59 
60  void add_ref(void *ref);
61  void drop_ref(void *ref);
62  infinint get_ref_count() const { return refs.size(); };
63  cat_inode *get_inode() const { return hosted; };
64  infinint get_etiquette() const { return etiquette; };
65  void change_etiquette(const infinint & new_val) { etiquette = new_val; };
66 
67 
68  bool is_counted() const { return tags.counted; };
69  bool is_wrote() const { return tags.wrote; };
70  bool is_dumped() const { return tags.dumped; };
71  void set_counted(bool val) { tags.counted = val ? 1 : 0; };
72  void set_wrote(bool val) { tags.wrote = val ? 1 : 0; };
73  void set_dumped(bool val) { tags.dumped = val ? 1 : 0; };
74 
75  // return the address of the first mirage that triggered the creation of this mirage
76  // if this object is destroyed afterward this call returns nullptr
77  const void *get_first_ref() const { if(refs.size() == 0) throw SRC_BUG; return refs.front(); };
78 
79 
80  private:
81  struct bool_tags
82  {
83  unsigned counted : 1; //< whether the inode has been counted
84  unsigned wrote : 1; //< whether the inode has its data copied to archive
85  unsigned dumped : 1; //< whether the inode information has been dumped in the catalogue
86  unsigned : 5; //< padding to get byte boundary and reserved for future use.
87 
88  bool_tags() { counted = wrote = dumped = 0; };
89  };
90 
91  std::list<void *> refs; //< list of pointers to the mirages objects, in the order of their creation
92  cat_inode *hosted;
93  infinint etiquette;
94  bool_tags tags;
95  };
96 
97 
99 
100 } // end of namespace
101 
102 #endif
the hard link implementation (etoile means star in French, seen a star as a point from which are thro...
Definition: cat_etoile.hpp:46
cat_etoile(cat_inode *host, const infinint &etiquette_number)
build an object
this is the base class of object that can be allocated on a memory pool
the root class for all cat_inode
Definition: cat_inode.hpp:54
base object for all inode types, managed EA and FSA, dates, permissions, ownership, ...
the arbitrary large positive integer class