Logo ROOT   6.12/07
Reference Guide
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 
17 
18 /** \class THbookKey
19  \ingroup Hist
20  \brief HBOOK Key
21 */
22 
23 
24 ////////////////////////////////////////////////////////////////////////////////
25 ///constructor
26 
28 {
29  fDirectory = file;
30  fID = id;
31  char name[10];
32  snprintf(name,10,"h%d",id);
33  SetName(name);
34 }
35 
36 
37 ////////////////////////////////////////////////////////////////////////////////
38 
40 {
41 }
42 
43 ////////////////////////////////////////////////////////////////////////////////
44 /// Read object from disk and call its Browse() method.
45 /// If object with same name already exist in memory delete it (like
46 /// TDirectory::Get() is doing), except when the key references a
47 /// folder in which case we don't want to re-read the folder object
48 /// since it might contain new objects not yet saved.
49 
51 {
52  fDirectory->cd();
53 
55  if (obj && !obj->IsFolder()) {
56  if (obj->InheritsFrom(TCollection::Class()))
57  obj->Delete(); // delete also collection elements
58  delete obj;
59  obj = 0;
60  }
61 
62  if (!obj)
63  obj = fDirectory->Get(fID);
64 
65  if (b && obj) {
66  obj->Browse(b);
68  }
69 }
70 
71 ////////////////////////////////////////////////////////////////////////////////
72 ///an hbook key is not a folder
73 
75 {
76  Bool_t ret = kFALSE;
77 
78 
79  return( ret );
80 }
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
virtual void SetName(const char *name)
Set the name of the TNamed.
Definition: TNamed.cxx:140
virtual void Browse(TBrowser *b)
Browse object. May be overridden for another default action.
Definition: TObject.cxx:119
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
HBOOK Key.
Definition: THbookKey.h:26
TObject * Get(Int_t id)
import Hbook object with identifier idd in memory
Definition: THbookFile.cxx:443
virtual TObject * FindObject(const char *name) const
Delete a TObjLink object.
Definition: TList.cxx:574
THbookKey()
Definition: THbookKey.h:33
void Class()
Definition: Class.C:29
virtual ~THbookKey()
Definition: THbookKey.cxx:39
XFontStruct * id
Definition: TGX11.cxx:108
THbookFile * fDirectory
Definition: THbookKey.h:29
virtual void Delete(Option_t *option="")
Delete this object.
Definition: TObject.cxx:169
Using a TBrowser one can browse all ROOT objects.
Definition: TBrowser.h:37
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition: TObject.cxx:443
void SetRefreshFlag(Bool_t flag)
Definition: TBrowser.h:97
TList * GetList() const
Definition: THbookFile.h:63
Int_t fID
pointer to the Hbook file
Definition: THbookKey.h:30
const Bool_t kFALSE
Definition: RtypesCore.h:88
Bool_t IsFolder() const
an hbook key is not a folder
Definition: THbookKey.cxx:74
#define ClassImp(name)
Definition: Rtypes.h:359
Mother of all ROOT objects.
Definition: TObject.h:37
virtual void Browse(TBrowser *b)
Read object from disk and call its Browse() method.
Definition: THbookKey.cxx:50
virtual Bool_t cd(const char *dirname="")
change directory to dirname
Definition: THbookFile.cxx:360
Definition: file.py:1
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
Definition: TRolke.cxx:630
#define snprintf
Definition: civetweb.c:822
This class is an interface to the Hbook objects in Hbook files.
Definition: THbookFile.h:29
virtual Bool_t IsFolder() const
Returns kTRUE in case object contains browsable objects (like containers or lists of other objects)...
Definition: TObject.cxx:473
const Bool_t kTRUE
Definition: RtypesCore.h:87
char name[80]
Definition: TGX11.cxx:109