Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TBranchProxyTemplate.h
Go to the documentation of this file.
1// @(#)root/treeplayer:$Id$
2// Author: Philippe Canal 01/06/2004
3
4/*************************************************************************
5 * Copyright (C) 1995-2004, Rene Brun and 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// NOTE: This header is only used by selectors, to verify that the selector
13// source matches the ROOT interface. It should not end up in the
14// dictionary nor in the PCH, so it should not be added to the list
15// of headers of the TreePlayer library.
16
17#ifndef ROOT_TBranchProxyTemplate
18#define ROOT_TBranchProxyTemplate
19
20#if R__BRANCHPROXY_GENERATOR_VERSION != 2
21// Generated source and branch proxy interface are out of sync.
22# error "Please regenerate this file using TTree::MakeProxy()!"
23#endif
24
25#include "TBranchProxy.h"
26
27#define InjecTBranchProxyInterface() \
28 ROOT::Detail::TBranchProxy *GetProxy() { return obj.GetProxy(); } \
29 void Reset() { obj.Reset(); } \
30 bool Setup() { return obj.Setup(); } \
31 bool IsInitialized() { return obj.IsInitialized(); } \
32 bool IsaPointer() const { return obj.IsaPointer(); } \
33 bool Read() { return obj.Read(); }
34
35namespace ROOT {
36namespace Internal {
37 template <class T>
38 class TObjProxy {
40 public:
42
43 TObjProxy() : obj() {};
44 TObjProxy(TBranchProxyDirector *director, const char *name) : obj(director,name) {};
45 TObjProxy(TBranchProxyDirector *director, const char *top, const char *name) :
46 obj(director,top,name) {};
47 TObjProxy(TBranchProxyDirector *director, const char *top, const char *name, const char *data) :
48 obj(director,top,name,data) {};
49 TObjProxy(TBranchProxyDirector *director, Detail::TBranchProxy *parent, const char *name, const char* top = 0, const char* mid = 0) :
50 obj(director,parent, name, top, mid) {};
52
53 Int_t GetOffset() { return obj.GetOffset(); }
54
55 void Print() {
56 obj.Print();
57 std::cout << "fWhere " << obj.GetWhere() << std::endl;
58 if (obj.GetWhere()) std::cout << "address? " << (T*)obj.GetWhere() << std::endl;
59 }
60
61 T* GetPtr() {
62 //static T default_val;
63 if (!obj.Read()) return 0; // &default_val;
64 T *temp = (T*)obj.GetStart();
65 // if (temp==0) return &default_val;
66 return temp;
67 }
68
69 T* operator->() { return GetPtr(); }
70 operator T*() { return GetPtr(); }
71 // operator T&() { return *GetPtr(); }
72
73 };
74
75 template <class T>
78 public:
80
81 void Print() {
82 obj.Print();
83 std::cout << "obj.GetWhere() " << obj.GetWhere() << std::endl;
84 //if (obj.GetWhere()) std::cout << "value? " << *(T*)obj.GetWhere() << std::endl;
85 }
86
87 TClaObjProxy() : obj() {};
88 TClaObjProxy(TBranchProxyDirector *director, const char *name) : obj(director,name) {};
89 TClaObjProxy(TBranchProxyDirector *director, const char *top, const char *name) :
90 obj(director,top,name) {};
91 TClaObjProxy(TBranchProxyDirector *director, const char *top, const char *name, const char *data) :
92 obj(director,top,name,data) {};
93 TClaObjProxy(TBranchProxyDirector *director, Detail::TBranchProxy *parent, const char *name, const char* top = 0, const char* mid = 0) :
94 obj(director,parent, name, top, mid) {};
96
97 const TClonesArray* GetPtr() { return obj.GetPtr(); }
98
100
101 const T* At(UInt_t i) {
102 static T default_val;
103 if (!obj.Read()) return &default_val;
104 if (obj.GetWhere()==0) return &default_val;
105
106 T* temp = (T*)obj.GetClaStart(i);
107 if (temp) return temp;
108 else return &default_val;
109 }
110
111 const T* operator [](Int_t i) { return At(i); }
112 const T* operator [](UInt_t i) { return At(i); }
113
114 };
115
116 template <class T>
119 typedef T value_t;
120 public:
122
123 void Print() {
124 obj.Print();
125 std::cout << "obj.GetWhere() " << obj.GetWhere() << std::endl;
126 //if (obj.GetWhere()) std::cout << "value? " << *(T*)obj.GetWhere() << std::endl;
127 }
128
130 TStlObjProxy(TBranchProxyDirector *director, const char *name) : obj(director,name) {};
131 TStlObjProxy(TBranchProxyDirector *director, const char *top, const char *name) :
132 obj(director,top,name) {};
133 TStlObjProxy(TBranchProxyDirector *director, const char *top, const char *name, const char *data) :
134 obj(director,top,name,data) {};
135 TStlObjProxy(TBranchProxyDirector *director, Detail::TBranchProxy *parent, const char *name, const char* top = 0, const char* mid = 0) :
136 obj(director,parent, name, top, mid) {};
138
140 return obj.GetPtr();
141 }
142
144
145 const value_t& At(UInt_t i) {
146 static const value_t default_val;
147 if (!obj.Read()) return default_val;
148 if (obj.GetWhere()==0) return default_val;
149
150 value_t *temp = (value_t*)obj.GetStlStart(i);
151 if (temp) return *temp;
152 else return default_val;
153 }
154
155 const value_t& operator [](Int_t i) { return At(i); }
156 const value_t& operator [](UInt_t i) { return At(i); }
157
158 };
159
160
161 template <class T>
163 // Intended to compiled non-split collection
164
166 typedef typename T::value_type value_t;
167 public:
168
170 TStlSimpleProxy(TBranchProxyDirector *director, const char *name) : TObjProxy<T>(director,name),fCollection(0) {};
171 TStlSimpleProxy(TBranchProxyDirector *director, const char *top, const char *name) :
172 TObjProxy<T>(director,top,name),fCollection(0) {};
173 TStlSimpleProxy(TBranchProxyDirector *director, const char *top, const char *name, const char *data) :
174 TObjProxy<T>(director,top,name,data),fCollection(0) {};
175 TStlSimpleProxy(TBranchProxyDirector *director, Detail::TBranchProxy *parent, const char *name, const char* top = 0, const char* mid = 0) :
176 TObjProxy<T>(director,parent, name, top, mid),fCollection(0) {};
178
180 if (fCollection==0) {
181 TClass *cl = TClass::GetClass<T>();
182 if (cl && cl->GetCollectionProxy()) {
184 }
185 }
186 return fCollection;
187 }
188
190 T *temp = TObjProxy<T>::GetPtr();
191 if (temp) {
193 if (!fCollection) return 0;
195 return fCollection->Size();
196 }
197 return 0;
198 }
199
200 const value_t At(UInt_t i) {
201 static value_t default_val;
202 T *temp = TObjProxy<T>::GetPtr();
203 if (temp) {
205 if (!fCollection) return 0;
207 return *(value_t*)(fCollection->At(i));
208 }
209 else return default_val;
210 }
211
212 const value_t operator [](Int_t i) { return At(i); }
213 const value_t operator [](UInt_t i) { return At(i); }
214
216 operator T*() { return TObjProxy<T>::GetPtr(); }
217 // operator T&() { return *GetPtr(); }
218
219 };
220
221} // namespace Internal
222} // namespace ROOT
223
224#endif
#define InjecTBranchProxyInterface()
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
char name[80]
Definition TGX11.cxx:110
Base class for all the proxy object.
void * GetClaStart(UInt_t i=0)
void * GetStlStart(UInt_t i=0)
virtual void * GetStart(UInt_t=0)
virtual void Print()
Display the content of the object.
TClaObjProxy(TBranchProxyDirector *director, const char *top, const char *name)
TClaObjProxy(TBranchProxyDirector *director, const char *name)
TClaObjProxy(TBranchProxyDirector *director, const char *top, const char *name, const char *data)
TClaObjProxy(TBranchProxyDirector *director, Detail::TBranchProxy *parent, const char *name, const char *top=0, const char *mid=0)
Base class for the proxy around object in TClonesArray.
Int_t GetEntries() override
const TClonesArray * GetPtr()
void Print() override
Display the content of the object.
TObjProxy(TBranchProxyDirector *director, const char *top, const char *name)
TObjProxy(TBranchProxyDirector *director, const char *top, const char *name, const char *data)
TObjProxy(TBranchProxyDirector *director, Detail::TBranchProxy *parent, const char *name, const char *top=0, const char *mid=0)
TObjProxy(TBranchProxyDirector *director, const char *name)
TStlObjProxy(TBranchProxyDirector *director, Detail::TBranchProxy *parent, const char *name, const char *top=0, const char *mid=0)
TVirtualCollectionProxy * GetCollection()
TStlObjProxy(TBranchProxyDirector *director, const char *top, const char *name, const char *data)
TStlObjProxy(TBranchProxyDirector *director, const char *name)
const value_t & At(UInt_t i)
TStlObjProxy(TBranchProxyDirector *director, const char *top, const char *name)
const value_t & operator[](Int_t i)
Base class for the proxy around STL containers.
Int_t GetEntries() override
void Print() override
Display the content of the object.
TVirtualCollectionProxy * GetPtr()
TVirtualCollectionProxy * fCollection
TStlSimpleProxy(TBranchProxyDirector *director, Detail::TBranchProxy *parent, const char *name, const char *top=0, const char *mid=0)
TVirtualCollectionProxy * GetCollection()
TStlSimpleProxy(TBranchProxyDirector *director, const char *top, const char *name)
TStlSimpleProxy(TBranchProxyDirector *director, const char *top, const char *name, const char *data)
TStlSimpleProxy(TBranchProxyDirector *director, const char *name)
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:81
TVirtualCollectionProxy * GetCollectionProxy() const
Return the proxy describing the collection (if any).
Definition TClass.cxx:2964
An array of clone (identical) objects.
RAII helper class that ensures that PushProxy() / PopProxy() are called when entering / leaving a C++...
Defines a common interface to inspect/change the contents of an object that represents a collection.
virtual void * At(UInt_t idx)=0
Return the address of the value at index idx
virtual UInt_t Size() const =0
Return the current number of elements in the container.
virtual TVirtualCollectionProxy * Generate() const =0
Returns a clean object of the actual class that derives from TVirtualCollectionProxy.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...