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
22Utility base class for \ref Roofitmain 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
32
33
34////////////////////////////////////////////////////////////////////////////////
35/// Remove object from directory it was added to
36
38{
39 if (_dir) {
40 _dir->GetList()->Remove(obj) ;
41 }
42}
43
44
45
46////////////////////////////////////////////////////////////////////////////////
47/// Append object to directory. If forceMemoryResident is
48/// true, nothing happens.
49void RooDirItem::appendToDir(TObject* obj, bool forceMemoryResident)
50{
51 if (forceMemoryResident) {
52 // If we are not going into a file, appending to a directory
53 // doesn't make sense. It only creates global state and congestion.
54 return;
55 } else {
56 // Append self to present gDirectory
58 gDirectory->Append(obj) ;
59 }
60}
61
#define ClassImp(name)
Definition Rtypes.h:382
#define gDirectory
Definition TDirectory.h:384
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:820
Mother of all ROOT objects.
Definition TObject.h:41