Disk ARchive  2.5.13
Full featured and portable backup and archiving tool
cat_mirage.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_MIRAGE_HPP
27 #define CAT_MIRAGE_HPP
28 
29 #include "../my_config.h"
30 
31 extern "C"
32 {
33 } // end extern "C"
34 
35 #include "cat_nomme.hpp"
36 #include "cat_etoile.hpp"
37 
38 namespace libdar
39 {
40 
43 
45 
47  class cat_mirage : public cat_nomme
48  {
49  public:
50  enum mirage_format {fmt_mirage, //< new format
51  fmt_hard_link, //< old dual format
52  fmt_file_etiquette }; //< old dual format
53 
54  cat_mirage(const std::string & name, cat_etoile *ref) : cat_nomme(name) { star_ref = ref; if(ref == nullptr) throw SRC_BUG; star_ref->add_ref(this); };
56  const smart_pointer<pile_descriptor> & pdesc,
57  const archive_version & reading_ver,
58  saved_status saved,
59  entree_stats & stats,
60  std::map <infinint, cat_etoile *> & corres,
61  compression default_algo,
62  mirage_format fmt,
63  bool lax,
64  bool small);
66  const smart_pointer<pile_descriptor> & pdesc,
67  const archive_version & reading_ver,
68  saved_status saved,
69  entree_stats & stats,
70  std::map <infinint, cat_etoile *> & corres,
71  compression default_algo,
72  bool lax,
73  bool small);
74  cat_mirage(const cat_mirage & ref) : cat_nomme (ref) { star_ref = ref.star_ref; if(star_ref == nullptr) throw SRC_BUG; star_ref->add_ref(this); };
75  const cat_mirage & operator = (const cat_mirage & ref);
76  ~cat_mirage() { star_ref->drop_ref(this); };
77 
78  bool operator == (const cat_entree & ref) const;
79 
80  unsigned char signature() const { return 'm'; };
81  cat_entree *clone() const { return new (get_pool()) cat_mirage(*this); };
82 
83  cat_inode *get_inode() const { if(star_ref == nullptr) throw SRC_BUG; return star_ref->get_inode(); };
84  infinint get_etiquette() const { return star_ref->get_etiquette(); };
85  infinint get_etoile_ref_count() const { return star_ref->get_ref_count(); };
86  cat_etoile *get_etoile() const { return star_ref; };
87 
88  bool is_inode_counted() const { return star_ref->is_counted(); };
89  bool is_inode_wrote() const { return star_ref->is_wrote(); };
90  bool is_inode_dumped() const { return star_ref->is_dumped(); };
91  void set_inode_counted(bool val) const { star_ref->set_counted(val); };
92  void set_inode_wrote(bool val) const { star_ref->set_wrote(val); };
93  void set_inode_dumped(bool val) const { star_ref->set_dumped(val); };
94 
95  void post_constructor(const pile_descriptor & pdesc);
96 
98  bool is_first_mirage() const { return star_ref->get_first_ref() == this; };
99 
100  // overwriting virtual method from cat_entree
101  virtual void change_location(const smart_pointer<pile_descriptor> & pdesc) { get_inode()->change_location(pdesc); };
102 
103  protected:
104  void inherited_dump(const pile_descriptor & pdesc, bool small) const;
105 
106  private:
107  cat_etoile *star_ref;
108 
109  void init(user_interaction & dialog,
110  const smart_pointer<pile_descriptor> & pdesc,
111  const archive_version & reading_ver,
112  saved_status saved,
113  entree_stats & stats,
114  std::map <infinint, cat_etoile *> & corres,
115  compression default_algo,
116  mirage_format fmt,
117  bool lax,
118  bool small);
119  };
120 
122 
123 } // end of namespace
124 
125 #endif
void inherited_dump(const pile_descriptor &pdesc, bool small) const
inherited class may overload this method but shall first call the parent&#39;s inherited_dump() in the ov...
base class of all objects contained in a catalogue and that can be named
memory_pool * get_pool() const
Definition: on_pool.hpp:144
the hard link implementation (etoile means star in French, seen a star as a point from which are thro...
Definition: cat_etoile.hpp:46
holds the statistics contents of a catalogue
Definition: cat_entree.hpp:61
unsigned char signature() const
inherited class signature
Definition: cat_mirage.hpp:80
cat_entree * clone() const
a way to copy the exact type of an object even if pointed to by a parent class pointer ...
Definition: cat_mirage.hpp:81
class holding an cat_inode object that get pointed by multiple mirage objects (smart pointers) to rec...
This is a pure virtual class that is used by libdar when interaction with the user is required...
the hard link implementation, cat_mirage is the named entry owned by a directory it points to a commo...
Definition: cat_mirage.hpp:47
void post_constructor(const pile_descriptor &pdesc)
the base class for all entry that have a name
Definition: cat_nomme.hpp:44
virtual void change_location(const smart_pointer< pile_descriptor > &pdesc)
Definition: cat_mirage.hpp:101
bool is_first_mirage() const
whether we are the mirage that triggered this hard link creation
Definition: cat_mirage.hpp:98
bool operator==(const cat_entree &ref) const
returns true if the two object have the same content
compression
the different compression algorithm available
Definition: compressor.hpp:43
virtual void change_location(const smart_pointer< pile_descriptor > &pdesc)
the root class for all cat_inode
Definition: cat_inode.hpp:54
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