Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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"
21#include <iostream>
22
23/** class TRefProxy
24A reference proxy, which allows to access ROOT references (TRef)
25stored 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
48void* TRefProxy::GetObject(TFormLeafInfoReference* info, void* data, int)
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}
#define b(i)
Definition RSha256.hxx:100
long long Long64_t
Definition RtypesCore.h:80
const Bool_t kTRUE
Definition RtypesCore.h:100
A TTree is a list of TBranches.
Definition TBranch.h:89
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:1652
Long64_t GetReadEntry() const
Definition TBranch.h:233
TBranch * GetMother() const
Get our top-level parent branch in the tree.
Definition TBranch.cxx:2065
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:80
A small helper class to implement the following of reference objects stored in a TTree.
TBranch * GetBranch() const
Access to the info's connected branch.
virtual Int_t GetOffset() const
Access to the offset of the data.
Mother of all ROOT objects.
Definition TObject.h:41
virtual UInt_t GetUniqueID() const
Return the unique object id.
Definition TObject.cxx:447
virtual Bool_t Update()
TVirtualRefProxy overload: Update (and propagate) cached information.
Definition TRefProxy.cxx:31
virtual TClass * GetValueClass(void *data) const
TVirtualRefProxy overload: Access to value class.
Definition TRefProxy.cxx:39
virtual void * GetObject(TFormLeafInfoReference *info, void *data, int instance)
TVirtualRefProxy overload: Access referenced object(-data)
Definition TRefProxy.cxx:48
A TRefTable maintains the association between a referenced object and the parent object supporting th...
Definition TRefTable.h:35
TObject * GetOwner() const
Definition TRefTable.h:77
static TRefTable * GetRefTable()
Static function returning the current TRefTable.
TObject * GetParent(Int_t uid, TProcessID *context=0) const
Return object corresponding to uid.
virtual void SetUID(UInt_t uid, TProcessID *context=0)
Definition TRefTable.h:87
Persistent Reference link to a TObject A TRef is a lightweight object pointing to any TObject.
Definition TRef.h:32
TProcessID * GetPID() const
Definition TRef.h:50
TObject * GetObject() const
Return a pointer to the referenced object.
Definition TRef.cxx:377