Disk ARchive 2.7.16
Full featured and portable backup and archiving tool
cat_entree.hpp
Go to the documentation of this file.
1/*********************************************************************/
2// dar - disk archive - a backup/restoration program
3// Copyright (C) 2002-2024 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18//
19// to contact the author, see the AUTHOR file
20/*********************************************************************/
21
25
26#ifndef CAT_ENTREE_HPP
27#define CAT_ENTREE_HPP
28
29#include "../my_config.h"
30
31extern "C"
32{
33} // end extern "C"
34
35#include "infinint.hpp"
36#include "user_interaction.hpp"
37#include "pile.hpp"
38#include "escape.hpp"
39#include "archive_version.hpp"
40#include "proto_compressor.hpp"
41#include "pile_descriptor.hpp"
42#include "smart_pointer.hpp"
43#include "entree_stats.hpp"
44#include "list_entry.hpp"
45#include "slice_layout.hpp"
46
47#include <memory>
48
49namespace libdar
50{
51 class cat_etoile;
52
55
56
58
60 {
61 public :
63
73 static cat_entree *read(const std::shared_ptr<user_interaction> & dialog,
75 const archive_version & reading_ver,
76 entree_stats & stats,
77 std::map <infinint, cat_etoile *> & corres,
78 compression default_algo,
79 bool lax,
80 bool only_detruit,
81 bool small);
82
85
87
93
94 // copy constructor is fine as we only copy the address of pointers
95 cat_entree(const cat_entree & ref) = default;
96
97 // move constructor
98 cat_entree(cat_entree && ref) noexcept = default;
99
100 // assignment operator is fine too for the same reason
101 cat_entree & operator = (const cat_entree & ref) = default;
102
103 // move assignment operator
104 cat_entree & operator = (cat_entree && ref) = default;
105
107 virtual ~cat_entree() noexcept(false) {};
108
110 virtual bool operator == (const cat_entree & ref) const = 0;
111 bool operator != (const cat_entree & ref) const { return ! (*this == ref); };
112
114
120 bool same_as(const cat_entree & ref) const { return true; };
121
123
126 void dump(const pile_descriptor & pdesc, bool small) const;
127
129
132 void specific_dump(const pile_descriptor & pdesc, bool small) const { inherited_dump(pdesc, small); };
133
135
139 virtual void post_constructor(const pile_descriptor & pdesc) {};
140
142 virtual unsigned char signature() const = 0;
143
145 virtual std::string get_description() const = 0;
146
148 virtual cat_entree *clone() const = 0;
149
152
162
165
168
170
176 void set_list_entry(const slice_layout *sly,
177 bool fetch_ea,
178 list_entry & ent) const;
179
180 protected:
182 virtual void inherited_dump(const pile_descriptor & pdesc, bool small) const;
183
184
186 pile *get_pile() const { return pdesc.is_null() ? nullptr : pdesc->stack; };
187
189
193 proto_compressor *get_compressor_layer() const { return pdesc.is_null() ? nullptr : pdesc->compr; };
194
196
200 escape *get_escape_layer() const { return pdesc.is_null() ? nullptr : pdesc->esc; };
201
204
205 private:
206 static const U_I ENTREE_CRC_SIZE;
207
210 };
211
213 extern const char *cat_entree_signature2string(unsigned char sign);
214
216
217} // end of namespace
218
219#endif
class archive_version that rules which archive format to follow
class archive_version manages the version of the archive format
the root class from all other inherite for any entry in the catalogue
Definition: cat_entree.hpp:60
escape * get_escape_layer() const
escape generic_file relative methods
Definition: cat_entree.hpp:200
generic_file * get_read_cat_layer(bool small) const
return the adhoc layer in the stack to read from the catalogue objects (except the EA,...
virtual void inherited_dump(const pile_descriptor &pdesc, bool small) const
inherited class may overload this method but shall first call the parent's inherited_dump() in the ov...
bool same_as(const cat_entree &ref) const
return true of the two objects would generate the same entry on filsystem
Definition: cat_entree.hpp:120
void specific_dump(const pile_descriptor &pdesc, bool small) const
this call gives an access to inherited_dump
Definition: cat_entree.hpp:132
pile * get_pile() const
stack used to read object from (nullptr is returned for object created from filesystem)
Definition: cat_entree.hpp:186
void set_list_entry(const slice_layout *sly, bool fetch_ea, list_entry &ent) const
setup a list_entry object relative to the current cat_entree object
saved_status get_saved_status() const
obtain the saved status of the object
Definition: cat_entree.hpp:164
cat_entree(saved_status val)
setup an object when read from filesystem
Definition: cat_entree.hpp:84
virtual unsigned char signature() const =0
inherited class signature
static cat_entree * read(const std::shared_ptr< user_interaction > &dialog, const smart_pointer< pile_descriptor > &f, const archive_version &reading_ver, entree_stats &stats, std::map< infinint, cat_etoile * > &corres, compression default_algo, bool lax, bool only_detruit, bool small)
read and create an object of inherited class of class cat_entree
virtual ~cat_entree() noexcept(false)
destructor
Definition: cat_entree.hpp:107
saved_status xsaved
inode data status, this field is stored with signature() in the cat_signature field -> must be manage...
Definition: cat_entree.hpp:208
void set_saved_status(saved_status x)
modify the saved_status of the object
Definition: cat_entree.hpp:167
virtual std::string get_description() const =0
inherited class designation
cat_entree(const smart_pointer< pile_descriptor > &pdesc, bool small, saved_status val)
setup an object when read from an archive
virtual void change_location(const smart_pointer< pile_descriptor > &pdesc)
virtual cat_entree * clone() const =0
a way to copy the exact type of an object even if pointed to by a parent class pointer
virtual bool operator==(const cat_entree &ref) const =0
returns true if the two object are the same
void dump(const pile_descriptor &pdesc, bool small) const
write down the object information to a stack
proto_compressor * get_compressor_layer() const
compressor generic_file relative methods
Definition: cat_entree.hpp:193
virtual void post_constructor(const pile_descriptor &pdesc)
let inherited classes build object's data after CRC has been read from file in small read mode
Definition: cat_entree.hpp:139
this is the interface class from which all other data transfer classes inherit
Definition: list_entry.hpp:60
stores a stack of generic_files writing/reading on each others
Definition: pile.hpp:44
bool is_null() const
return whether the smart_pointer is pointing to nullptr
datastructure holding the nature of file present in a given archive
class escape definition, used for sequential reading of archives
compression
the different compression algorithm available
Definition: compression.hpp:46
const char * cat_entree_signature2string(unsigned char sign)
convert a signature char to a human readable string
saved_status
data saved status for an entry
Definition: cat_status.hpp:45
switch module to limitint (32 ou 64 bits integers) or infinint
class of objects describing an entry in the archive, used by archive::get_children_in_table
libdar namespace encapsulate all libdar symbols
Definition: archive.hpp:47
class pile definition. Used to manage a stack of generic_file objects
optimization structure to quickly access some commonly used layers of a stack of generic_file
abstracted ancestor class for compressor and parallel_compressor classes
object describing the slicing of an archive
template class implementing memory efficient smart pointer
holds the statistics contents of a catalogue
defines the interaction interface between libdar and users.