Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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 <iostream>
28#include "TDirectoryFile.h"
29#include "RooDirItem.h"
30
31using namespace std;
32
34
35
36////////////////////////////////////////////////////////////////////////////////
37/// Remove object from directory it was added to
38
40{
41 if (_dir) {
42 _dir->GetList()->Remove(obj) ;
43 }
44}
45
46
47
48////////////////////////////////////////////////////////////////////////////////
49/// Append object to directory. If forceMemoryResident is
50/// true, nothing happens.
51void RooDirItem::appendToDir(TObject* obj, bool forceMemoryResident)
52{
53 if (forceMemoryResident) {
54 // If we are not going into a file, appending to a directory
55 // doesn't make sense. It only creates global state and congestion.
56 return;
57 } else {
58 // Append self to present gDirectory
60 gDirectory->Append(obj) ;
61 }
62}
63
#define ClassImp(name)
Definition Rtypes.h:377
#define gDirectory
Definition TDirectory.h:386
RooDirItem is a utility base class for RooFit objects that are to be attached to ROOT directories.
Definition RooDirItem.h:22
void removeFromDir(TObject *obj)
Remove object from directory it was added to.
TDirectory * _dir
! Associated directory
Definition RooDirItem.h:33
void appendToDir(TObject *obj, bool forceMemoryResident=false)
Append object to directory.
virtual TList * GetList() const
Definition TDirectory.h:222
virtual void Append(TObject *obj, Bool_t replace=kFALSE)
Append object to this directory.
TObject * Remove(TObject *obj) override
Remove object from the list.
Definition TList.cxx:822
Mother of all ROOT objects.
Definition TObject.h:41