Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkSmapsFileParser.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkSmapsFileParser.h,v $
00005   Language:  C++
00006   Date:      $Date: 2008-10-24 18:11:22 $
00007   Version:   $Revision: 1.1 $
00008 
00009   Copyright (c) Insight Software Consortium. All rights reserved.
00010   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00011 
00012      This software is distributed WITHOUT ANY WARRANTY; without even 
00013      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00014      PURPOSE.  See the above copyright notices for more information.
00015 
00016 =========================================================================*/
00017 #ifndef __itkSmapsFileParser_h
00018 #define __itkSmapsFileParser_h
00019 
00020 #include "itkConfigure.h"
00021 #include "itkWin32Header.h"
00022 #include "itkExceptionObject.h"
00023 
00024 #include <string>
00025 #include <vector>
00026 #include <map>
00027 #include <istream>
00028 #include <iostream>
00029 
00030 namespace itk {
00031 
00032 
00038 class ITKCommon_EXPORT MapRecord
00039 {
00040 public:
00041   typedef unsigned int  MemoryLoadType;
00042   virtual ~MapRecord();
00045   void Reset(void);
00046 
00049   std::string  m_RecordName;
00050 
00055   std::map<std::string, MemoryLoadType> m_Tokens;
00056 
00057 };
00058 
00063 class ITKCommon_EXPORT SmapsRecord : public MapRecord
00064 {
00081   friend ITKCommon_EXPORT std::istream&  operator>>(std::istream &in, SmapsRecord &record);
00082 };
00083 
00088 class ITKCommon_EXPORT VMMapSummaryRecord : public MapRecord
00089 {
00095   friend ITKCommon_EXPORT std::istream&  operator>>(std::istream &in, VMMapSummaryRecord &record);
00096 };
00097 
00102 class ITKCommon_EXPORT VMMapRecord : public MapRecord
00103 {
00109   friend ITKCommon_EXPORT std::istream&  operator>>(std::istream &in, VMMapRecord &record);
00110 };
00111 
00119 class ITKCommon_EXPORT MapData
00120 {
00121 public:
00123   typedef unsigned long             MemoryLoadType;
00124   //todo delete records
00125   virtual ~MapData();
00126 
00128   virtual MemoryLoadType GetHeapUsage() = 0;
00129 
00131   virtual MemoryLoadType GetStackUsage() = 0;
00132 
00134   virtual MemoryLoadType GetTotalMemoryUsage();
00135 
00137   virtual MemoryLoadType GetMemoryUsage( const char * filter, const char * token );
00138 
00140   bool Empty();
00141 protected:
00142 
00144   void Reset(void);
00145 protected: 
00146   typedef std::vector< MapRecord* >  MapRecordVectorType;
00147 
00149   MapRecordVectorType                   m_Records;
00150 };
00151 
00156 class ITKCommon_EXPORT SmapsData_2_6:public MapData
00157 {
00158 public:
00159   typedef MapData::MemoryLoadType MemoryLoadType;
00160   
00161   virtual ~SmapsData_2_6();
00162 
00164   virtual MemoryLoadType GetHeapUsage();
00165 
00167   virtual MemoryLoadType GetStackUsage();
00168 
00170   friend ITKCommon_EXPORT std::istream&  operator>>( std::istream &smapsStream,
00171                                               SmapsData_2_6 &data);
00172 
00173 protected:
00174   bool                m_HeapRecordFound;
00175 };
00176 
00182 class ITKCommon_EXPORT VMMapData_10_2:public MapData
00183 {
00184 public:
00185   typedef MapData::MemoryLoadType MemoryLoadType;
00186   VMMapData_10_2();
00187   virtual ~VMMapData_10_2();
00188 
00190   virtual MemoryLoadType GetHeapUsage();
00191 
00193   virtual MemoryLoadType GetStackUsage();  
00194 
00196   friend ITKCommon_EXPORT std::istream& operator>>( std::istream &stream,
00197                                               VMMapData_10_2 &data);
00198 protected: 
00199   bool                m_UsingSummary;
00200 };
00201 
00202 
00208 template<class TMapData>
00209 class ITK_EXPORT MapFileParser
00210 {
00211 public: 
00212   typedef typename TMapData::MemoryLoadType MemoryLoadType;
00213 
00214   virtual ~MapFileParser();
00219   virtual void ReadFile( const std::string &mapFileLocation = "") = 0;
00220 
00224   bool Update(void);
00225 
00229   MemoryLoadType GetHeapUsage();
00230 
00234   MemoryLoadType GetStackUsage();
00235 
00239   MemoryLoadType GetTotalMemoryUsage();
00240 
00244   MemoryLoadType GetMemoryUsage( const char* filter , const char * token = "Size" );
00245 
00246 protected: 
00247   std::string   m_MapFilePath;  //< location of the last loaded Map file
00248   TMapData      m_MapData;      //< data of the loaded smap file
00249 };
00250 
00256 template<class TSmapsDataType>
00257 class ITK_EXPORT SmapsFileParser: public MapFileParser<TSmapsDataType>
00258 {
00259 public:
00260   virtual ~SmapsFileParser();
00266   virtual void ReadFile( const std::string &mapFileLocation = "");
00267 
00268 };
00269 
00274 template<class TVMMapDataType>
00275 class ITK_EXPORT VMMapFileParser: public MapFileParser<TVMMapDataType>
00276 {
00277 public:
00278   virtual ~VMMapFileParser();
00282   virtual void ReadFile( const std::string &mapFileLocation = "");
00283 
00284 };
00285 
00286 }  // end namespace itk
00287 
00288 #ifndef ITK_MANUAL_INSTANTIATION
00289 #include "itkSmapsFileParser.txx"
00290 #endif
00291 
00292 #endif // __itkSmapsFileParser_h
00293 

Generated at Mon Jul 12 2010 19:55:04 for ITK by doxygen 1.7.1 written by Dimitri van Heesch, © 1997-2000