/* * * Copyright (c) 1995 * Knowledge Science Institute, University of Calgary * * Permission to use, copy, modify, distribute and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. The Knowledge Science Institute makes no * representations about the suitability of this software for any * purpose. It is provided "as is" without express or implied warranty. * */ #ifdef __BCPLUSPLUS__ //---Borland C++ #include #pragma hdrstop #endif #include "MObject.h" #include #include long ObjectCounter::Count = 0; map < string,int,less > ObjectCounter::Counts; ObjectCounter::ObjectCounter() { MTRACE(ObjectCounter,ObjectCounter); MCONSTRUCTOR_IMP_CODE_VIRTUAL(ObjectCounter); MEXIT_CODE(ObjectCounter,ObjectCounter); } ObjectCounter::~ObjectCounter() { MTRACE(ObjectCounter,~ObjectCounter); MDESTRUCTOR_IMP_CODE_VIRTUAL(ObjectCounter); MTRACEOUT(ObjectCounter,~ObjectCounter); } void ObjectCounter::classInvarient(char* file, int line) const { MCLASSINVTEST(Count>=0); } void ObjectCounter::report() { map < string,int,less >::iterator i; error(0,'D',"-------CLASS-------- : -INSTANCES-"); for (i=Counts.begin(); i!=Counts.end(); i++) if ((*i).second) error(0,'D',"%20.20s :%6d",(*i).first.c_str(),(*i).second); error(0,'D',"------------end report------------"); } void ObjectCounter::incObjectCount() { string name = debugClassName(); Count++; if (Counts.count(name)) Counts[name]++; else Counts[name] = 1; #ifdef SET_DEBUG error(0,'D',"\t