Advanced Strategic Command
memsize_interface.h
Go to the documentation of this file.
1 
2 /***************************************************************************
3  * *
4  * This program is free software; you can redistribute it and/or modify *
5  * it under the terms of the GNU General Public License as published by *
6  * the Free Software Foundation; either version 2 of the License, or *
7  * (at your option) any later version. *
8  * *
9  ***************************************************************************/
10 
11 #ifndef memsizeinterfaceH
12  #define memsizeinterfaceH
13 
15  public:
16  virtual int getMemoryFootprint() const = 0;
18  };
19 
20  template<typename T>
21  int getMemoryFootprint( const T& t )
22  {
23  return t.getMemoryFootprint();
24  };
25 
26  template<class T>
27  struct MemorySum : public unary_function<T, void>
28  {
29  MemorySum() : size(0) {}
30  void operator() (const T& x) { size += getMemoryFootprint(x); }
31  void operator() (const T* x) { size += getMemoryFootprint(*x); }
32  int size;
33  };
34 
35 
36 #endif
void operator()(const T &x)
virtual int getMemoryFootprint() const =0
int getMemoryFootprint(const T &t)