| Disk ARchive 2.6.11 Full featured and portable backup and archiving tool

cache_global.hpp
Go to the documentation of this file.
1 /*********************************************************************/
2 // dar - disk archive - a backup/restoration program
3 // Copyright (C) 2002-2020 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 : http://dar.linux.free.fr/email.html
20 /*********************************************************************/
21
25
26 #ifndef CACHE_GLOBAL_HPP
27 #define CACHE_GLOBAL_HPP
28
29 #include "../my_config.h"
30 #include "cache.hpp"
31 #include "fichier_global.hpp"
32
33 namespace libdar
34 {
35
38
40
41 class cache_global: public fichier_global
42 {
43 public:
44 static const U_I default_cache_size = 102400;
45
47
54 cache_global(const std::shared_ptr<user_interaction> & dialog, fichier_global *x_ptr, bool shift_mode, U_I size = default_cache_size);
55
57 cache_global(cache_global & ref) = delete;
58
60 cache_global(cache_global && ref) = delete;
61
63 cache_global & operator = (const cache_global & ref) = delete;
64
66 cache_global & operator = (cache_global && ref) = delete;
67
69 ~cache_global() { detruit(); };
70
71 // inherited from fichier_global
72
73 virtual void change_ownership(const std::string & user, const std::string & group) override { ptr->change_ownership(user, group); };
74 virtual void change_permission(U_I perm) override { ptr->change_permission(perm); };
75 virtual infinint get_size() const override { return ptr->get_size(); };
76 virtual void fadvise(advise adv) const override { ptr->fadvise(adv); };
77
78
79 // inherited from generic_file grand-parent class
80
81 virtual bool skippable(skippability direction, const infinint & amount) override { return buffer->skippable(direction, amount); };
82 virtual bool skip(const infinint & pos) override { return buffer->skip(pos); };
83 virtual bool skip_to_eof() override { return buffer->skip_to_eof(); };
84 virtual bool skip_relative(S_I x) override { return buffer->skip_relative(x); };
85 virtual infinint get_position() const override { return buffer->get_position(); };
86
87 // expose cache specific methods
88
89 void change_to_read_write() { buffer->change_to_read_write(); };
90
91 protected:
92
93 // inherited from fichier_global
94
95 virtual U_I fichier_global_inherited_write(const char *a, U_I size) override { buffer->write(a, size); return size; };
96 virtual bool fichier_global_inherited_read(char *a, U_I size, U_I & read, std::string & message) override { read = buffer->read(a, size); return true; };
97
98 // inherted from generic_file
99 virtual void inherited_read_ahead(const infinint & amount) override { buffer->read_ahead(amount); };
100 virtual void inherited_sync_write() override { buffer->sync_write(); ptr->sync_write(); };
101 virtual void inherited_flush_read() override { buffer->flush_read(); };
102 virtual void inherited_terminate() override { buffer->terminate(); ptr->terminate(); };
103
104
105 private:
106 cache *buffer;
107 fichier_global *ptr;
108
109 void detruit();
110 };
111
113
114 } // end of namespace
115
116 #endif
117
libdar::cache::skip_to_eof
virtual bool skip_to_eof() override
skip to the end of file
libdar::generic_file::write
virtual void write(const char *a, U_I size) override
write data to the generic_file inherited from proto_generic_file
libdar::cache_global::fichier_global_inherited_write
virtual U_I fichier_global_inherited_write(const char *a, U_I size) override
replaces generic_file::inherited_write() method, to allow the return of partial writings
Definition: cache_global.hpp:95
libdar::cache
the cache class implements a fixed length read/write caching mechanism
Definition: cache.hpp:53
libdar::cache_global::cache_global
cache_global(const std::shared_ptr< user_interaction > &dialog, fichier_global *x_ptr, bool shift_mode, U_I size=default_cache_size)
constructor
libdar::cache_global::change_permission
virtual void change_permission(U_I perm) override
change the permission of the file
Definition: cache_global.hpp:74
libdar::cache::skip
virtual bool skip(const infinint &pos) override
skip at the absolute position
libdar::cache_global::cache_global
cache_global(cache_global &ref)=delete
copy constructor
libdar::fichier_global::change_permission
virtual void change_permission(U_I perm)=0
change the permission of the file
libdar::infinint
the arbitrary large positive integer class
Definition: real_infinint.hpp:62
libdar::generic_file::flush_read
void flush_read()
be ready to read at current position, reseting all pending data for reading, cached and in compressio...
libdar::generic_file::sync_write
void sync_write()
write any pending data
libdar::fichier_global::advise
advise
Definition: fichier_global.hpp:62
libdar::fichier_global::change_ownership
virtual void change_ownership(const std::string &user, const std::string &group)=0
set the ownership of the file
libdar::cache_global
the cache_global cache is an adaptation of the cache class to the fichier_global interface
Definition: cache_global.hpp:42
libdar::cache_global::inherited_flush_read
virtual void inherited_flush_read() override
reset internal engine, flush caches in order to read the data at current position
Definition: cache_global.hpp:101
libdar::cache_global::change_ownership
virtual void change_ownership(const std::string &user, const std::string &group) override
set the ownership of the file
Definition: cache_global.hpp:73
fichier_global.hpp
class fichier_global definition. This class is a pure virtual class class fichier_global is an abstra...
libdar::cache_global::fadvise
virtual void fadvise(advise adv) const override
set posix_fadvise for the whole file
Definition: cache_global.hpp:76
libdar::cache_global::operator=
cache_global & operator=(const cache_global &ref)=delete
assignment operator
libdar::cache::skippable
virtual bool skippable(skippability direction, const infinint &amount) override
whether the implementation is able to skip
libdar::cache_global::cache_global
cache_global(cache_global &&ref)=delete
move constructor
libdar::generic_file::read_ahead
void read_ahead(const infinint &amount)
libdar::generic_file::terminate
void terminate()
destructor-like call, except that it is allowed to throw exceptions
libdar::cache_global::inherited_read_ahead
virtual void inherited_read_ahead(const infinint &amount) override
tells the object that several calls to read() will follow to probably obtain at least the given amoun...
Definition: cache_global.hpp:99
libdar::cache_global::~cache_global
~cache_global()
destructor
Definition: cache_global.hpp:69
libdar::generic_file::read
virtual U_I read(char *a, U_I size) override
read data from the generic_file inherited from proto_generic_file
libdar::cache_global::skippable
virtual bool skippable(skippability direction, const infinint &amount) override
whether the implementation is able to skip
Definition: cache_global.hpp:81
libdar::cache_global::skip
virtual bool skip(const infinint &pos) override
skip at the absolute position
Definition: cache_global.hpp:82
libdar::cache_global::fichier_global_inherited_read
virtual bool fichier_global_inherited_read(char *a, U_I size, U_I &read, std::string &message) override
replaces generic_file::inherited_read() method, to allow the return of partial reading
Definition: cache_global.hpp:96
libdar::fichier_global::fadvise
virtual void fadvise(advise adv) const =0
set posix_fadvise for the whole file
libdar::fichier_global
abstraction of filesystem files for entrepot
Definition: fichier_global.hpp:59
libdar::cache_global::inherited_sync_write
virtual void inherited_sync_write() override
write down any pending data
Definition: cache_global.hpp:100
libdar::cache_global::skip_to_eof
virtual bool skip_to_eof() override
skip to the end of file
Definition: cache_global.hpp:83
libdar::cache_global::skip_relative
virtual bool skip_relative(S_I x) override
skip relatively to the current position
Definition: cache_global.hpp:84
libdar::cache::get_position
virtual infinint get_position() const override
get the current read/write position
Definition: cache.hpp:72
libdar::cache_global::get_position
virtual infinint get_position() const override
get the current read/write position
Definition: cache_global.hpp:85
libdar::cache_global::inherited_terminate
virtual void inherited_terminate() override
destructor-like call, except that it is allowed to throw exceptions
Definition: cache_global.hpp:102
cache.hpp
contains the cache class
libdar::cache::skip_relative
virtual bool skip_relative(S_I x) override
skip relatively to the current position
libdar::cache_global::get_size
virtual infinint get_size() const override
return the size of the file
Definition: cache_global.hpp:75
libdar::fichier_global::get_size
virtual infinint get_size() const =0
return the size of the file
libdar
libdar namespace encapsulate all libdar symbols
Definition: archive.hpp:47