Blender V2.61 - r43446

KX_TimeCategoryLogger.h

Go to the documentation of this file.
00001 /*
00002  * ***** BEGIN GPL LICENSE BLOCK *****
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 Foundation,
00016  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  *
00018  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
00019  * All rights reserved.
00020  *
00021  * The Original Code is: all of this file.
00022  *
00023  * Contributor(s): none yet.
00024  *
00025  * ***** END GPL LICENSE BLOCK *****
00026  */
00027 
00032 #ifndef __KX_TIME_CATEGORY_LOGGER_H
00033 #define __KX_TIME_CATEGORY_LOGGER_H
00034 
00035 #if defined(WIN32) && !defined(FREE_WINDOWS)
00036 #pragma warning (disable:4786) // suppress stl-MSVC debug info warning
00037 #endif
00038 
00039 #include <map>
00040 
00041 #include "KX_TimeLogger.h"
00042 
00049 class KX_TimeCategoryLogger {
00050 public:
00051     typedef int TimeCategory;
00052 
00057     KX_TimeCategoryLogger(unsigned int maxNumMeasurements = 10);
00058 
00062     virtual ~KX_TimeCategoryLogger(void);
00063 
00067     virtual void SetMaxNumMeasurements(unsigned int maxNumMeasurements);
00068 
00072     virtual unsigned int GetMaxNumMeasurements(void) const;
00073 
00078     virtual void AddCategory(TimeCategory tc);
00079 
00086     virtual void StartLog(TimeCategory tc, double now, bool endOtherCategories = true);
00087 
00093     virtual void EndLog(TimeCategory tc, double now);
00094 
00099     virtual void EndLog(double now);
00100 
00105     virtual void NextMeasurement(double now);
00106 
00111     virtual double GetAverage(TimeCategory tc);
00112 
00116     virtual double GetAverage(void);
00117 
00118 protected:
00122     virtual void DisposeLoggers(void);
00123 
00125     typedef std::map<TimeCategory, KX_TimeLogger*> KX_TimeLoggerMap;
00126     KX_TimeLoggerMap m_loggers;
00128     unsigned int m_maxNumMeasurements;
00129 
00130 
00131 #ifdef WITH_CXX_GUARDEDALLOC
00132 public:
00133     void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_TimeCategoryLogger"); }
00134     void operator delete( void *mem ) { MEM_freeN(mem); }
00135 #endif
00136 };
00137 
00138 #endif // __KX_TIME_CATEGORY_LOGGER_H
00139