ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition: TObject.cxx:487
TList * GetList() const
Definition: THbookFile.h:65
virtual void Browse(TBrowser *b)
Browse object. May be overridden for another default action.
Definition: TObject.cxx:178
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
virtual Bool_t IsFolder() const
Returns kTRUE in case object contains browsable objects (like containers or lists of other objects)...
Definition: TObject.cxx:517
const Bool_t kFALSE
Definition: Rtypes.h:92
HBOOK Key.
Definition: THbookKey.h:28
virtual TObject * FindObject(const char *name) const
Find an object in this list using its name.
Definition: TList.cxx:497
TObject * Get(Int_t id)
import Hbook object with identifier idd in memory
Definition: THbookFile.cxx:443
void Class()
Definition: Class.C:29
virtual ~THbookKey()
Definition: THbookKey.cxx:39
XFontStruct * id
Definition: TGX11.cxx:108
THbookFile * fDirectory
Definition: THbookKey.h:31
virtual void Delete(Option_t *option="")
Delete this object.
Definition: TObject.cxx:228
Using a TBrowser one can browse all ROOT objects.
Definition: TBrowser.h:41
void SetRefreshFlag(Bool_t flag)
Definition: TBrowser.h:101
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:51
Int_t fID
pointer to the Hbook file
Definition: THbookKey.h:32
#define ClassImp(name)
Definition: Rtypes.h:279
tuple file
Definition: fildir.py:20
#define name(a, b)
Definition: linkTestLib0.cpp:5
Mother of all ROOT objects.
Definition: TObject.h:58
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
This class is an interface to the Hbook objects in Hbook files.
Definition: THbookFile.h:31
const Bool_t kTRUE
Definition: Rtypes.h:91
TObject * obj
gr SetName("gr")
Bool_t IsFolder() const
an hbook key is not a folder
Definition: THbookKey.cxx:74