00001 // @(#)root/hbook:$Id: THbookKey.cxx 35944 2010-09-30 16:04:10Z brun $ 00002 // Author: Rene Brun 20/02/2002 00003 00004 /************************************************************************* 00005 * Copyright (C) 1995-2002, Rene Brun and Fons Rademakers. * 00006 * All rights reserved. * 00007 * * 00008 * For the licensing terms see $ROOTSYS/LICENSE. * 00009 * For the list of contributors see $ROOTSYS/README/CREDITS. * 00010 *************************************************************************/ 00011 00012 #include "THbookKey.h" 00013 #include "THbookTree.h" 00014 #include "TBrowser.h" 00015 00016 ClassImp(THbookKey) 00017 00018 00019 //______________________________________________________________________________ 00020 THbookKey::THbookKey(Int_t id, THbookFile *file) 00021 { 00022 //constructor 00023 fDirectory = file; 00024 fID = id; 00025 char name[10]; 00026 snprintf(name,10,"h%d",id); 00027 SetName(name); 00028 } 00029 00030 00031 //______________________________________________________________________________ 00032 THbookKey::~THbookKey() 00033 { 00034 } 00035 00036 //______________________________________________________________________________ 00037 void THbookKey::Browse(TBrowser *b) 00038 { 00039 // Read object from disk and call its Browse() method. 00040 // If object with same name already exist in memory delete it (like 00041 // TDirectory::Get() is doing), except when the key references a 00042 // folder in which case we don't want to re-read the folder object 00043 // since it might contain new objects not yet saved. 00044 00045 fDirectory->cd(); 00046 00047 TObject *obj = fDirectory->GetList()->FindObject(GetName()); 00048 if (obj && !obj->IsFolder()) { 00049 if (obj->InheritsFrom(TCollection::Class())) 00050 obj->Delete(); // delete also collection elements 00051 delete obj; 00052 obj = 0; 00053 } 00054 00055 if (!obj) 00056 obj = fDirectory->Get(fID); 00057 00058 if (b && obj) { 00059 obj->Browse(b); 00060 b->SetRefreshFlag(kTRUE); 00061 } 00062 } 00063 00064 //______________________________________________________________________________ 00065 Bool_t THbookKey::IsFolder() const 00066 { 00067 //an hbook key is not a folder 00068 Bool_t ret = kFALSE; 00069 00070 00071 return( ret ); 00072 }