MeVisLabToolboxReference
MeVis/Foundation/Sources/MLProfilingManager/Include/mlMemoryProfile.h
Go to the documentation of this file.
00001 // **InsertLicense** code
00002 //----------------------------------------------------------------------------------
00003 // Class for collecting memory profiling information.
00004 //
00005 // \file    mlMemoryProfile.h
00006 // \author  Marcus Barann
00007 // \date    7/2009
00008 //
00009 //----------------------------------------------------------------------------------
00010 #ifndef _ML_MEMORY_PROFILE_H_
00011 #define _ML_MEMORY_PROFILE_H_
00012 
00013 #include "mlProfilingManagerDllExport.h"
00014 #include <string>
00015 
00016 
00017 typedef size_t MLProfilingMemoryType;
00018 
00019 
00020 class MLMemoryProfile;
00021 
00022 
00023 class MLPROFILINGMANAGER_EXPORT MLCurrentlyUsedMemoryTracker
00024 {
00025 public:
00026   MLCurrentlyUsedMemoryTracker() : _memoryProfile(NULL) { }
00027   virtual ~MLCurrentlyUsedMemoryTracker();
00028   virtual size_t getCurrentlyUsedMemory() const = 0;
00029 
00030 private:
00031   MLMemoryProfile* _memoryProfile;
00032 
00033   friend class MLMemoryProfile;
00034 };
00035 
00036 
00037 class MLPROFILINGMANAGER_EXPORT MLMemoryProfile
00038 {
00039 public:
00040   MLMemoryProfile(MLCurrentlyUsedMemoryTracker* tracker, const std::string& shortDescription);
00041   ~MLMemoryProfile();
00043   void addMemory(MLProfilingMemoryType memory);
00045   MLProfilingMemoryType getMemory() const;
00047   MLProfilingMemoryType getCurrentlyUsedMemory() const;
00049   void reset();
00050 
00051   const std::string& shortDescription() const { return _shortDescription; }
00052 
00053   const std::string& description() const { return _description; }
00054   void setDescription(const std::string& description_) { _description = description_; }
00055 
00056 private:
00057   void removeCurrentlyUsedMemoryTracker() { _currentlyUsedMemoryTracker = NULL; }
00058 
00059 private:
00060   MLProfilingMemoryType         _total;
00061   MLCurrentlyUsedMemoryTracker* _currentlyUsedMemoryTracker;
00062   std::string                   _description;
00063   std::string                   _shortDescription;
00064 
00065   friend class MLCurrentlyUsedMemoryTracker;
00066 };
00067 
00068 
00069 #endif // _ML_MEMORY_PROFILE_H_