memsize_interface.h

Go to the documentation of this file.
00001 
00002 /***************************************************************************
00003  *                                                                         *
00004  *   This program is free software; you can redistribute it and/or modify  *
00005  *   it under the terms of the GNU General Public License as published by  *
00006  *   the Free Software Foundation; either version 2 of the License, or     *
00007  *   (at your option) any later version.                                   *
00008  *                                                                         *
00009  ***************************************************************************/
00010 
00011 #ifndef memsizeinterfaceH
00012  #define memsizeinterfaceH
00013  
00014  class MemorySizeQueryInterface {
00015     public:
00016        virtual int getMemoryFootprint() const = 0;
00017        virtual ~MemorySizeQueryInterface(){};
00018  };
00019  
00020  template<typename T>
00021  int getMemoryFootprint( const T& t ) 
00022  {
00023     return t.getMemoryFootprint();
00024  }; 
00025  
00026  template<class T> 
00027  struct MemorySum : public unary_function<T, void>
00028  {
00029     MemorySum() : size(0) {}
00030     void operator() (const T& x) { size += getMemoryFootprint(x); }
00031     void operator() (const T* x) { size += getMemoryFootprint(*x); }
00032     int size;
00033  };
00034  
00035  
00036 #endif

Generated on Mon May 21 01:26:35 2012 for Advanced Strategic Command by  doxygen 1.5.1