"Fossies" - the Fresh Open Source Software Archive

Member "srg-1.3.6/src/Report.cc" (5 Aug 2009, 2103 Bytes) of package /linux/privat/old/srg-1.3.6.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 /*
    2     SRG - Squid Report Generator
    3     Report template
    4     Copyright 2005 University of Waikato
    5 
    6     This file is part of SRG.
    7 
    8     SRG is free software; you can redistribute it and/or modify
    9     it under the terms of the GNU General Public License as published by
   10     the Free Software Foundation; either version 2 of the License, or
   11     (at your option) any later version.
   12 
   13     SRG is distributed in the hope that it will be useful,
   14     but WITHOUT ANY WARRANTY; without even the implied warranty of
   15      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   16     GNU General Public License for more details.
   17 
   18     You should have received a copy of the GNU General Public License
   19     along with SRG; if not, write to the Free Software
   20     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 
   21     USA
   22 
   23 */
   24 
   25 #include "Report.h"
   26 #include "srg.h"
   27 #include "prototypes.h"
   28 
   29 /* Default constructor */
   30 Report::Report(char* name) {
   31 
   32     mName = strdup(name);
   33     zeroStats();
   34 
   35     if (srg.debug)
   36         fprintf(stderr, "Creating Report: %s\n", mName);
   37 
   38 }
   39 Report::~Report() {
   40     free(mName);
   41 }
   42 
   43 /* Adds a new log line to the report */
   44 void Report::process_line(const log_line *line) {
   45 
   46     if (srg.debug)
   47         fprintf(stderr, "In process_line for report '%s'\n", mName);
   48 
   49     //stats.connects++;
   50     stats.bytesTransferred += line->size;
   51     stats.timeSpent += line->elapsedTime;
   52     if (is_cache_hit(line->resultCode)) {
   53         stats.hits++;
   54         stats.bytesHit+=line->size;
   55     } else {
   56         stats.misses++;
   57         stats.bytesMissed+=line->size;
   58     }
   59     if (is_cache_denied(line->resultCode)) {
   60         stats.deniedHits++;
   61     }
   62       
   63 }
   64 
   65 /* Get statistics about this report */
   66 summary_info Report::getStats() {
   67   
   68     summary_info returnInfo;
   69 
   70     updateStats();
   71 
   72     returnInfo = stats;
   73 
   74     return returnInfo;
   75 
   76 }
   77 
   78 /* Update the statistics */
   79 void Report::updateStats() {
   80     /* Do nothing here */
   81 }
   82 
   83 /* Reset the statistics */
   84 void Report::zeroStats() {
   85     stats.connects = 0;
   86     stats.bytesTransferred = 0;
   87     stats.timeSpent = 0;
   88     stats.hits = 0;
   89     stats.bytesHit = 0;
   90     stats.misses = 0;
   91     stats.bytesMissed = 0;
   92     stats.deniedHits = 0;
   93 }
   94 
   95 /* Get the name of this report */
   96 char * Report::getName() {
   97     return mName;
   98 }