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 true;
34}
35
36////////////////////////////////////////////////////////////////////////////////
37/// TVirtualRefProxy overload: Access to value class
38
40{
41 TObject* obj = (TObject*)data;
42 return ( obj ) ? obj->IsA() : nullptr;
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 ( nullptr == b ) {
67 ((TBranch*)table->GetOwner())->GetEntry(ent);
68 b = (TBranch*)table->GetParent(uid, ref->GetPID());
69 }
70 if ( nullptr != b ) {
71 TBranch* br = b->GetMother();
72 if ( br ) br->GetEntry(ent);
73 }
74 obj = ref->GetObject();
75 if ( obj ) {
76 (*ref) = nullptr;
77 return obj;
78 }
79 }
80 }
81 }
82 return nullptr;
83}
#define b(i)
Definition RSha256.hxx:100
long long Long64_t
Definition RtypesCore.h:80
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
A TTree is a list of TBranches.
Definition TBranch.h:93
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:1706
Long64_t GetReadEntry() const
Definition TBranch.h:237
TBranch * GetMother() const
Get our top-level parent branch in the tree.
Definition TBranch.cxx:2127
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:81
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:457
virtual TClass * IsA() const
Definition TObject.h:245
TClass * GetValueClass(void *data) const override
TVirtualRefProxy overload: Access to value class.
Definition TRefProxy.cxx:39
bool Update() override
TVirtualRefProxy overload: Update (and propagate) cached information.
Definition TRefProxy.cxx:31
void * GetObject(TFormLeafInfoReference *info, void *data, int instance) override
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
virtual void SetUID(UInt_t uid, TProcessID *context=nullptr)
Definition TRefTable.h:91
TObject * GetParent(Int_t uid, TProcessID *context=nullptr) const
Return object corresponding to uid.
TObject * GetOwner() const
Definition TRefTable.h:81
static TRefTable * GetRefTable()
Static function returning the current TRefTable.
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