#include <stats.h>
Public Methods | |
Stats (const Configuration &) | |
The configuration is copied locally. More... | |
void | add (const LogRecord &) |
Add whatever is needed from a logrecord to the various Count maps (see below). | |
void | print_dates (ostream &) const |
Auxiliary function for operator<<. | |
void | print_paths (ostream &) const |
Auxiliary function for operator<<. | |
void | print_domains (ostream &) const |
Auxiliary function for operator<<. | |
Private Types | |
typedef map<DatePattern,unsigned int> | DateCount |
The key of a DateCount map is a Date category vector. More... | |
typedef map<Path,unsigned int> | PathCount |
typedef map<Domain,unsigned int> | DomainCount |
Private Attributes | |
DateCount | dates_ |
PathCount | paths_ |
DomainCount | domains_ |
Configuration | configuration_ |
Copy of constructor parameter. | |
Friends | |
ostream& | operator<< (ostream &,const Stats &) |
Print stats information on ostream. |
Selected logrecords can be added using Stats::add, the contents of the database can be printed using operator<<.
Definition at line 16 of file stats.h.
|
The key of a DateCount map is a Date category vector. E.g. <1999>, <1999,6>, <1999,6,3>, <1999,6,3,10> (June 3, 1999 10:00), .. The value is the number of logrecords in this category that have been added . |
|
E.g. <""> ("/"), <"","a","b","c"> ("/a/b/c"). The value is the number of logrecords in this category that have been added . |
|
E.g. <"be"> (*.be), <"be","ac","vub"> (*.vub.ac.be), <"be","ac","vub","tinf2"> (tinf2.vub.ac.be). The value is the number of logrecords in this category that have been added . |
|
The configuration is copied locally. It is used to decide what aspects of an added logrecord will be stored and what information will be printed. Definition at line 6 of file stats.C. 00006 : configuration_(c) { 00007 } |
|
Add whatever is needed from a logrecord to the various Count maps (see below).
Definition at line 11 of file stats.C. Referenced by main().
00011 { 00012 // What we do depends on the requested configuration format. 00013 /* It would be more efficient to make these actual data members 00014 of Stat. That way, they would only be ``computed'' once. 00015 */ 00016 set<unsigned int> levels(configuration_.levels()); 00017 unsigned int max_level(configuration_.max_level()); 00018 00019 switch (configuration_.format()) { 00020 00021 case Configuration::DATE: { 00022 const DatePattern& d(r.date()); 00023 // We will have at most 4 components in a date vector. 00024 // This should become a symbolic constant in Configuration! 00025 unsigned int m(min(d.size(),max_level)); 00026 for (unsigned int l=1;(l<=m);++l) 00027 if (levels.count(l)) { 00028 DatePattern dp(d,l); 00029 ++dates_[dp]; 00030 } 00031 } 00032 break; 00033 00034 case Configuration::PATH: { 00035 const Path& path(r.path()); 00036 unsigned int m(min(path.size(),max_level)); 00037 for (unsigned int l=1; l<=m; ++l) 00038 if (levels.count(l)) { 00039 Path pp(path,l); 00040 ++paths_[pp]; 00041 } 00042 } 00043 break; 00044 00045 case Configuration::DOMAIN: { 00046 const Domain& domain(r.domain()); 00047 unsigned int sz(domain.size()); 00048 unsigned int m(min(sz,max_level)); 00049 for (unsigned int l=1; l<=m; ++l) { 00050 if (levels.count(l)) { 00051 Domain dom(domain,l); 00052 ++(domains_[dom]); 00053 } 00054 } 00055 } 00056 break; 00057 00058 case Configuration::NONE: 00059 break; 00060 } 00061 } |
|
Auxiliary function for operator<<.
Definition at line 65 of file stats.C. Referenced by operator<<().
00065 { 00066 for (DateCount::const_iterator i=dates_.begin(); i!=dates_.end(); ++i) { 00067 const DatePattern& d((*i).first); 00068 os << d << "\t" << (*i).second << "\n"; 00069 } 00070 } |
|
Auxiliary function for operator<<.
Definition at line 74 of file stats.C. Referenced by operator<<().
00074 { 00075 for (PathCount::const_iterator i=paths_.begin(); i!=paths_.end(); ++i) { 00076 const Path& path((*i).first); 00077 os << path << "\t" << (*i).second << "\n"; 00078 } 00079 } |
|
Auxiliary function for operator<<.
Definition at line 83 of file stats.C. Referenced by operator<<().
00083 { 00084 for (DomainCount::const_iterator i=domains_.begin(); i!=domains_.end(); ++i) { 00085 const Domain& domain((*i).first); 00086 os << domain << "\t" << (*i).second << "\n"; 00087 } 00088 } |
|
Print stats information on ostream.
Definition at line 92 of file stats.C. 00092 { 00093 switch (stats.configuration_.format()) { 00094 case Configuration::DATE: 00095 stats.print_dates(os); 00096 break; 00097 case Configuration::PATH: 00098 stats.print_paths(os); 00099 break; 00100 case Configuration::DOMAIN: 00101 stats.print_domains(os); 00102 break; 00103 case Configuration::NONE: 00104 break; 00105 } 00106 return os; 00107 } |
|
|
|
|
|
|
|
Copy of constructor parameter.
|