Logo ROOT  
Reference Guide
RooDirItem.cxx
Go to the documentation of this file.
1/*****************************************************************************
2 * Project: RooFit *
3 * Package: RooFitCore *
4 * @(#)root/roofitcore:$Id$
5 * Authors: *
6 * WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu *
7 * DK, David Kirkby, UC Irvine, dkirkby@uci.edu *
8 * *
9 * Copyright (c) 2000-2005, Regents of the University of California *
10 * and Stanford University. All rights reserved. *
11 * *
12 * Redistribution and use in source and binary forms, *
13 * with or without modification, are permitted according to the terms *
14 * listed in LICENSE (http://roofit.sourceforge.net/license.txt) *
15 *****************************************************************************/
16
17/**
18\file RooDirItem.cxx
19\class RooDirItem
20\ingroup Roofitcore
21
22RooDirItem is a utility base class for RooFit objects that are to be attached
23to ROOT directories. Concrete classes inherit the appendToDir and removeToDir
24methods that can be used to safely attach and detach one self from a TDirectory
25**/
26
27#include "RooFit.h"
28
29#include "Riostream.h"
30#include "TROOT.h"
31#include "TList.h"
32#include "TDirectoryFile.h"
33#include "TString.h"
34#include "RooDirItem.h"
35
36using namespace std;
37
39
40
41////////////////////////////////////////////////////////////////////////////////
42/// Remove object from directory it was added to
43
45{
46 if (_dir) {
48 _dir->GetList()->Remove(obj) ;
49 }
50}
51
52
53
54////////////////////////////////////////////////////////////////////////////////
55/// Append object to directory. If forceMemoryResident is
56/// true, nothing happens.
57void RooDirItem::appendToDir(TObject* obj, Bool_t forceMemoryResident)
58{
59 if (forceMemoryResident) {
60 // If we are not going into a file, appending to a directory
61 // doesn't make sense. It only creates global state and congestion.
62 return;
63 } else {
64 // Append self to present gDirectory
66 gDirectory->Append(obj) ;
67 }
68}
69
#define ClassImp(name)
Definition: Rtypes.h:361
#define gDirectory
Definition: TDirectory.h:229
RooDirItem is a utility base class for RooFit objects that are to be attached to ROOT directories.
Definition: RooDirItem.h:22
void appendToDir(TObject *obj, Bool_t forceMemoryResident=kFALSE)
Append object to directory.
Definition: RooDirItem.cxx:57
void removeFromDir(TObject *obj)
Remove object from directory it was added to.
Definition: RooDirItem.cxx:44
TDirectory * _dir
Definition: RooDirItem.h:33
virtual TList * GetList() const
Definition: TDirectory.h:165
virtual TObject * Remove(TObject *obj)
Remove object from the list.
Definition: TList.cxx:821
Mother of all ROOT objects.
Definition: TObject.h:37
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition: TObject.h:187