1: 
   2: 
   3: #ifndef WWWI_MIND_AM_H 
   4: #define WWWI_MIND_AM_H 
   5: 
   6: #include <iostream> 
   7: 
   8: #include "format.h" 
   9: #include "wwwi/singleton.h" 
  10: #include "wwwi/string.h" 
  11: 
  12: using WWWI::GetSingleton;
  13: using WWWI::StringDuplicate;
  14: using std::cerr;
  15: using std::endl;
  16: 
  17: #ifndef NDEBUG 
  18: #define AMCTOR(XXX) { GetSingleton<AM<XXX> >()->CTOR(#XXX); FastLog(LF_OBJNEWDEL,LY_DEBUG,FOUT(#XXX"::"#XXX"(",(unsigned)this,")")); } 
  19: #define AMDTOR(XXX) { GetSingleton<AM<XXX> >()->DTOR(); FastLog(LF_OBJNEWDEL,LY_DEBUG,FOUT(#XXX"::~"#XXX"(",(unsigned)this,")")); } 
  20: #else 
  21: #define AMCTOR(XXX) 
  22: #define AMDTOR(XXX) 
  23: #endif 
  24: 
  25: 
  26: template <class T> class AM {
  27: public:
  28:         AM(void) { m_strName = NULL; m_uCTOR = 0; m_uDTOR = 0; }
  29:   void  CTOR(const char *ci_strName) {
  30:           if (m_strName==NULL) m_strName = StringDuplicate(ci_strName);
  31:           m_uCTOR++; 
  32:         }
  33:   void  DTOR(void) { m_uDTOR++; }
  34:        ~AM(void) { 
  35:           if (m_strName==NULL) return;
  36:           cerr << "AM:" << m_strName << ": " << m_uCTOR << " created " << m_uDTOR 
  37:                << " destroyed " << sizeof(T) << " bytes each" << endl; 
  38:           delete[] m_strName;
  39:         }
  40: 
  41: protected:
  42:   const char *m_strName;
  43:   unsigned m_uCTOR;
  44:   unsigned m_uDTOR;
  45: };
  46: 
  47: 
  48: #endif 
  49: 
  50: 
  51: