17 #ifndef ROOT_TBranchProxyTemplate
18 #define ROOT_TBranchProxyTemplate
20 #if R__BRANCHPROXY_GENERATOR_VERSION != 2
22 # error "Please regenerate this file using TTree::MakeProxy()!"
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(); }
39 Detail::TBranchProxy obj;
41 InjecTBranchProxyInterface();
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) {};
53 Int_t GetOffset() {
return obj.GetOffset(); }
57 std::cout <<
"fWhere " << obj.GetWhere() << std::endl;
58 if (obj.GetWhere()) std::cout <<
"address? " << (T*)obj.GetWhere() << std::endl;
63 if (!obj.Read())
return 0;
64 T *temp = (T*)obj.GetStart();
69 T* operator->() {
return GetPtr(); }
70 operator T*() {
return GetPtr(); }
79 InjecTBranchProxyInterface();
83 std::cout <<
"obj.GetWhere() " << obj.GetWhere() << std::endl;
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) {};
97 const TClonesArray* GetPtr() {
return obj.GetPtr(); }
99 Int_t GetEntries() {
return obj.GetEntries(); }
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;
106 T* temp = (T*)obj.GetClaStart(i);
107 if (temp)
return temp;
108 else return &default_val;
111 const T* operator [](Int_t i) {
return At(i); }
112 const T* operator [](UInt_t i) {
return At(i); }
121 InjecTBranchProxyInterface();
125 std::cout <<
"obj.GetWhere() " << obj.GetWhere() << std::endl;
129 TStlObjProxy() : obj() {};
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) {};
139 TVirtualCollectionProxy* GetCollection() {
143 Int_t GetEntries() {
return obj.GetEntries(); }
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;
150 value_t *temp = (value_t*)obj.GetStlStart(i);
151 if (temp)
return *temp;
152 else return default_val;
155 const value_t& operator [](Int_t i) {
return At(i); }
156 const value_t& operator [](UInt_t i) {
return At(i); }
162 class TStlSimpleProxy : TObjProxy<T> {
165 TVirtualCollectionProxy *fCollection;
166 typedef typename T::value_type value_t;
169 TStlSimpleProxy() : TObjProxy<T>(),fCollection(0) {};
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) {};
177 ~TStlSimpleProxy() {
delete fCollection; };
179 TVirtualCollectionProxy* GetCollection() {
180 if (fCollection==0) {
181 TClass *cl = TClass::GetClass<T>();
182 if (cl && cl->GetCollectionProxy()) {
183 fCollection = cl->GetCollectionProxy()->Generate();
190 T *temp = TObjProxy<T>::GetPtr();
193 if (!fCollection)
return 0;
194 TVirtualCollectionProxy::TPushPop helper( fCollection, temp );
195 return fCollection->Size();
200 const value_t At(UInt_t i) {
201 static value_t default_val;
202 T *temp = TObjProxy<T>::GetPtr();
205 if (!fCollection)
return 0;
206 TVirtualCollectionProxy::TPushPop helper( fCollection, temp );
207 return *(value_t*)(fCollection->At(i));
209 else return default_val;
212 const value_t operator [](Int_t i) {
return At(i); }
213 const value_t operator [](UInt_t i) {
return At(i); }
215 T* operator->() {
return TObjProxy<T>::GetPtr(); }
216 operator T*() {
return TObjProxy<T>::GetPtr(); }