// Class RooTrace controls the memory tracing hooks in all RooFit
// objects. When tracing is active, a table of live RooFit objects
// is kept that can be queried at any time. In verbose mode, messages
// are printed in addition at the construction and destruction of
// each object.
// END_HTML
#include "RooFit.h"
#include "RooTrace.h"
#include "RooAbsArg.h"
#include "Riostream.h"
#include <iomanip>
ClassImp(RooTrace)
;
Bool_t RooTrace::_active(kFALSE) ;
Bool_t RooTrace::_verbose(kFALSE) ;
RooLinkedList RooTrace::_list ;
RooLinkedList RooTrace::_markList ;
void RooTrace::create(const TObject* obj)
{
if (_active) create2(obj) ;
}
void RooTrace::destroy(const TObject* obj)
{
if (_active) destroy2(obj) ;
}
void RooTrace::active(Bool_t flag)
{
_active = flag ;
}
void RooTrace::verbose(Bool_t flag)
{
_verbose = flag ;
}
void RooTrace::create2(const TObject* obj)
{
_list.Add((RooAbsArg*)obj) ;
if (_verbose) {
cout << "RooTrace::create: object " << obj << " of type " << obj->ClassName()
<< " created " << endl ;
}
}
void RooTrace::destroy2(const TObject* obj)
{
if (!_list.Remove((RooAbsArg*)obj)) {
} else if (_verbose) {
cout << "RooTrace::destroy: object " << obj << " of type " << obj->ClassName()
<< " destroyed [" << obj->GetTitle() << "]" << endl ;
}
}
void RooTrace::mark()
{
_markList = _list ;
}
void RooTrace::dump()
{
dump(cout,kFALSE) ;
}
void RooTrace::dump(ostream& os, Bool_t sinceMarked)
{
os << "List of RooFit objects allocated while trace active:" << endl ;
Int_t i, nMarked(0) ;
for(i=0 ; i<_list.GetSize() ; i++) {
if (!sinceMarked || _markList.IndexOf(_list.At(i)) == -1) {
os << hex << setw(10) << _list.At(i) << " : " << setw(20) << _list.At(i)->ClassName() << setw(0) << " - " << _list.At(i)->GetName() << endl ;
} else {
nMarked++ ;
}
}
if (sinceMarked) os << nMarked << " marked objects suppressed" << endl ;
}
Last change: Wed Jun 25 08:34:23 2008
Last generated: 2008-06-25 08:34
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.