1 /* 2 SRG - Squid Report Generator 3 Template class for an srg report, this class should be used 4 as a base. IE. you should create a class that inherits from 5 this one. 6 Copyright 2005 University of Waikato 7 8 This file is part of SRG. 9 10 SRG is free software; you can redistribute it and/or modify 11 it under the terms of the GNU General Public License as published by 12 the Free Software Foundation; either version 2 of the License, or 13 (at your option) any later version. 14 15 SRG is distributed in the hope that it will be useful, 16 but WITHOUT ANY WARRANTY; without even the implied warranty of 17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 GNU General Public License for more details. 19 20 You should have received a copy of the GNU General Public License 21 along with SRG; if not, write to the Free Software 22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 23 24 */ 25 #ifndef REPORT_H 26 #define REPORT_H 27 28 #include "srg.h" 29 #include <functional> 30 31 template <typename T> 32 struct LessByBytesTransferred: binary_function<T const *, T const *, bool> 33 { operatorLessByBytesTransferred34 bool operator()(T *x, T *y) const 35 { 36 summary_info xstats = x->getStats(); 37 summary_info ystats = y->getStats(); 38 return less<unsigned long long>()(ystats.bytesTransferred, 39 xstats.bytesTransferred); 40 } 41 }; 42 template <typename T> 43 struct LessByBytesMissed: binary_function<T const *, T const *, bool> 44 { operatorLessByBytesMissed45 bool operator()(T *x, T *y) const 46 { 47 summary_info xstats = x->getStats(); 48 summary_info ystats = y->getStats(); 49 return less<unsigned long long>()(ystats.bytesMissed, 50 xstats.bytesMissed); 51 } 52 }; 53 54 55 class Report { 56 57 public: 58 59 Report(char * name); 60 ~Report(); 61 62 void process_line(const log_line *line); 63 summary_info getStats(); 64 void updateStats(); 65 char * getName(); 66 void generate_report(char *); 67 bool create_files(const log_line *line); 68 69 protected: 70 71 void zeroStats(); 72 73 char * mName; 74 summary_info stats; 75 76 }; 77 78 #endif // REPORT_H 79