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-04-10 12:33:37 $
00007   Version:   $Revision: 1.7 $
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 
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 VMMapRecord : public MapRecord
00086 {
00087 
00104   friend ITKCommon_EXPORT std::istream&  operator>>(std::istream &in, VMMapRecord &record);
00105 };
00106 
00107 
00114 template <class TMapRecord>
00115 class ITK_EXPORT MapData{
00116 public:
00117 
00119   typedef unsigned long             MemoryLoadType;
00120   virtual ~MapData();
00121 
00123   virtual MemoryLoadType GetHeapUsage() = 0;
00124 
00126   virtual MemoryLoadType GetStackUsage() = 0;  
00127 
00129   virtual MemoryLoadType GetTotalMemoryUsage() = 0;
00130 
00132   virtual MemoryLoadType GetMemoryUsage( const char * filter, const char * token ) =0;
00133 
00135   bool Empty();
00136 protected:
00137 
00139   void Reset(void);
00140 protected: 
00141   typedef TMapRecord                    MapRecordType;
00142   typedef typename std::vector< MapRecordType >  MapRecordVectorType;
00143 
00145   MapRecordVectorType                   m_Records;
00146 };
00147 
00152 template <class TMapRecord>
00153 class ITK_EXPORT SmapsData_2_6:public MapData<TMapRecord>
00154 {
00155 public:
00156   typedef typename MapData<TMapRecord>::MemoryLoadType MemoryLoadType;
00157   
00158   virtual ~SmapsData_2_6();
00159 
00161   virtual MemoryLoadType GetHeapUsage();
00162 
00164   virtual MemoryLoadType GetStackUsage();
00165 
00167   virtual MemoryLoadType GetTotalMemoryUsage();
00168 
00172   virtual MemoryLoadType GetMemoryUsage( const char * filter, const char * token );
00173 
00175   template<class TSmapsRecordType> 
00176   friend ITK_EXPORT std::istream& operator>>( std::istream &smapsStream,
00177                                               SmapsData_2_6<TSmapsRecordType>&data);
00178 
00179 protected:
00180   bool                m_HeapRecordFound;  
00181 };
00182 
00188 template <class TMapRecord>
00189 class ITK_EXPORT VMMapData_10_2:public MapData<TMapRecord>
00190 {
00191 public:
00192   typedef typename MapData<TMapRecord>::MemoryLoadType MemoryLoadType;
00193 
00194   virtual ~VMMapData_10_2();
00195 
00197   virtual MemoryLoadType GetHeapUsage();
00198 
00200   virtual MemoryLoadType GetStackUsage();  
00201 
00203   virtual MemoryLoadType GetTotalMemoryUsage();
00204 
00206   virtual MemoryLoadType GetMemoryUsage( const char * filter, const char * token );
00207 
00209   template<class TVMMapRecordType> 
00210   friend ITK_EXPORT std::istream& operator>>( std::istream &stream,
00211                                               VMMapData_10_2<TVMMapRecordType>&data);
00212 };
00213 
00214 
00218 template<class TMapData>
00219 class ITK_EXPORT MapFileParser
00220 {
00221 public: 
00222   typedef typename TMapData::MemoryLoadType MemoryLoadType;
00223 
00224   virtual ~MapFileParser();
00229   virtual void ReadFile( const std::string &mapFileLocation = "") = 0;
00230 
00234   bool Update(void);
00235 
00239   MemoryLoadType GetHeapUsage();
00240 
00244   MemoryLoadType GetStackUsage();
00245 
00249   MemoryLoadType GetTotalMemoryUsage();
00250 
00254   MemoryLoadType GetMemoryUsage( const char* filter , const char * token = "Size" );
00255 
00256 protected: 
00257   std::string   m_MapFilePath;  //< location of the last loaded Map file
00258   TMapData      m_MapData;      //< data of the loaded smap file
00259 };
00260 
00266 template<class TSmapsDataType>
00267 class ITK_EXPORT SmapsFileParser: public MapFileParser<TSmapsDataType>
00268 {
00269 public:
00270   virtual ~SmapsFileParser();
00276   virtual void ReadFile( const std::string &mapFileLocation = "");
00277 
00278 };
00279 
00284 template<class TVMMapDataType>
00285 class ITK_EXPORT VMMapFileParser: public MapFileParser<TVMMapDataType>
00286 {
00287 public:
00288   virtual ~VMMapFileParser();
00292   virtual void ReadFile( const std::string &mapFileLocation = "");
00293 
00294 };
00295 
00296 }  // end namespace itk
00297 
00298 #ifndef ITK_MANUAL_INSTANTIATION
00299 #include "itkSmapsFileParser.txx"
00300 #endif
00301 
00302 #endif // __itkSmapsFileParser_h
00303 

Generated at Mon Apr 14 14:27:37 2008 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000