cat_mirage.hpp
Go to the documentation of this file.
/*********************************************************************/
// dar - disk archive - a backup/restoration program
// Copyright (C) 2002-2023 Denis Corbin
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
// to contact the author, see the AUTHOR file
/*********************************************************************/
#ifndef CAT_MIRAGE_HPP
#define CAT_MIRAGE_HPP
#include "../my_config.h"
extern "C"
{
} // end extern "C"
#include "cat_nomme.hpp"
#include "cat_etoile.hpp"
namespace libdar
{
class cat_mirage : public cat_nomme
{
public:
enum mirage_format {fmt_mirage,
fmt_hard_link,
fmt_file_etiquette };
cat_mirage(const std::string & name, cat_etoile *ref): cat_nomme(name, saved_status::saved) { dup_on(ref); };
cat_mirage(const std::shared_ptr<user_interaction> & dialog,
const smart_pointer<pile_descriptor> & pdesc,
const archive_version & reading_ver,
saved_status saved,
entree_stats & stats,
std::map <infinint, cat_etoile *> & corres,
compression default_algo,
mirage_format fmt,
bool lax,
bool small);
cat_mirage(const std::shared_ptr<user_interaction> & dialog,
const smart_pointer<pile_descriptor> & pdesc,
const archive_version & reading_ver,
saved_status saved,
entree_stats & stats,
std::map <infinint, cat_etoile *> & corres,
compression default_algo,
bool lax,
bool small);
cat_mirage(const cat_mirage & ref) : cat_nomme (ref) { dup_on(ref.star_ref); };
cat_mirage(cat_mirage && ref) noexcept: cat_nomme(std::move(ref)) { try { dup_on(ref.star_ref); } catch(...) {}; };
cat_mirage & operator = (const cat_mirage & ref);
cat_mirage & operator = (cat_mirage && ref) noexcept;
~cat_mirage() { star_ref->drop_ref(this); };
virtual bool operator == (const cat_entree & ref) const override;
virtual unsigned char signature() const override { return 'm'; };
virtual std::string get_description() const override { return "hard linked inode"; };
virtual cat_entree *clone() const override { return new (std::nothrow) cat_mirage(*this); };
cat_inode *get_inode() const { if(star_ref == nullptr) throw SRC_BUG; return star_ref->get_inode(); };
infinint get_etiquette() const { return star_ref->get_etiquette(); };
infinint get_etoile_ref_count() const { return star_ref->get_ref_count(); };
cat_etoile *get_etoile() const { return star_ref; };
bool is_inode_counted() const { return star_ref->is_counted(); };
bool is_inode_wrote() const { return star_ref->is_wrote(); };
bool is_inode_dumped() const { return star_ref->is_dumped(); };
void set_inode_counted(bool val) const { star_ref->set_counted(val); };
void set_inode_wrote(bool val) const { star_ref->set_wrote(val); };
void set_inode_dumped(bool val) const { star_ref->set_dumped(val); };
virtual void post_constructor(const pile_descriptor & pdesc) override;
bool is_first_mirage() const { return star_ref->get_first_ref() == this; };
// overwriting virtual method from cat_entree
virtual void change_location(const smart_pointer<pile_descriptor> & pdesc) override { get_inode()->change_location(pdesc); };
void disable_reduction_to_normal_inode() { star_ref->disable_reduction_to_normal_inode(); };
protected:
virtual void inherited_dump(const pile_descriptor & pdesc, bool small) const override;
private:
cat_etoile *star_ref;
void init(const std::shared_ptr<user_interaction> & dialog,
const smart_pointer<pile_descriptor> & pdesc,
const archive_version & reading_ver,
saved_status saved,
entree_stats & stats,
std::map <infinint, cat_etoile *> & corres,
compression default_algo,
mirage_format fmt,
bool lax,
bool small);
void dup_on(cat_etoile * ref);
};
} // end of namespace
#endif
cat_etoile.hpp
class holding an cat_inode object that get pointed by multiple mirage objects (smart pointers) to rec...
cat_nomme.hpp
base class of all objects contained in a catalogue and that can be named
libdar::archive_version
class archive_version manages the version of the archive format
Definition: archive_version.hpp:47
libdar::cat_entree
the root class from all other inherite for any entry in the catalogue
Definition: cat_entree.hpp:60
libdar::cat_entree::change_location
virtual void change_location(const smart_pointer< pile_descriptor > &pdesc)
libdar::cat_etoile
the hard link implementation
Definition: cat_etoile.hpp:48
libdar::cat_inode
the root class for all cat_inode
Definition: cat_inode.hpp:53
libdar::cat_mirage
the hard link implementation, cat_mirage is the named entry owned by a directory it points to a commo...
Definition: cat_mirage.hpp:48
libdar::cat_mirage::get_description
virtual std::string get_description() const override
inherited class designation
Definition: cat_mirage.hpp:84
libdar::cat_mirage::mirage_format
mirage_format
format of mirage
Definition: cat_mirage.hpp:51
libdar::cat_mirage::fmt_hard_link
@ fmt_hard_link
old dual format
Definition: cat_mirage.hpp:52
libdar::cat_mirage::fmt_mirage
@ fmt_mirage
new format
Definition: cat_mirage.hpp:51
libdar::cat_mirage::post_constructor
virtual void post_constructor(const pile_descriptor &pdesc) override
let inherited classes build object's data after CRC has been read from file in small read mode
libdar::cat_mirage::operator==
virtual bool operator==(const cat_entree &ref) const override
returns true if the two object are the same
libdar::cat_mirage::change_location
virtual void change_location(const smart_pointer< pile_descriptor > &pdesc) override
Definition: cat_mirage.hpp:106
libdar::cat_mirage::inherited_dump
virtual void inherited_dump(const pile_descriptor &pdesc, bool small) const override
inherited class may overload this method but shall first call the parent's inherited_dump() in the ov...
libdar::cat_mirage::clone
virtual cat_entree * clone() const override
a way to copy the exact type of an object even if pointed to by a parent class pointer
Definition: cat_mirage.hpp:86
libdar::cat_mirage::is_first_mirage
bool is_first_mirage() const
whether we are the mirage that triggered this hard link creation
Definition: cat_mirage.hpp:103
libdar::cat_mirage::disable_reduction_to_normal_inode
void disable_reduction_to_normal_inode()
always write the inode as a hardlinked inode
Definition: cat_mirage.hpp:117
libdar::cat_mirage::signature
virtual unsigned char signature() const override
inherited class signature
Definition: cat_mirage.hpp:83
libdar::cat_nomme
the base class for all entry that have a name
Definition: cat_nomme.hpp:45
libdar::smart_pointer< pile_descriptor >
libdar::compression
compression
the different compression algorithm available
Definition: compression.hpp:46
libdar::saved_status
saved_status
data saved status for an entry
Definition: cat_status.hpp:45
libdar::saved_status::saved
@ saved
inode is saved in the archive
libdar
libdar namespace encapsulate all libdar symbols
Definition: archive.hpp:47
libdar::entree_stats
holds the statistics contents of a catalogue
Definition: entree_stats.hpp:49