GlobalStatistics.h

Go to the documentation of this file.
00001 //
00002 // Copyright (C) 2007 Institut fuer Telematik, Universitaet Karlsruhe (TH)
00003 //
00004 // This program is free software; you can redistribute it and/or
00005 // modify it under the terms of the GNU General Public License
00006 // as published by the Free Software Foundation; either version 2
00007 // of the License, or (at your option) any later version.
00008 //
00009 // This program is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with this program; if not, write to the Free Software
00016 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00017 //
00018 
00024 #ifndef __GLOBALSTATISTICS_H__
00025 #define __GLOBALSTATISTICS_H__
00026 
00027 #include <map>
00028 
00029 #include <omnetpp.h>
00030 
00031 class OverlayKey;
00032 
00038 #define RECORD_STATS(x) \
00039     do { \
00040         if (globalStatistics->isMeasuring()){ x; } \
00041     } while(false)
00042 
00043 
00049 class GlobalStatistics : public cSimpleModule
00050 {
00051 public:
00052     double sentKBRTestAppMessages; 
00053     double deliveredKBRTestAppMessages; 
00054     int testCount;
00055     cOutVector currentDeliveryVector; 
00056 
00057 
00058     int nodesInitialized; 
00059     int nodesFinished; 
00060 
00064     ~GlobalStatistics();
00065 
00070     void doFinish();
00071 
00075     void addStdDev(const std::string& name, double value);
00076 
00077 
00081     void recordOutVector(const std::string& name, double value, int avg = -1);
00082 
00083     void startMeasuring();
00084 
00085     inline bool isMeasuring() { return measuring; };
00086     inline simtime_t getMeasureStartTime() { return measureStartTime; };
00087 
00088     simtime_t calcMeasuredLifetime(simtime_t creationTime);
00089 
00090 protected:
00091 
00092     struct OutVector 
00093     {
00094         cOutVector vector; 
00095         int count; 
00096         double value; 
00097         double avg;
00098 
00099         OutVector(const std::string& name) :
00100             vector(name.c_str()), count(0), value(0), avg(0) {};
00101     };
00102 
00103     std::map<std::string, cStdDev*> stdDevMap; 
00104     std::map<std::string, OutVector*> outVectorMap; 
00105     cMessage* globalStatTimer; 
00106     double globalStatTimerInterval; 
00107 
00111     virtual void initialize();
00112 
00116     virtual void handleMessage(cMessage* msg);
00117 
00121     virtual void finish();
00122 
00123     bool measuring;
00124     simtime_t measureStartTime;
00125 };
00126 
00127 #endif

Generated on Wed Mar 25 16:32:48 2009 for OverSim by  doxygen 1.5.5