Warning, file /include/root/TBranchProxyTemplate.h was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 #ifndef ROOT_TBranchProxyTemplate
0018 #define ROOT_TBranchProxyTemplate
0019
0020 #if R__BRANCHPROXY_GENERATOR_VERSION != 2
0021
0022 # error "Please regenerate this file using TTree::MakeProxy()!"
0023 #endif
0024
0025 #include "TBranchProxy.h"
0026
0027 #define InjecTBranchProxyInterface() \
0028 ROOT::Detail::TBranchProxy *GetProxy() { return obj.GetProxy(); } \
0029 void Reset() { obj.Reset(); } \
0030 bool Setup() { return obj.Setup(); } \
0031 bool IsInitialized() { return obj.IsInitialized(); } \
0032 bool IsaPointer() const { return obj.IsaPointer(); } \
0033 bool Read() { return obj.Read(); }
0034
0035 namespace ROOT {
0036 namespace Internal {
0037 template <class T>
0038 class TObjProxy {
0039 Detail::TBranchProxy obj;
0040 public:
0041 InjecTBranchProxyInterface();
0042
0043 TObjProxy() : obj() {};
0044 TObjProxy(TBranchProxyDirector *director, const char *name) : obj(director,name) {};
0045 TObjProxy(TBranchProxyDirector *director, const char *top, const char *name) :
0046 obj(director,top,name) {};
0047 TObjProxy(TBranchProxyDirector *director, const char *top, const char *name, const char *data) :
0048 obj(director,top,name,data) {};
0049 TObjProxy(TBranchProxyDirector *director, Detail::TBranchProxy *parent, const char *name, const char* top = 0, const char* mid = 0) :
0050 obj(director,parent, name, top, mid) {};
0051 ~TObjProxy() {};
0052
0053 Int_t GetOffset() { return obj.GetOffset(); }
0054
0055 void Print() {
0056 obj.Print();
0057 std::cout << "fWhere " << obj.GetWhere() << std::endl;
0058 if (obj.GetWhere()) std::cout << "address? " << (T*)obj.GetWhere() << std::endl;
0059 }
0060
0061 T* GetPtr() {
0062
0063 if (!obj.Read()) return 0;
0064 T *temp = (T*)obj.GetStart();
0065
0066 return temp;
0067 }
0068
0069 T* operator->() { return GetPtr(); }
0070 operator T*() { return GetPtr(); }
0071
0072
0073 };
0074
0075 template <class T>
0076 class TClaObjProxy {
0077 TClaProxy obj;
0078 public:
0079 InjecTBranchProxyInterface();
0080
0081 void Print() {
0082 obj.Print();
0083 std::cout << "obj.GetWhere() " << obj.GetWhere() << std::endl;
0084
0085 }
0086
0087 TClaObjProxy() : obj() {};
0088 TClaObjProxy(TBranchProxyDirector *director, const char *name) : obj(director,name) {};
0089 TClaObjProxy(TBranchProxyDirector *director, const char *top, const char *name) :
0090 obj(director,top,name) {};
0091 TClaObjProxy(TBranchProxyDirector *director, const char *top, const char *name, const char *data) :
0092 obj(director,top,name,data) {};
0093 TClaObjProxy(TBranchProxyDirector *director, Detail::TBranchProxy *parent, const char *name, const char* top = 0, const char* mid = 0) :
0094 obj(director,parent, name, top, mid) {};
0095 ~TClaObjProxy() {};
0096
0097 const TClonesArray* GetPtr() { return obj.GetPtr(); }
0098
0099 Int_t GetEntries() { return obj.GetEntries(); }
0100
0101 const T* At(UInt_t i) {
0102 static T default_val;
0103 if (!obj.Read()) return &default_val;
0104 if (obj.GetWhere()==0) return &default_val;
0105
0106 T* temp = (T*)obj.GetClaStart(i);
0107 if (temp) return temp;
0108 else return &default_val;
0109 }
0110
0111 const T* operator [](Int_t i) { return At(i); }
0112 const T* operator [](UInt_t i) { return At(i); }
0113
0114 };
0115
0116 template <class T>
0117 class TStlObjProxy {
0118 TStlProxy obj;
0119 typedef T value_t;
0120 public:
0121 InjecTBranchProxyInterface();
0122
0123 void Print() {
0124 obj.Print();
0125 std::cout << "obj.GetWhere() " << obj.GetWhere() << std::endl;
0126
0127 }
0128
0129 TStlObjProxy() : obj() {};
0130 TStlObjProxy(TBranchProxyDirector *director, const char *name) : obj(director,name) {};
0131 TStlObjProxy(TBranchProxyDirector *director, const char *top, const char *name) :
0132 obj(director,top,name) {};
0133 TStlObjProxy(TBranchProxyDirector *director, const char *top, const char *name, const char *data) :
0134 obj(director,top,name,data) {};
0135 TStlObjProxy(TBranchProxyDirector *director, Detail::TBranchProxy *parent, const char *name, const char* top = 0, const char* mid = 0) :
0136 obj(director,parent, name, top, mid) {};
0137 ~TStlObjProxy() {};
0138
0139 TVirtualCollectionProxy* GetCollection() {
0140 return obj.GetPtr();
0141 }
0142
0143 Int_t GetEntries() { return obj.GetEntries(); }
0144
0145 const value_t& At(UInt_t i) {
0146 static const value_t default_val;
0147 if (!obj.Read()) return default_val;
0148 if (obj.GetWhere()==0) return default_val;
0149
0150 value_t *temp = (value_t*)obj.GetStlStart(i);
0151 if (temp) return *temp;
0152 else return default_val;
0153 }
0154
0155 const value_t& operator [](Int_t i) { return At(i); }
0156 const value_t& operator [](UInt_t i) { return At(i); }
0157
0158 };
0159
0160
0161 template <class T>
0162 class TStlSimpleProxy : TObjProxy<T> {
0163
0164
0165 TVirtualCollectionProxy *fCollection;
0166 typedef typename T::value_type value_t;
0167 public:
0168
0169 TStlSimpleProxy() : TObjProxy<T>(),fCollection(0) {};
0170 TStlSimpleProxy(TBranchProxyDirector *director, const char *name) : TObjProxy<T>(director,name),fCollection(0) {};
0171 TStlSimpleProxy(TBranchProxyDirector *director, const char *top, const char *name) :
0172 TObjProxy<T>(director,top,name),fCollection(0) {};
0173 TStlSimpleProxy(TBranchProxyDirector *director, const char *top, const char *name, const char *data) :
0174 TObjProxy<T>(director,top,name,data),fCollection(0) {};
0175 TStlSimpleProxy(TBranchProxyDirector *director, Detail::TBranchProxy *parent, const char *name, const char* top = 0, const char* mid = 0) :
0176 TObjProxy<T>(director,parent, name, top, mid),fCollection(0) {};
0177 ~TStlSimpleProxy() { delete fCollection; };
0178
0179 TVirtualCollectionProxy* GetCollection() {
0180 if (fCollection==0) {
0181 TClass *cl = TClass::GetClass<T>();
0182 if (cl && cl->GetCollectionProxy()) {
0183 fCollection = cl->GetCollectionProxy()->Generate();
0184 }
0185 }
0186 return fCollection;
0187 }
0188
0189 Int_t GetEntries() {
0190 T *temp = TObjProxy<T>::GetPtr();
0191 if (temp) {
0192 GetCollection();
0193 if (!fCollection) return 0;
0194 TVirtualCollectionProxy::TPushPop helper( fCollection, temp );
0195 return fCollection->Size();
0196 }
0197 return 0;
0198 }
0199
0200 const value_t At(UInt_t i) {
0201 static value_t default_val;
0202 T *temp = TObjProxy<T>::GetPtr();
0203 if (temp) {
0204 GetCollection();
0205 if (!fCollection) return 0;
0206 TVirtualCollectionProxy::TPushPop helper( fCollection, temp );
0207 return *(value_t*)(fCollection->At(i));
0208 }
0209 else return default_val;
0210 }
0211
0212 const value_t operator [](Int_t i) { return At(i); }
0213 const value_t operator [](UInt_t i) { return At(i); }
0214
0215 T* operator->() { return TObjProxy<T>::GetPtr(); }
0216 operator T*() { return TObjProxy<T>::GetPtr(); }
0217
0218
0219 };
0220
0221 }
0222 }
0223
0224 #endif