ITK  4.2.0
Insight Segmentation and Registration Toolkit
itkSmapsFileParser.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 __itkSmapsFileParser_h
19 #define __itkSmapsFileParser_h
20 
21 #include "itkMacro.h"
22 #include "itkIntTypes.h"
23 
24 #include <string>
25 #include <vector>
26 #include <map>
27 #include <istream>
28 #include <iostream>
29 
30 namespace itk
31 {
38 class ITKCommon_EXPORT MapRecord
39 {
40 public:
42  virtual ~MapRecord();
45  void Reset(void);
46 
49  std::string m_RecordName;
50 
55  std::map< std::string, MemoryLoadType > m_Tokens;
56 };
57 
64 class ITKCommon_EXPORT SmapsRecord:public MapRecord
65 {
82  friend ITKCommon_EXPORT std::istream & operator>>(std::istream & in, SmapsRecord & record);
83 };
84 
91 class ITKCommon_EXPORT VMMapSummaryRecord:public MapRecord
92 {
98  friend ITKCommon_EXPORT std::istream & operator>>(std::istream & in, VMMapSummaryRecord & record);
99 };
100 
107 class ITKCommon_EXPORT VMMapRecord:public MapRecord
108 {
114  friend ITKCommon_EXPORT std::istream & operator>>(std::istream & in, VMMapRecord & record);
115 };
116 
125 class ITKCommon_EXPORT MapData
126 {
127 public:
130  //todo delete records
131  virtual ~MapData();
132 
134  virtual MemoryLoadType GetHeapUsage() = 0;
135 
137  virtual MemoryLoadType GetStackUsage() = 0;
138 
140  virtual MemoryLoadType GetTotalMemoryUsage();
141 
143  virtual MemoryLoadType GetMemoryUsage(const char *filter, const char *token);
144 
146  bool Empty();
147 
148 protected:
150  void Reset(void);
151 
152 protected:
153  typedef std::vector< MapRecord * > MapRecordVectorType;
154 
157 };
158 
164 class ITKCommon_EXPORT SmapsData_2_6:public MapData
165 {
166 public:
168 
169  virtual ~SmapsData_2_6();
170 
172  virtual MemoryLoadType GetHeapUsage();
173 
175  virtual MemoryLoadType GetStackUsage();
176 
178  friend ITKCommon_EXPORT std::istream & operator>>(std::istream & smapsStream,
179  SmapsData_2_6 & data);
180 
181 protected:
183 };
184 
193 class ITKCommon_EXPORT VMMapData_10_2:public MapData
194 {
195 public:
197  VMMapData_10_2();
198  virtual ~VMMapData_10_2();
199 
201  virtual MemoryLoadType GetHeapUsage();
202 
204  virtual MemoryLoadType GetStackUsage();
205 
207  friend ITKCommon_EXPORT std::istream & operator>>(std::istream & stream,
208  VMMapData_10_2 & data);
209 
210 protected:
212 };
213 
221 template< class TMapData >
222 class ITK_EXPORT MapFileParser
223 {
224 public:
225  typedef typename TMapData::MemoryLoadType MemoryLoadType;
226 
227  virtual ~MapFileParser();
232  virtual void ReadFile(const std::string & mapFileLocation = "") = 0;
233 
237  bool Update(void);
238 
242  MemoryLoadType GetHeapUsage();
243 
247  MemoryLoadType GetStackUsage();
248 
252  MemoryLoadType GetTotalMemoryUsage();
253 
257  MemoryLoadType GetMemoryUsage(const char *filter, const char *token = "Size");
258 
259 protected:
260  std::string m_MapFilePath; //< location of the last loaded Map file
261  TMapData m_MapData; //< data of the loaded smap file
262 };
263 
270 template< class TSmapsDataType >
271 class ITK_EXPORT SmapsFileParser:public MapFileParser< TSmapsDataType >
272 {
273 public:
274  virtual ~SmapsFileParser();
280  virtual void ReadFile(const std::string & mapFileLocation = "");
281 };
282 
288 template< class TVMMapDataType >
289 class ITK_EXPORT VMMapFileParser:public MapFileParser< TVMMapDataType >
290 {
291 public:
292  virtual ~VMMapFileParser();
296  virtual void ReadFile(const std::string & mapFileLocation = "");
297 };
298 } // end namespace itk
299 
300 #ifndef ITK_MANUAL_INSTANTIATION
301 #include "itkSmapsFileParser.hxx"
302 #endif
303 
304 #endif // __itkSmapsFileParser_h
305