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 <iostream>
30#include "TList.h"
31#include "TDirectoryFile.h"
32#include "TString.h"
33#include "RooDirItem.h"
34
35using namespace std;
36
38
39
40////////////////////////////////////////////////////////////////////////////////
41/// Remove object from directory it was added to
42
44{
45 if (_dir) {
46 _dir->GetList()->Remove(obj) ;
47 }
48}
49
50
51
52////////////////////////////////////////////////////////////////////////////////
53/// Append object to directory. If forceMemoryResident is
54/// true, nothing happens.
55void RooDirItem::appendToDir(TObject* obj, Bool_t forceMemoryResident)
56{
57 if (forceMemoryResident) {
58 // If we are not going into a file, appending to a directory
59 // doesn't make sense. It only creates global state and congestion.
60 return;
61 } else {
62 // Append self to present gDirectory
64 gDirectory->Append(obj) ;
65 }
66}
67
bool Bool_t
Definition: RtypesCore.h:63
#define ClassImp(name)
Definition: Rtypes.h:364
#define gDirectory
Definition: TDirectory.h:348
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:55
void removeFromDir(TObject *obj)
Remove object from directory it was added to.
Definition: RooDirItem.cxx:43
TDirectory * _dir
Definition: RooDirItem.h:33
virtual TList * GetList() const
Definition: TDirectory.h:213
virtual TObject * Remove(TObject *obj)
Remove object from the list.
Definition: TList.cxx:822
Mother of all ROOT objects.
Definition: TObject.h:37