00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef __itkMemoryUsageObserver_h
00019 #define __itkMemoryUsageObserver_h
00020
00021 #include "itkConfigure.h"
00022 #include "itkMacro.h"
00023 #include "itkObject.h"
00024 #include "itkObjectFactory.h"
00025
00026 #if defined(WIN32) || defined(_WIN32)
00027 #include <windows.h>
00028 #define SUPPORT_TOOLHELP32
00029 #if defined(SUPPORT_TOOLHELP32)
00030 typedef LONG NTSTATUS;
00031 #endif
00032 #endif
00033
00034 namespace itk
00035 {
00036
00045 class ITKCommon_EXPORT MemoryUsageObserverBase
00046 {
00047 public:
00049 typedef unsigned long MemoryLoadType;
00050
00052 virtual ~MemoryUsageObserverBase();
00053
00055 virtual MemoryLoadType GetMemoryUsage() = 0;
00056
00057 };
00058
00059 #if defined(WIN32) || defined(_WIN32)
00060 class ITKCommon_EXPORT WindowsMemoryUsageObserver:public MemoryUsageObserverBase
00061 {
00062 public:
00063 WindowsMemoryUsageObserver();
00065 virtual ~WindowsMemoryUsageObserver();
00066
00068 virtual MemoryLoadType GetMemoryUsage();
00069 protected:
00070 #if defined(SUPPORT_TOOLHELP32)
00071 typedef NTSTATUS (WINAPI * PZwQuerySystemInformation)(UINT, PVOID, ULONG, PULONG);
00073
00074
00075 HMODULE m_hNTLib;
00076
00077 PZwQuerySystemInformation ZwQuerySystemInformation;
00078 #endif // defined(SUPPORT_TOOLHELP32)
00079 };
00080 #endif // defined(WIN32) || defined(_WIN32)
00081
00082 #ifdef linux
00083 class ITKCommon_EXPORT LinuxMemoryUsageObserver:public MemoryUsageObserverBase
00084 {
00085 public:
00087 virtual ~LinuxMemoryUsageObserver();
00088 virtual MemoryLoadType GetMemoryUsage();
00089 };
00090 #endif // linux
00091
00092
00093 #if defined(__APPLE__) && MAC_OS_X_VERSION >= MAC_OS_X_VERSION_10_2
00094 class ITKCommon_EXPORT MacOSXMemoryUsageObserver:public MemoryUsageObserverBase
00095 {
00096 public:
00098 virtual ~MacOSXMemoryUsageObserver();
00099 virtual MemoryLoadType GetMemoryUsage();
00100 };
00101 #endif // Mac OS X
00102
00103
00104 #if defined(__SUNPRO_CC) || defined (__sun__)
00105 class ITKCommon_EXPORT SunSolarisMemoryUsageObserver:public MemoryUsageObserverBase
00106 {
00107 public:
00109 virtual ~SunSolarisMemoryUsageObserver();
00110 virtual MemoryLoadType GetMemoryUsage();
00111 };
00112 #endif // Sun Solaris
00113
00114
00115 #if !defined(WIN32) && !defined(_WIN32)
00116 class ITKCommon_EXPORT SysResourceMemoryUsageObserver:public MemoryUsageObserverBase
00117 {
00118 public:
00120 virtual ~SysResourceMemoryUsageObserver();
00121 virtual MemoryLoadType GetMemoryUsage();
00122 };
00123 #if !defined(__APPLE__) && !defined(__SUNPRO_CC) && !defined (__sun__) && !defined(__FreeBSD__)
00124
00127
00133
00138
00144
00152
00169