rvm  1.11
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Go to the documentation of this file.
1 #ifndef __reporter_h__
2 #define __reporter_h__
4 #include <string>
5 #include <vector>
7 #include "asserts.h"
8 #include "types.h"
9 #include "timer.h"
10 #include "table.h"
12 /** Vault stats report */
14 {
15 public:
17  vault_stats_report(const vault_stats_report& a_class);
19  const std::string& a_message,
20  const filesystem& a_class
21  );
24  void clear(void);
26  void assign(
27  const vault_stats_report& a_class
28  );
29  void assign(
30  const std::string& a_message,
31  const filesystem& a_class
32  );
33  void assign(
34  const std::string& a_message,
35  const uint64 a_total_blocks,
36  const uint64 a_free_blocks,
37  const uint64 a_total_inodes,
38  const uint64 a_free_inodes
39  );
40  void assign(
41  const std::string& a_message,
42  const std::string& a_time,
43  const uint64 a_total_blocks,
44  const uint64 a_free_blocks,
45  const uint64 a_total_inodes,
46  const uint64 a_free_inodes
47  );
49  const std::string& time(void) const;
50  const std::string& message(void) const;
51  const uint64 total_blocks(void) const;
52  const uint64 free_blocks(void) const;
53  const uint64 total_inodes(void) const;
54  const uint64 free_inodes(void) const;
58 private:
59  std::string m_time;
60  std::string m_message;
62  uint64 m_free_blocks;
64  uint64 m_free_inodes;
65 };
67 /** Vault selection and usage report */
69 {
70 public:
71  vault_report();
72  ~vault_report();
74  void clear(void);
76  void add_report(const vault_stats_report& a_class);
78  void write_report(std::ostream& a_out);
80  void format_synopsis(table& a_table);
81 private:
82  std::vector<vault_stats_report> m_reports;
83 };
85 /** Job report for an rsync run on a single path */
87 {
88 public:
90  job_path_report(const job_path_report& a_class);
92  const std::string a_source,
93  const timer a_time,
94  const uint16 a_exit_code,
95  const uint16 a_signal_num,
96  const rsync_behavior::value_type a_behavior,
97  const std::string a_error_message
98  );
101  void clear(void);
103  void assign(const job_path_report& a_class);
104  void assign(
105  const std::string a_source,
106  const timer a_time,
107  const uint16 a_exit_code,
108  const uint16 a_signal_num,
109  const rsync_behavior::value_type a_behavior,
110  const std::string a_error_message
111  );
113  const bool status(void) const;
114  void source(const std::string& a_class);
115  const std::string& source(void) const;
116  void time(const timer& a_class);
117  const timer& time(void) const;
118  void exit_code(const int a_exit_code);
119  const int exit_code(void) const;
120  void signal_num(const int a_signal_num);
121  const int signal_num(void) const;
122  const rsync_behavior::value_type behavior(void) const;
123  void error_msg(const std::string& a_class);
124  const std::string& error_msg(void) const;
126  job_path_report& operator=(const job_path_report& a_class);
128 private:
129  std::string m_source;
133  std::string m_error_msg;
135 };
137 /** Submit or parse a job path report */
138 class reportio
139 {
140 public:
141  enum source_type {
144  };
145  static const char *tags[];
147  void write_rsync_out(const std::string& a_str);
148  void write_rsync_err(const std::string& a_str);
149  void write_report(
150  const std::string a_source,
151  const timer& a_timer,
152  const int a_exit_code,
153  const int a_signal_num,
154  const rsync_behavior::value_type& a_behavior,
155  const std::string& a_error_msg
156  );
158  job_path_report parse(const std::string& a_str);
160  bool is_report(const std::string& a_str);
161 };
163 /** A single job report */
165 {
166 public:
170  void clear(void);
172  void add_report(const job_path_report& a_class);
173  const std::vector<job_path_report>& reports(void) const;
175  void id(const std::string& a_str);
176  const std::string& id(void) const;
178  const bool status(void) const;
180 private:
181  std::vector<job_path_report> m_reports;
182  std::string m_id;
183 };
185 /** All job reports */
187 {
188 public:
189  jobs_report();
190  ~jobs_report();
192  void clear(void);
194  void add_report(const single_job_report& a_class);
195  const std::vector<single_job_report>& reports(void) const;
197  void write_report(std::ostream& a_out);
199  void format_synopsis(table& a_table);
201 private:
202  std::vector<single_job_report> m_jobs;
203 };
205 /** The report manager
207  Process reports coming in both from the parent and from children, then
208  format and print a finalized report.
209  */
211 {
212 public:
213  report_manager();
214  ~report_manager();
216  void init(void);
217  const bool initialized(void) const;
218  void clear(void);
220  void set_total_time(const timer& a_class);
222  vault_report& vault(void);
223  jobs_report& jobs(void);
225  void print_report(void);
226  void file_report(void);
227  void write_report(std::ostream& a_out);
229  void format_synopsis(table& a_table);
231 private:
237  void mf_write_header(std::ostream& a_out);
238  void mf_write_synopsis(std::ostream& a_out);
239 };
241 extern report_manager reporter;
243 #endif
Definition: reporter.cc:672
Retrieve information about a filesystem.
Definition: fs.h:316
job_path_report parse(const std::string &a_str)
Parse a received report from a child process and return a job_path_report.
Definition: reporter.cc:571
uint64 m_free_blocks
Definition: reporter.h:62
Vault selection and usage report.
Definition: reporter.h:68
void clear(void)
Clear all values.
Definition: reporter.cc:683
Basic types definitions and templates.
const uint64 free_inodes(void) const
Return the number of free inodes in the vault.
Definition: reporter.cc:143
const std::string & error_msg(void) const
Return the error message.
Definition: reporter.cc:493
void write_report(std::ostream &a_out)
Format job reports and output to the given stream.
Definition: reporter.cc:760
void add_report(const single_job_report &a_class)
Add a job report to the list.
Definition: reporter.cc:748
report_manager reporter
The global report manager.
Definition: reporter.cc:1124
Submit or parse a job path report.
Definition: reporter.h:138
std::vector< vault_stats_report > m_reports
Definition: reporter.h:82
Definition: reporter.cc:926
job_path_report & operator=(const job_path_report &a_class)
Assignment operator.
Definition: reporter.cc:499
void format_synopsis(table &a_table)
Generate a synopsis report.
Definition: reporter.cc:318
Definition: reporter.cc:26
A single job report.
Definition: reporter.h:164
void write_rsync_err(const std::string &a_str)
Write a report line for output from rsync to parent on child's std::cerr.
Definition: reporter.cc:525
jobs_report m_jobs
Definition: reporter.h:235
void mf_write_synopsis(std::ostream &a_out)
Definition: reporter.cc:1109
const rsync_behavior::value_type behavior(void) const
void write_report(std::ostream &a_out)
Write report to the given stream.
Definition: reporter.cc:1043
Definition: reporter.cc:165
const std::vector< single_job_report > & reports(void) const
Return a const vector of all job reports.
Definition: reporter.cc:754
const uint64 total_blocks(void) const
Return the total number of blocks in the vault.
Definition: reporter.cc:125
const std::vector< job_path_report > & reports(void) const
Return a const vector of all path reports.
Definition: reporter.cc:696
void write_report(std::ostream &a_out)
Format and print the vault report to the given stream.
Definition: reporter.cc:184
uint64 m_free_inodes
Definition: reporter.h:64
Definition: reporter.cc:731
void set_total_time(const timer &a_class)
Report the overall RVM time.
Definition: reporter.cc:960
rsync_behavior::value_type m_behavior
Definition: reporter.h:134
std::string m_time
Definition: reporter.h:59
const bool status(void) const
Return true if rsync succeeded archiving this path.
Definition: reporter.cc:414
Vault stats report.
Definition: reporter.h:13
void clear(void)
Clear all values.
Definition: reporter.cc:952
void clear(void)
Clear all values.
Definition: reporter.cc:54
jobs_report & jobs(void)
Return the jobs reporter object.
Definition: reporter.cc:975
uint64 m_total_inodes
Definition: reporter.h:63
void file_report(void)
Save report to a file.
Definition: reporter.cc:998
timer m_total_time
Definition: reporter.h:233
const std::string & message(void) const
Return the message.
Definition: reporter.cc:119
vault_report m_vault
Definition: reporter.h:234
All job reports.
Definition: reporter.h:186
Definition: reporter.cc:49
vault_stats_report & operator=(const vault_stats_report &a_class)
Assignment operator.
Definition: reporter.cc:150
void add_report(const job_path_report &a_class)
Add a path report for this job.
Definition: reporter.cc:690
Definition: reporter.cc:737
const std::string & source(void) const
Return a string of the path archived.
Definition: reporter.cc:445
void clear(void)
Clear all values.
Definition: reporter.cc:372
void assign(const vault_stats_report &a_class)
Definition: reporter.cc:63
Definition: reporter.cc:678
const std::string & time(void) const
Return a string timestamp.
Definition: reporter.cc:113
Job report for an rsync run on a single path.
Definition: reporter.h:86
const std::string & id(void) const
Return the descriptive id for this job report.
Definition: reporter.cc:708
void format_synopsis(table &a_table)
Generate a synopsis report.
Definition: reporter.cc:1066
static const char * tags[]
Report type tags.
Definition: reporter.h:145
std::string m_source
Definition: reporter.h:129
Definition: reporter.cc:333
std::vector< job_path_report > m_reports
Definition: reporter.h:181
vault_report & vault(void)
Return the vault reporter object.
Definition: reporter.cc:969
The report manager.
Definition: reporter.h:210
void write_report(const std::string a_source, const timer &a_timer, const int a_exit_code, const int a_signal_num, const rsync_behavior::value_type &a_behavior, const std::string &a_error_msg)
Generate and submit a report to the parent process on child's std::cout.
Definition: reporter.cc:534
void print_report(void)
Print report to standard output.
Definition: reporter.cc:981
Definition: reporter.cc:159
void format_synopsis(table &a_table)
Generate a synopsis report.
Definition: reporter.cc:894
void clear(void)
Clear all values.
Definition: reporter.cc:170
const uint64 total_inodes(void) const
Return the total number of inodes in the vault.
Definition: reporter.cc:137
void assign(const job_path_report &a_class)
Definition: reporter.cc:383
Definition: reporter.cc:932
void add_report(const vault_stats_report &a_class)
Add a vault report to the list.
Definition: reporter.cc:176
const timer & time(void) const
Return the timer object for this report.
Definition: reporter.cc:457
const int signal_num(void) const
Return rsync's signal number.
Definition: reporter.cc:481
std::vector< single_job_report > m_jobs
Definition: reporter.h:202
std::string m_error_msg
Definition: reporter.h:133
void mf_write_header(std::ostream &a_out)
Definition: reporter.cc:1092
void clear(void)
Clear all values.
Definition: reporter.cc:742
bool is_report(const std::string &a_str)
Return true if the given string looks like a valid report.
Definition: reporter.cc:658
const uint64 free_blocks(void) const
Return the number of free blocks in the vault.
Definition: reporter.cc:131
bool m_initialized
Definition: reporter.h:232
std::string m_message
Definition: reporter.h:60
Definition: reporter.cc:367
void init(void)
Definition: reporter.cc:937
uint64 m_total_blocks
Definition: reporter.h:61
void write_rsync_out(const std::string &a_str)
Write a report line for output from rsync to parent on child's std::cout.
Definition: reporter.cc:516
Definition: table.h:96
const bool initialized(void) const
Return whether or not this object has been inintialized.
Definition: reporter.cc:946
Used as a stopwatch.
Definition: timer.h:29
std::string m_id
Definition: reporter.h:182
const bool status(void) const
If all path reports say that rsync was successful, then return true, else return false.
Definition: reporter.cc:715
const int exit_code(void) const
Return rsync's exit code.
Definition: reporter.cc:469