Logo ROOT   6.10/09
Reference Guide
TRefProxy.cxx
Go to the documentation of this file.
1 // @(#)root/meta:$Id$
2 // Author: Markus Frank 10/02/2006
3 
4 /*************************************************************************
5 * Copyright (C) 1995-2000, 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 "TRef.h"
13 #include "TTree.h"
14 #include "TError.h"
15 #include "TBranch.h"
16 #include "TRefProxy.h"
17 #include "TBranchRef.h"
18 #include "TRefTable.h"
19 #include "TTreeFormula.h"
20 #include "TFormLeafInfoReference.h"
21 #include <iostream>
22 
23 /** class TRefProxy
24 A reference proxy, which allows to access ROOT references (TRef)
25 stored contained in other objects from TTree::Draw
26 */
27 
28 ////////////////////////////////////////////////////////////////////////////////
29 /// TVirtualRefProxy overload: Update (and propagate) cached information
30 
32 {
33  return kTRUE;
34 }
35 
36 ////////////////////////////////////////////////////////////////////////////////
37 /// TVirtualRefProxy overload: Access to value class
38 
40 {
41  TObject* obj = (TObject*)data;
42  return ( obj ) ? obj->IsA() : 0;
43 }
44 
45 ////////////////////////////////////////////////////////////////////////////////
46 /// Access referenced object(-data)
47 
49 {
50  if ( data ) {
51  TRef* ref = (TRef*)((char*)data + info->GetOffset());
52  void* obj = ref->GetObject();
53  // std::cout << "UID=" << ref->GetUniqueID() << std::endl;
54  if ( obj ) {
55  return obj;
56  }
57  else {
58  TBranch* branch = info->GetBranch();
59  if ( branch ) {
60  UInt_t uid = ref->GetUniqueID();
61  Long64_t ent = branch->GetReadEntry();
63  table->SetUID(uid, ref->GetPID());
64  ((TBranch*)table->GetOwner())->GetEntry(ent);
65  TBranch *b = (TBranch*)table->GetParent(uid, ref->GetPID());
66  if ( 0 == b ) {
67  ((TBranch*)table->GetOwner())->GetEntry(ent);
68  b = (TBranch*)table->GetParent(uid, ref->GetPID());
69  }
70  if ( 0 != b ) {
71  TBranch* br = b->GetMother();
72  if ( br ) br->GetEntry(ent);
73  }
74  obj = ref->GetObject();
75  if ( obj ) {
76  (*ref) = 0;
77  return obj;
78  }
79  }
80  }
81  }
82  return 0;
83 }
virtual UInt_t GetUniqueID() const
Return the unique object id.
Definition: TObject.cxx:382
A small helper class to implement the following of reference objects stored in a TTree.
long long Long64_t
Definition: RtypesCore.h:69
bool Bool_t
Definition: RtypesCore.h:59
Persistent Reference link to a TObject A TRef is a lightweight object pointing to any TObject...
Definition: TRef.h:32
virtual TClass * GetValueClass(void *data) const
TVirtualRefProxy overload: Access to value class.
Definition: TRefProxy.cxx:39
TObject * GetObject() const
Return a pointer to the referenced object.
Definition: TRef.cxx:377
unsigned int UInt_t
Definition: RtypesCore.h:42
virtual Int_t GetEntry(Long64_t entry=0, Int_t getall=0)
Read all leaves of entry and return total number of bytes read.
Definition: TBranch.cxx:1291
The ROOT global object gROOT contains a list of all defined classes.
Definition: TClass.h:71
TObject * GetOwner() const
Definition: TRefTable.h:77
static TRefTable * GetRefTable()
Static function returning the current TRefTable.
Definition: TRefTable.cxx:287
A TRefTable maintains the association between a referenced object and the parent object supporting th...
Definition: TRefTable.h:35
TProcessID * GetPID() const
Definition: TRef.h:52
virtual Bool_t Update()
TVirtualRefProxy overload: Update (and propagate) cached information.
Definition: TRefProxy.cxx:31
Mother of all ROOT objects.
Definition: TObject.h:37
virtual Int_t GetOffset() const
Long64_t GetReadEntry() const
Definition: TBranch.h:174
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
A TTree is a list of TBranches.
Definition: TBranch.h:57
const Bool_t kTRUE
Definition: RtypesCore.h:91
virtual void SetUID(UInt_t uid, TProcessID *context=0)
Definition: TRefTable.h:87
TBranch * GetMother() const
Get our top-level parent branch in the tree.
Definition: TBranch.cxx:1625
virtual void * GetObject(TFormLeafInfoReference *info, void *data, int instance)
TVirtualRefProxy overload: Access referenced object(-data)
Definition: TRefProxy.cxx:48
TObject * GetParent(Int_t uid, TProcessID *context=0) const
Return object corresponding to uid.
Definition: TRefTable.cxx:249