#include "TObjectSpy.h"
#include "TROOT.h"
ClassImp(TObjectSpy)
ClassImp(TObjectRefSpy)
TObjectSpy::TObjectSpy(TObject *obj, Bool_t fixMustCleanupBit) :
TObject(), fObj(obj), fResetMustCleanupBit(kFALSE)
{
gROOT->GetListOfCleanups()->Add(this);
if (fObj && !fObj->TestBit(kMustCleanup)) {
if (fixMustCleanupBit) {
fResetMustCleanupBit = kTRUE;
fObj->SetBit(kMustCleanup, kTRUE);
} else {
Error("TObjectSpy", "spied object must have the kMustCleanup bit set");
}
}
}
TObjectSpy::~TObjectSpy()
{
if (fObj && fResetMustCleanupBit)
fObj->SetBit(kMustCleanup, kFALSE);
gROOT->GetListOfCleanups()->Remove(this);
}
void TObjectSpy::RecursiveRemove(TObject *obj)
{
if (obj == fObj) {
fObj = 0;
fResetMustCleanupBit = kFALSE;
}
}
void TObjectSpy::SetObject(TObject *obj, Bool_t fixMustCleanupBit)
{
if (fObj && fResetMustCleanupBit)
fObj->SetBit(kMustCleanup, kFALSE);
fResetMustCleanupBit = kFALSE;
fObj = obj;
if (fObj && !fObj->TestBit(kMustCleanup)) {
if (fixMustCleanupBit) {
fResetMustCleanupBit = kTRUE;
fObj->SetBit(kMustCleanup, kTRUE);
} else {
Error("TObjectSpy", "spied object must have the kMustCleanup bit set");
}
}
}
TObjectRefSpy::TObjectRefSpy(TObject *&obj, Bool_t fixMustCleanupBit) :
fObj(obj), fResetMustCleanupBit(kFALSE)
{
gROOT->GetListOfCleanups()->Add(this);
if (fObj && !fObj->TestBit(kMustCleanup)) {
if (fixMustCleanupBit) {
fResetMustCleanupBit = kTRUE;
fObj->SetBit(kMustCleanup, kTRUE);
} else {
Error("TObjectSpy", "spied object must have the kMustCleanup bit set");
}
}
}
TObjectRefSpy::~TObjectRefSpy()
{
if (fObj && fResetMustCleanupBit)
fObj->SetBit(kMustCleanup, kFALSE);
gROOT->GetListOfCleanups()->Remove(this);
}
void TObjectRefSpy::RecursiveRemove(TObject *obj)
{
if (obj == fObj) {
fObj = 0;
fResetMustCleanupBit = kFALSE;
}
}
Last change: Wed Jun 25 08:49:58 2008
Last generated: 2008-06-25 08:49
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.