00001 #ifndef StatCoder_HPP 00002 #define StatCoder_HPP 00003 00008 #include "common.hpp" 00009 #include <iostream> 00010 00011 00024 template <class CODER> 00025 class StatCoder : public CODER 00026 { 00027 public: 00028 typedef typename CODER::params_t params_t; 00029 StatCoder(const params_t* par) : CODER(par), first_run(true), 00030 nr_of_transactions(0), sum_of_tr_sizes(0){} 00031 template <class BIS> counter_t nextTransactionBIS( BIS& transaction ) 00032 { 00033 if(first_run) 00034 { 00035 counter_t return_value = CODER::nextTransactionBIS(transaction); 00036 if(return_value) 00037 { 00038 ++nr_of_transactions; 00039 sum_of_tr_sizes += transaction.size(); 00040 } 00041 else 00042 { 00043 log_info(0,"Average size of the coded/filtered transactions: %lg", static_cast<double>(sum_of_tr_sizes)/nr_of_transactions); 00044 first_run = false; 00045 } 00046 return return_value; 00047 } 00048 else 00049 return CODER::nextTransactionBIS(transaction); 00050 00051 } 00052 template <class UAC> counter_t nextTransactionUAC( UAC& transaction ) 00053 { 00054 if(first_run) 00055 { 00056 counter_t return_value = CODER::nextTransactionUAC(transaction); 00057 if(return_value) 00058 { 00059 ++nr_of_transactions; 00060 sum_of_tr_sizes += transaction.size(); 00061 } 00062 else 00063 first_run = false; 00064 return return_value; 00065 } 00066 else 00067 return CODER::nextTransactionUAC(transaction); 00068 } 00069 00070 protected: 00071 bool first_run; 00072 unsigned int nr_of_transactions; 00073 unsigned int sum_of_tr_sizes; 00074 }; 00075 00076 00077 #endif