ITK  4.3.0
Insight Segmentation and Registration Toolkit
itkMemoryUsageObserver.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef __itkMemoryUsageObserver_h
19 #define __itkMemoryUsageObserver_h
20 
21 #include "itkConfigure.h"
22 #include "itkMacro.h"
23 #include "itkObject.h"
24 #include "itkObjectFactory.h"
25 #include "itkIntTypes.h"
26 
27 #if defined( WIN32 ) || defined( _WIN32 )
28  #include <windows.h>
29  #define SUPPORT_TOOLHELP32
30  #if defined( SUPPORT_TOOLHELP32 )
31 typedef LONG NTSTATUS;
32  #endif
33 #endif
34 
35 namespace itk
36 {
46 class ITKCommon_EXPORT MemoryUsageObserverBase
47 {
48 public:
51 
53  virtual ~MemoryUsageObserverBase();
54 
56  virtual MemoryLoadType GetMemoryUsage() = 0;
57 };
58 
59 #if defined( WIN32 ) || defined( _WIN32 )
60 class ITKCommon_EXPORT WindowsMemoryUsageObserver:public MemoryUsageObserverBase
61 {
62 public:
63  WindowsMemoryUsageObserver();
65  virtual ~WindowsMemoryUsageObserver();
66 
68  virtual MemoryLoadType GetMemoryUsage();
69 
70 protected:
71 #if defined( SUPPORT_TOOLHELP32 )
72  typedef NTSTATUS ( WINAPI * PZwQuerySystemInformation )(UINT, PVOID, ULONG, PULONG);
73 
74  // handle ntdll.dll library
75  HMODULE m_hNTLib;
76  // Windows native API function to query system information
77  PZwQuerySystemInformation ZwQuerySystemInformation;
78 #endif // defined(SUPPORT_TOOLHELP32)
79 };
80 #endif // defined(WIN32) || defined(_WIN32)
81 
82 #ifdef linux
83 class ITKCommon_EXPORT LinuxMemoryUsageObserver:public MemoryUsageObserverBase
84 {
85 public:
87  virtual ~LinuxMemoryUsageObserver();
88  virtual MemoryLoadType GetMemoryUsage();
89 };
90 #endif // linux
91 
92 
93 #if defined( __APPLE__ )
94 class ITKCommon_EXPORT MacOSXMemoryUsageObserver:public MemoryUsageObserverBase
95 {
96 public:
98  virtual ~MacOSXMemoryUsageObserver();
99  virtual MemoryLoadType GetMemoryUsage();
100 };
101 #endif // Mac OS X
102 
103 
104 #if defined( __SUNPRO_CC ) || defined ( __sun__ )
105 class ITKCommon_EXPORT SunSolarisMemoryUsageObserver:public MemoryUsageObserverBase
106 {
107 public:
109  virtual ~SunSolarisMemoryUsageObserver();
110  virtual MemoryLoadType GetMemoryUsage();
111 };
112 #endif // Sun Solaris
113 
114 
115 #if !defined( WIN32 ) && !defined( _WIN32 )
117 {
118 public:
121  virtual MemoryLoadType GetMemoryUsage();
122 };
123 #if !defined( __APPLE__ ) && !defined( __SUNPRO_CC ) && !defined ( __sun__ ) && !defined( __FreeBSD__ ) \
124  && !defined( __OpenBSD__ )
125 
128 
141 
147