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-05-04 17:27:20 $
00007   Version:   $Revision: 1.8 $
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 
00036 class ITKCommon_EXPORT MapRecord
00037 {
00038 public:
00039   typedef unsigned int  MemoryLoadType;
00040   virtual ~MapRecord();
00043   void Reset(void);
00044 
00047   std::string  m_RecordName;
00048 
00053   std::map<std::string, MemoryLoadType> m_Tokens;
00054 
00055 };
00056 
00060 class ITKCommon_EXPORT SmapsRecord : public MapRecord
00061 {
00062 
00079   friend ITKCommon_EXPORT std::istream&  operator>>(std::istream &in, SmapsRecord &record);
00080 };
00081 
00085 class ITKCommon_EXPORT VMMapSummaryRecord : public MapRecord
00086 {
00087 
00093   friend ITKCommon_EXPORT std::istream&  operator>>(std::istream &in, VMMapSummaryRecord &record);
00094 };
00095 
00099 class ITKCommon_EXPORT VMMapRecord : public MapRecord
00100 {
00101 
00107   friend ITKCommon_EXPORT std::istream&  operator>>(std::istream &in, VMMapRecord &record);
00108 };
00109 
00116 class ITKCommon_EXPORT MapData{
00117 public:
00118 
00120   typedef unsigned long             MemoryLoadType;
00121   //todo delete records
00122   virtual ~MapData();
00123 
00125   virtual MemoryLoadType GetHeapUsage() = 0;
00126 
00128   virtual MemoryLoadType GetStackUsage() = 0;
00129 
00131   virtual MemoryLoadType GetTotalMemoryUsage();
00132 
00134   virtual MemoryLoadType GetMemoryUsage( const char * filter, const char * token );
00135 
00137   bool Empty();
00138 protected:
00139 
00141   void Reset(void);
00142 protected: 
00143   typedef std::vector< MapRecord* >  MapRecordVectorType;
00144 
00146   MapRecordVectorType                   m_Records;
00147 };
00148 
00153 class ITKCommon_EXPORT SmapsData_2_6:public MapData
00154 {
00155 public:
00156   typedef MapData::MemoryLoadType MemoryLoadType;
00157   
00158   virtual ~SmapsData_2_6();
00159 
00161   virtual MemoryLoadType GetHeapUsage();
00162 
00164   virtual MemoryLoadType GetStackUsage();
00165 
00167   friend ITKCommon_EXPORT std::istream&  operator>>( std::istream &smapsStream,
00168                                               SmapsData_2_6 &data);
00169 
00170 protected:
00171   bool                m_HeapRecordFound;
00172 };
00173 
00179 class ITKCommon_EXPORT VMMapData_10_2:public MapData
00180 {
00181 public:
00182   typedef MapData::MemoryLoadType MemoryLoadType;
00183   VMMapData_10_2();
00184   virtual ~VMMapData_10_2();
00186 
00188   virtual MemoryLoadType GetHeapUsage();
00189 
00191   virtual MemoryLoadType GetStackUsage();  
00192 
00194   friend ITKCommon_EXPORT std::istream& operator>>( std::istream &stream,
00195                                               VMMapData_10_2 &data);
00196 protected: 
00197   bool                m_UsingSummary;
00198 };
00199 
00200 
00204 template<class TMapData>
00205 class ITK_EXPORT MapFileParser
00206 {
00207 public: 
00208   typedef typename TMapData::MemoryLoadType MemoryLoadType;
00209 
00210   virtual ~MapFileParser();
00215   virtual void ReadFile( const std::string &mapFileLocation = "") = 0;
00216 
00220   bool Update(void);
00221 
00225   MemoryLoadType GetHeapUsage();
00226 
00230   MemoryLoadType GetStackUsage();
00231 
00235   MemoryLoadType GetTotalMemoryUsage();
00236 
00240   MemoryLoadType GetMemoryUsage( const char* filter , const char * token = "Size" );
00241 
00242 protected: 
00243   std::string   m_MapFilePath;  //< location of the last loaded Map file
00244   TMapData      m_MapData;      //< data of the loaded smap file
00245 };
00246 
00252 template<class TSmapsDataType>
00253 class ITK_EXPORT SmapsFileParser: public MapFileParser<TSmapsDataType>
00254 {
00255 public:
00256   virtual ~SmapsFileParser();
00262   virtual void ReadFile( const std::string &mapFileLocation = "");
00263 
00264 };
00265 
00270 template<class TVMMapDataType>
00271 class ITK_EXPORT VMMapFileParser: public MapFileParser<TVMMapDataType>
00272 {
00273 public:
00274   virtual ~VMMapFileParser();
00278   virtual void ReadFile( const std::string &mapFileLocation = "");
00279 
00280 };
00281 
00282 }  // end namespace itk
00283 
00284 #ifndef ITK_MANUAL_INSTANTIATION
00285 #include "itkSmapsFileParser.txx"
00286 #endif
00287 
00288 #endif // __itkSmapsFileParser_h
00289 

Generated at Tue Jul 29 22:29:23 2008 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000