#include <stats.h>
Public Methods | |
Stats (const Configuration &) | |
The configuration is copied locally. | |
void | add (const LogRecord &) |
Add whatever is needed from a logrecord to the various Count maps (see below). More... | |
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 |
The key of a PathCount map is a path category vector. More... | |
typedef map<Domain,unsigned int> | DomainCount |
The key of a DomainCount map is a domain category vector. More... | |
Private Attributes | |
DateCount | dates_ |
PathCount | paths_ |
DomainCount | domains_ |
Configuration | configuration_ |
Copy of the ctor parameter. | |
Friends | |
ostream& | operator<< (ostream &,const Stats &) |
Print stats information on ostream. More... |
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 . |
|
The key of a PathCount map is a path category vector. E.g. <""> ("/"), <"","a","b","c"> ("/a/b/c"). The value is the number of logrecords in this category that have been added . |
|
The key of a DomainCount map is a domain category vector. <"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.
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). The decision on which map to add to depends on configuration_. 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 } |
|
Auxiliary function for operator<<.
Definition at line 62 of file stats.C. Referenced by operator<<().
00062 { 00063 for (DateCount::const_iterator i=dates_.begin(); i!=dates_.end(); ++i) { 00064 const DatePattern& d((*i).first); 00065 os << d << "\t" << (*i).second << "\n"; 00066 } 00067 } |
|
Auxiliary function for operator<<.
Definition at line 71 of file stats.C. Referenced by operator<<().
00071 { 00072 for (PathCount::const_iterator i=paths_.begin(); i!=paths_.end(); ++i) { 00073 const Path& path((*i).first); 00074 os << path << "\t" << (*i).second << "\n"; 00075 } 00076 } |
|
Auxiliary function for operator<<.
Definition at line 80 of file stats.C. Referenced by operator<<().
00080 { 00081 for (DomainCount::const_iterator i=domains_.begin(); i!=domains_.end(); ++i) { 00082 const Domain& domain((*i).first); 00083 os << domain << "\t" << (*i).second << "\n"; 00084 } 00085 } |
|
Print stats information on ostream. What information (dates, paths or domains) depends on configuration_. Definition at line 89 of file stats.C. 00089 { 00090 switch (stats.configuration_.format()) { 00091 case Configuration::DATE: 00092 stats.print_dates(os); 00093 break; 00094 case Configuration::PATH: 00095 stats.print_paths(os); 00096 break; 00097 case Configuration::DOMAIN: 00098 stats.print_domains(os); 00099 break; 00100 } 00101 return os; 00102 } |
|
|
|
|
|
|
|
Copy of the ctor parameter.
|