ROOT  6.06/09
Reference Guide
TFriendProxy.cxx
Go to the documentation of this file.
1 // @(#)root/base:$Id$
2 // Author: Philippe Canal 13/05/2003
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun, Fons Rademakers and al. *
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 /** \class TFriendProxy
13 Concrete implementation of the proxy around a Friend Tree.
14 */
15 
16 #include "TFriendProxy.h"
17 #include "TTree.h"
18 #include "TList.h"
19 #include "TFriendElement.h"
20 
22 
23 namespace ROOT {
24 namespace Internal {
25 
26 /////////////////////////////////////////////////////////////////////////////
27 
28 TFriendProxy::TFriendProxy() : fDirector(0,-1), fIndex(-1)
29 {
30 }
31 
32  /////////////////////////////////////////////////////////////////////////////
33  /// Constructor.
34 
36  fDirector(0,-1), fIndex(index)
37  {
38  if (main && main->GetListOfFriends()) {
39  TObject *obj = main->GetListOfFriends()->At(fIndex);
40  TFriendElement *element = dynamic_cast<TFriendElement*>( obj );
41  if (element) fDirector.SetTree(element->GetTree());
42  }
43  director->Attach(this);
44  }
45 
46  /////////////////////////////////////////////////////////////////////////////
47  /// Return the entry number currently being looked at.
48 
50  {
51  return fDirector.GetReadEntry();
52  }
53 
54  /////////////////////////////////////////////////////////////////////////////
55  /// Refresh the cached read entry number from the original tree.
56 
58  {
59  // The 2nd call to GetTree is to insure we get the 'local' tree's entry in the case of a
60  // chain.
62  }
63 
64  //////////////////////////////////////////////////////////////////////////////
65  /// Update the address of the underlying tree.
66 
67  void TFriendProxy::Update(TTree *newmain)
68  {
69  if (newmain && newmain->GetListOfFriends()) {
70  TObject *obj = newmain->GetListOfFriends()->At(fIndex);
71  TFriendElement *element = dynamic_cast<TFriendElement*>( obj );
72  if (element) fDirector.SetTree(element->GetTree());
73  else fDirector.SetTree(0);
74  } else {
75  fDirector.SetTree(0);
76  }
77  }
78 
79 } // namespace Internal
80 } // namespace ROOT
virtual TTree * GetTree()
Return pointer to friend TTree.
long long Long64_t
Definition: RtypesCore.h:69
Namespace for new ROOT classes and functions.
Definition: ROOT.py:1
virtual Long64_t GetReadEntry() const
Definition: TTree.h:424
int Int_t
Definition: RtypesCore.h:41
virtual TObject * At(Int_t idx) const
Returns the object at position idx. Returns 0 if idx is out of range.
Definition: TList.cxx:310
virtual TList * GetListOfFriends() const
Definition: TTree.h:407
TBranchProxyDirector fDirector
Definition: TFriendProxy.h:26
void ResetReadEntry()
Refresh the cached read entry number from the original tree.
void Update(TTree *newmain)
Update the address of the underlying tree.
int main(int argc, char *argv[])
Definition: python64.c:14
Long64_t GetReadEntry() const
Return the entry number currently being looked at.
virtual TTree * GetTree() const
Definition: TTree.h:432
ClassImp(ROOT::Internal::TFriendProxy)
Mother of all ROOT objects.
Definition: TObject.h:58
A TFriendElement TF describes a TTree object TF in a file.
A TTree object has a header with a name and a title.
Definition: TTree.h:94
TObject * obj
void Attach(Detail::TBranchProxy *p)