00001 #ifndef RdbStats_H
00002 #define RdbStats_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #include <rdbxx/RDB.h>
00029 #include <cmath>
00030
00031 using namespace std;
00032
00038 class RdbStats {
00039
00040 public:
00041
00042 virtual ~RdbStats( ) throw( );
00043
00044 RdbStats( RDB& irdbtable, const string& name ) throw( Exception );
00045
00047 virtual int calculate_statistics( ) throw( );
00048
00050 double get_absolute_average( ) const { return fabs( the_statistics[AVG] ); }
00051
00052 virtual void init( ) throw( );
00053
00054 virtual void normalize_results( const double norm ) throw( );
00055
00056 virtual void set_output_columns( RDB& ordbtable ) throw( Exception );
00057
00059 virtual void update_statistics( ) throw( Exception );
00060
00061 private:
00062
00063
00064
00065 RDBColumn* input_column;
00066
00067
00068 vector<RDBColumn*> output_stats;
00069
00070 protected:
00071
00072 enum Stats { AVG, MAX, MIN, SD, SUM, SUM2, SUM_T };
00073
00074 double num_n;
00075
00076 string column_name;
00077
00078 double the_statistics[ 7 ];
00079
00080 double get_value( ) throw( Exception );
00081
00082 };
00083
00084 #endif