Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
THbookKey.cxx
Go to the documentation of this file.
1// @(#)root/hbook:$Id$
2// Author: Rene Brun 20/02/2002
3
4/*************************************************************************
5 * Copyright (C) 1995-2002, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12#include "THbookKey.h"
13#include "THbookTree.h"
14#include "TBrowser.h"
15#include "snprintf.h"
16
18
19/** \class THbookKey
20 \ingroup Hist
21 \brief HBOOK Key
22*/
23
24
25////////////////////////////////////////////////////////////////////////////////
26///constructor
27
29{
31 fID = id;
32 char name[10];
33 snprintf(name,10,"h%d",id);
35}
36
37
38////////////////////////////////////////////////////////////////////////////////
39
41{
42}
43
44////////////////////////////////////////////////////////////////////////////////
45/// Read object from disk and call its Browse() method.
46/// If object with same name already exist in memory delete it (like
47/// TDirectory::Get() is doing), except when the key references a
48/// folder in which case we don't want to re-read the folder object
49/// since it might contain new objects not yet saved.
50
52{
53 fDirectory->cd();
54
56 if (obj && !obj->IsFolder()) {
57 if (obj->InheritsFrom(TCollection::Class()))
58 obj->Delete(); // delete also collection elements
59 delete obj;
60 obj = 0;
61 }
62
63 if (!obj)
64 obj = fDirectory->Get(fID);
65
66 if (b && obj) {
67 obj->Browse(b);
68 b->SetRefreshFlag(kTRUE);
69 }
70}
71
72////////////////////////////////////////////////////////////////////////////////
73///an hbook key is not a folder
74
76{
77 Bool_t ret = kFALSE;
78
79
80 return( ret );
81}
#define b(i)
Definition RSha256.hxx:100
const Bool_t kFALSE
Definition RtypesCore.h:92
const Bool_t kTRUE
Definition RtypesCore.h:91
#define ClassImp(name)
Definition Rtypes.h:364
XFontStruct * id
Definition TGX11.cxx:109
char name[80]
Definition TGX11.cxx:110
#define snprintf
Definition civetweb.c:1540
Using a TBrowser one can browse all ROOT objects.
Definition TBrowser.h:37
This class is an interface to the Hbook objects in Hbook files.
Definition THbookFile.h:29
TObject * Get(Int_t id)
import Hbook object with identifier idd in memory
TList * GetList() const
Definition THbookFile.h:63
virtual Bool_t cd(const char *dirname="")
change directory to dirname
HBOOK Key.
Definition THbookKey.h:26
virtual ~THbookKey()
Definition THbookKey.cxx:40
virtual void Browse(TBrowser *b)
Read object from disk and call its Browse() method.
Definition THbookKey.cxx:51
THbookFile * fDirectory
Definition THbookKey.h:29
Bool_t IsFolder() const
an hbook key is not a folder
Definition THbookKey.cxx:75
Int_t fID
pointer to the Hbook file
Definition THbookKey.h:30
virtual TObject * FindObject(const char *name) const
Find an object in this list using its name.
Definition TList.cxx:578
virtual void SetName(const char *name)
Set the name of the TNamed.
Definition TNamed.cxx:140
virtual const char * GetName() const
Returns name of object.
Definition TNamed.h:47
Mother of all ROOT objects.
Definition TObject.h:37
virtual Bool_t IsFolder() const
Returns kTRUE in case object contains browsable objects (like containers or lists of other objects).
Definition TObject.cxx:475
virtual void Browse(TBrowser *b)
Browse object. May be overridden for another default action.
Definition TObject.cxx:121
virtual void Delete(Option_t *option="")
Delete this object.
Definition TObject.cxx:171
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition TObject.cxx:445
Definition file.py:1