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

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

statistics.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 STATISTICS_HPP
27 #define STATISTICS_HPP
28
29 #include "../my_config.h"
30
31 #include "infinint.hpp"
32 #include "user_interaction.hpp"
33
34 extern "C"
35 {
36 #if MUTEX_WORKS
37 #if HAVE_PTHREAD_H
38 #include <pthread.h>
39 #endif
40 #endif
41 }
42
45
46 #if MUTEX_WORKS
47 #define LOCK_IN pthread_mutex_lock(&lock_mutex)
48 #define LOCK_OUT pthread_mutex_unlock(&lock_mutex)
49 #define LOCK_IN_CONST pthread_mutex_lock(const_cast<pthread_mutex_t *>(&lock_mutex))
50 #define LOCK_OUT_CONST pthread_mutex_unlock(const_cast<pthread_mutex_t *>(&lock_mutex))
51 #else
52 #define LOCK_IN //
53 #define LOCK_OUT //
54 #define LOCK_IN_CONST //
55 #define LOCK_OUT_CONST //
56 #endif
57
58 namespace libdar
59 {
60
62
66 // are their meaning see the archive class constructor and methods documentation
68 class statistics
69 {
70 public:
72
78 statistics(bool lock = true) { init(lock); clear(); };
79 statistics(const statistics & ref) { copy_from(ref); };
80 const statistics & operator = (const statistics & ref) { detruit(); copy_from(ref); return *this; };
81
83 ~statistics() { detruit(); };
84
86 void clear();
87
89 infinint total() const;
90
91 void incr_treated() { (this->*increment)(&treated); };
92 void incr_hard_links() { (this->*increment)(&hard_links); };
93 void incr_skipped() { (this->*increment)(&skipped); };
94 void incr_ignored() { (this->*increment)(&ignored); };
95 void incr_tooold() { (this->*increment)(&tooold); };
96 void incr_errored() { (this->*increment)(&errored); };
97 void incr_deleted() { (this->*increment)(&deleted); };
98 void incr_ea_treated() { (this->*increment)(&ea_treated); };
99 void incr_fsa_treated() { (this->*increment)(&fsa_treated); };
100
101 void add_to_ignored(const infinint & val) { (this->*add_to)(&ignored, val); };
102 void add_to_errored(const infinint & val) { (this->*add_to)(&errored, val); };
103 void add_to_deleted(const infinint & val) { (this->*add_to)(&deleted, val); };
104 void add_to_byte_amount(const infinint & val) { (this->*add_to)(&byte_amount, val); };
105
106 void sub_from_treated(const infinint & val) { (this->*sub_from)(&treated, val); };
107 void sub_from_ea_treated(const infinint & val) { (this->*sub_from)(&ea_treated, val); };
108 void sub_from_hard_links(const infinint & val) { (this->*sub_from)(&hard_links, val); };
109 void sub_from_fsa_treated(const infinint & val) { (this->*sub_from)(&fsa_treated, val); };
110
111 infinint get_treated() const { return (this->*returned)(&treated); };
112 infinint get_hard_links() const { return (this->*returned)(&hard_links); };
113 infinint get_skipped() const { return (this->*returned)(&skipped); };
114 infinint get_ignored() const { return (this->*returned)(&ignored); };
115 infinint get_tooold() const { return (this->*returned)(&tooold); };
116 infinint get_errored() const { return (this->*returned)(&errored); };
117 infinint get_deleted() const { return (this->*returned)(&deleted); };
118 infinint get_ea_treated() const { return (this->*returned)(&ea_treated); };
119 infinint get_byte_amount() const { return (this->*returned)(&byte_amount); };
120 infinint get_fsa_treated() const { return (this->*returned)(&fsa_treated); };
121
122 void decr_treated() { (this->*decrement)(&treated); };
123 void decr_hard_links() { (this->*decrement)(&hard_links); };
124 void decr_skipped() { (this->*decrement)(&skipped); };
125 void decr_ignored() { (this->*decrement)(&ignored); };
126 void decr_tooold() { (this->*decrement)(&tooold); };
127 void decr_errored() { (this->*decrement)(&errored); };
128 void decr_deleted() { (this->*decrement)(&deleted); };
129 void decr_ea_treated() { (this->*decrement)(&ea_treated); };
130 void decr_fsa_treated() { (this->*decrement)(&fsa_treated); };
131
132 void set_byte_amount(const infinint & val) { (this->*set_to)(&byte_amount, val); };
133
134 // debuging method
135 void dump(user_interaction & dialog) const;
136
137 private:
138 #if MUTEX_WORKS
139 pthread_mutex_t lock_mutex;
140 #endif
141 bool locking;
142
143 infinint treated;
144 infinint hard_links;
145 infinint skipped;
146 infinint ignored;
147 infinint tooold;
148 infinint errored;
149 infinint deleted;
150 infinint ea_treated;
151 infinint byte_amount;
152 infinint fsa_treated;
153
154
155 void (statistics::*increment)(infinint * var);
156 void (statistics::*add_to)(infinint * var, const infinint & val);
157 infinint (statistics::*returned)(const infinint * var) const;
158 void (statistics::*decrement)(infinint * var);
159 void (statistics::*set_to)(infinint * var, const infinint & val);
160 void (statistics::*sub_from)(infinint *var, const infinint & val);
161
162 void increment_locked(infinint * var)
163 {
164 LOCK_IN;
165 (*var)++;
166 LOCK_OUT;
167 };
168
169 void increment_unlocked(infinint * var)
170 {
171 (*var)++;
172 }
173
174 void add_to_locked(infinint * var, const infinint & val)
175 {
176 LOCK_IN;
177 (*var) += val;
178 LOCK_OUT;
179 }
180
181 void add_to_unlocked(infinint *var, const infinint & val)
182 {
183 (*var) += val;
184 }
185
186 infinint returned_locked(const infinint * var) const
187 {
188 infinint ret;
189
190 LOCK_IN_CONST;
191 ret = *var;
192 LOCK_OUT_CONST;
193
194 return ret;
195 };
196
197 infinint returned_unlocked(const infinint * var) const
198 {
199 return *var;
200 };
201
202 void decrement_locked(infinint * var)
203 {
204 LOCK_IN;
205 (*var)--;
206 LOCK_OUT;
207 }
208
209 void decrement_unlocked(infinint * var)
210 {
211 (*var)--;
212 }
213
214 void set_to_locked(infinint *var, const infinint & val)
215 {
216 LOCK_IN;
217 (*var) = val;
218 LOCK_OUT;
219 }
220
221 void set_to_unlocked(infinint *var, const infinint & val)
222 {
223 *var = val;
224 }
225
226 void sub_from_unlocked(infinint *var, const infinint & val)
227 {
228 *var -= val;
229 }
230
231 void sub_from_locked(infinint *var, const infinint & val)
232 {
233 LOCK_IN;
234 *var -= val;
235 LOCK_OUT;
236 }
237
238
239 void init(bool lock); // set locking & mutex
240 void detruit(); // release and free the mutex
241 void copy_from(const statistics & ref); // reset mutex and copy data from the object of reference
242
243 };
244
245 } // end of namespace
246
248
249 #endif
libdar::statistics::decr_deleted
void decr_deleted()
decrement by one the errored counter
Definition: statistics.hpp:128
libdar::statistics::get_skipped
infinint get_skipped() const
returns the current value of the hard_links counter
Definition: statistics.hpp:113
libdar::statistics::get_deleted
infinint get_deleted() const
returns the current value of the errored counter
Definition: statistics.hpp:117
libdar::statistics::decr_errored
void decr_errored()
decrement by one the toold counter
Definition: statistics.hpp:127
libdar::statistics::decr_skipped
void decr_skipped()
decrement by one the hard_links counter
Definition: statistics.hpp:124
libdar::statistics::clear
void clear()
reset counters to zero
libdar::statistics::decr_tooold
void decr_tooold()
decrement by one the ignored counter
Definition: statistics.hpp:126
libdar::statistics::get_fsa_treated
infinint get_fsa_treated() const
returns the current value of the byte_amount counter
Definition: statistics.hpp:120
libdar::statistics::incr_deleted
void incr_deleted()
increment by one the errored counter
Definition: statistics.hpp:97
libdar::statistics::get_ea_treated
infinint get_ea_treated() const
returns the current value of the deleted counter
Definition: statistics.hpp:118
libdar::statistics::add_to_ignored
void add_to_ignored(const infinint &val)
increment by one the fsa treated counter
Definition: statistics.hpp:101
libdar::statistics::sub_from_treated
void sub_from_treated(const infinint &val)
increment the byte amount counter by a given value
Definition: statistics.hpp:106
libdar::statistics::decr_hard_links
void decr_hard_links()
decrement by one the treated counter
Definition: statistics.hpp:123
libdar::statistics::~statistics
~statistics()
destructor
Definition: statistics.hpp:83
libdar::user_interaction
This is a pure virtual class that is used by libdar when interaction with the user is required...
Definition: user_interaction.hpp:98
libdar::statistics::get_tooold
infinint get_tooold() const
returns the current value of the ignored counter
Definition: statistics.hpp:115
libdar::statistics::incr_ea_treated
void incr_ea_treated()
increment by one the deleted counter
Definition: statistics.hpp:98
libdar::statistics::statistics
statistics(bool lock=true)
constructor
Definition: statistics.hpp:78
libdar::statistics::add_to_deleted
void add_to_deleted(const infinint &val)
increment the errored counter by a given value
Definition: statistics.hpp:103
libdar::statistics::get_byte_amount
infinint get_byte_amount() const
returns the current value of the ea_treated counter
Definition: statistics.hpp:119
libdar::statistics::incr_fsa_treated
void incr_fsa_treated()
increment by one the ea_treated counter
Definition: statistics.hpp:99
libdar::statistics::total
infinint total() const
total number of file treated
libdar::statistics::decr_treated
void decr_treated()
returns the current value of the fsa_treated counter
Definition: statistics.hpp:122
libdar::statistics::dump
void dump(user_interaction &dialog) const
set to the given value the byte_amount counter
user_interaction.hpp
defines the interaction between libdar and the user.Three classes are defined
libdar::statistics::incr_ignored
void incr_ignored()
increment by one the skipped counter
Definition: statistics.hpp:94
libdar::statistics::decr_ea_treated
void decr_ea_treated()
decrement by one the deleted counter
Definition: statistics.hpp:129
libdar::statistics::incr_skipped
void incr_skipped()
increment by one the hard_links counter
Definition: statistics.hpp:93
libdar::statistics::add_to_byte_amount
void add_to_byte_amount(const infinint &val)
increment the deleted counter by a given value
Definition: statistics.hpp:104
libdar::statistics::incr_hard_links
void incr_hard_links()
increment by one the treated counter
Definition: statistics.hpp:92
libdar::statistics::decr_fsa_treated
void decr_fsa_treated()
decrement by one the ea_treated counter
Definition: statistics.hpp:130
libdar::statistics::incr_errored
void incr_errored()
increment by one the tooold counter
Definition: statistics.hpp:96
libdar::statistics::incr_tooold
void incr_tooold()
increment by one the ignored counter
Definition: statistics.hpp:95
infinint.hpp
switch module to limitint (32 ou 64 bits integers) or infinint
libdar::statistics::get_ignored
infinint get_ignored() const
returns the current value of the skipped counter
Definition: statistics.hpp:114
libdar::statistics::get_hard_links
infinint get_hard_links() const
returns the current value of the treated counter
Definition: statistics.hpp:112
libdar::infinint
the arbitrary large positive integer class
Definition: real_infinint.hpp:59
libdar::statistics::set_byte_amount
void set_byte_amount(const infinint &val)
decrement by one the fsa_treated counter
Definition: statistics.hpp:132
libdar
libdar namespace encapsulate all libdar symbols
Definition: archive.hpp:47
libdar::statistics::decr_ignored
void decr_ignored()
decrement by one the skipped counter
Definition: statistics.hpp:125
libdar::statistics::get_errored
infinint get_errored() const
returns the current value of the tooold counter
Definition: statistics.hpp:116
libdar::statistics
structure returned by libdar call to give a summary of the operation done in term of file treated ...
Definition: statistics.hpp:68
libdar::statistics::add_to_errored
void add_to_errored(const infinint &val)
increment the ignored counter by a given value
Definition: statistics.hpp:102