TBranchProxy.h

Go to the documentation of this file.
00001 // @(#)root/treeplayer:$Id: TBranchProxy.h 36449 2010-10-28 20:52:17Z pcanal $
00002 // Author: Philippe Canal 01/06/2004
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers and al.        *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #ifndef ROOT_TBranchProxy
00013 #define ROOT_TBranchProxy
00014 
00015 #ifndef ROOT_TBranchProxyDirector
00016 #include "TBranchProxyDirector.h"
00017 #endif
00018 #ifndef ROOT_TTree
00019 #include "TTree.h"
00020 #endif
00021 #ifndef ROOT_TBranch
00022 #include "TBranch.h"
00023 #endif
00024 #ifndef ROOT_TClonesArray
00025 #include "TClonesArray.h"
00026 #endif
00027 #ifndef ROOT_TString
00028 #include "TString.h"
00029 #endif
00030 #ifndef ROOT_Riostream
00031 #include "Riostream.h"
00032 #endif
00033 #ifndef ROOT_TError
00034 #include "TError.h"
00035 #endif
00036 #ifndef ROOT_TVirtualCollectionProxy
00037 #include "TVirtualCollectionProxy.h"
00038 #endif
00039 
00040 #include <list>
00041 #include <algorithm>
00042 
00043 class TBranch;
00044 class TStreamerElement;
00045 
00046 // Note we could protect the arrays more by introducing a class TArrayWrapper<class T> which somehow knows
00047 // its internal dimensions and check for them ...
00048 // template <class T> TArrayWrapper {
00049 // public:
00050 //    TArrayWrapper(void *where, int dim1);
00051 //    const T operator[](int i) {
00052 //       if (i>=dim1) return 0;
00053 //       return where[i];
00054 //    };
00055 // };
00056 // 2D array would actually be a wrapper of a wrapper i.e. has a method TArrayWrapper<T> operator[](int i);
00057 
00058 namespace ROOT {
00059 
00060    //_______________________________________________
00061    // String builder to be used in the constructors.
00062    class TBranchProxyHelper {
00063    public:
00064       TString fName;
00065       TBranchProxyHelper(const char *left,const char *right = 0) :
00066          fName() {
00067          if (left) {
00068             fName = left;
00069             if (strlen(left)&&right && fName[fName.Length()-1]!='.') fName += ".";
00070          }
00071          if (right) {
00072             fName += right;
00073          }
00074       }
00075       operator const char*() { return fName.Data(); };
00076    };
00077 
00078 
00079    class TBranchProxy {
00080    protected:
00081       TBranchProxyDirector *fDirector; // contain pointer to TTree and entry to be read
00082 
00083       Bool_t   fInitialized;
00084 
00085       const TString fBranchName;  // name of the branch to read
00086       TBranchProxy *fParent;      // Proxy to a parent object
00087 
00088       const TString fDataMember;  // name of the (eventual) data member being proxied
00089 
00090       const Bool_t  fIsMember;    // true if we proxy an unsplit data member
00091       Bool_t        fIsClone;     // true if we proxy the inside of a TClonesArray
00092       Bool_t        fIsaPointer;  // true if we proxy a data member of pointer type
00093 
00094 
00095       TString           fClassName;     // class name of the object pointed to by the branch
00096       TClass           *fClass;         // class name of the object pointed to by the branch
00097       TStreamerElement *fElement;
00098       Int_t             fMemberOffset;
00099       Int_t             fOffset;        // Offset inside the object
00100 
00101       TBranch *fBranch;       // branch to read
00102       TBranch *fBranchCount;  // eventual auxiliary branch (for example holding the size)
00103 
00104       TTree   *fLastTree; // TTree containing the last entry read
00105       Long64_t fRead;     // Last entry read
00106 
00107       void    *fWhere;    // memory location of the data
00108       TVirtualCollectionProxy *fCollection; // Handle to the collection containing the data chunk.
00109 
00110    public:
00111       virtual void Print();
00112 
00113       TBranchProxy();
00114       TBranchProxy(TBranchProxyDirector* boss, const char* top, const char* name = 0);
00115       TBranchProxy(TBranchProxyDirector* boss, const char *top, const char *name, const char *membername);
00116       TBranchProxy(TBranchProxyDirector* boss, TBranchProxy *parent, const char* membername, const char* top = 0, const char* name = 0);
00117       virtual ~TBranchProxy();
00118 
00119       TBranchProxy* GetProxy() { return this; }
00120 
00121       void Reset();
00122 
00123       Bool_t Setup();
00124 
00125       Bool_t IsInitialized() {
00126          return fLastTree && (fLastTree == fDirector->GetTree());
00127       }
00128 
00129       Bool_t IsaPointer() const {
00130          return fIsaPointer;
00131       }
00132 
00133       Bool_t Read() {
00134          if (fDirector==0) return false;
00135 
00136          if (fDirector->GetReadEntry()!=fRead) {
00137             if (!IsInitialized()) {
00138                if (!Setup()) {
00139                   Error("Read","%s",Form("Unable to initialize %s\n",fBranchName.Data()));
00140                   return kFALSE;
00141                }
00142             }
00143             Bool_t result = kTRUE;
00144             if (fParent) {
00145                result = fParent->Read();
00146             } else {
00147                if (fBranchCount) {
00148                   result &= (-1 != fBranchCount->GetEntry(fDirector->GetReadEntry()));
00149                }
00150                result &= (-1 != fBranch->GetEntry(fDirector->GetReadEntry()));
00151             }
00152             fRead = fDirector->GetReadEntry();
00153             return result;
00154          } else {
00155             return IsInitialized();
00156          }
00157       }
00158 
00159       Bool_t ReadEntries() {
00160          if (fDirector==0) return false;
00161 
00162          if (fDirector->GetReadEntry()!=fRead) {
00163             if (!IsInitialized()) {
00164                if (!Setup()) {
00165                   Error("Read","%s",Form("Unable to initialize %s\n",fBranchName.Data()));
00166                   return false;
00167                }
00168             }
00169             if (fParent) fParent->ReadEntries();
00170             else {
00171                if (fBranchCount) {
00172                   fBranchCount->TBranch::GetEntry(fDirector->GetReadEntry());
00173                }
00174                fBranch->TBranch::GetEntry(fDirector->GetReadEntry());
00175             }
00176             // NO - we only read the entries, not the contained objects!
00177             // fRead = fDirector->GetReadEntry();
00178          }
00179          return IsInitialized();
00180       }
00181 
00182       TClass *GetClass() {
00183          if (fDirector==0) return 0;
00184          if (fDirector->GetReadEntry()!=fRead) {
00185             if (!IsInitialized()) {
00186                if (!Setup()) {
00187                   return 0;
00188                }
00189             }
00190          }
00191          return fClass;
00192       }
00193 
00194       void* GetWhere() const { return fWhere; } // intentionally non-virtual
00195       
00196       TVirtualCollectionProxy *GetCollection() { return fCollection; }
00197 
00198       // protected:
00199       virtual  void *GetStart(UInt_t /*i*/=0) {
00200          // return the address of the start of the object being proxied. Assumes
00201          // that Setup() has been called.
00202 
00203          if (fParent) {
00204             fWhere = ((unsigned char*)fParent->GetStart()) + fMemberOffset;
00205          }
00206          if (IsaPointer()) {
00207             if (fWhere) return *(void**)fWhere;
00208             else return 0;
00209          } else {
00210             return fWhere;
00211          }
00212       }
00213 
00214       virtual void *GetClaStart(UInt_t i=0) {
00215          // return the address of the start of the object being proxied. Assumes
00216          // that Setup() has been called.  Assumes the object containing this data
00217          // member is held in TClonesArray.
00218 
00219          char *location;
00220 
00221          if (fIsClone) {
00222 
00223             TClonesArray *tca;
00224             tca = (TClonesArray*)GetStart();
00225 
00226             if (tca->GetLast()<(Int_t)i) return 0;
00227 
00228             location = (char*)tca->At(i);
00229 
00230             return location;
00231 
00232          } else if (fParent) {
00233 
00234             //tcaloc = ((unsigned char*)fParent->GetStart());
00235             location = (char*)fParent->GetClaStart(i);
00236 
00237          } else {
00238 
00239             void *tcaloc;
00240             tcaloc = fWhere;
00241             TClonesArray *tca;
00242             tca = (TClonesArray*)tcaloc;
00243 
00244             if (tca->GetLast()<(Int_t)i) return 0;
00245 
00246             location = (char*)tca->At(i);
00247          }
00248 
00249          if (location) location += fOffset;
00250          else return 0;
00251 
00252          if (IsaPointer()) {
00253             return *(void**)(location);
00254          } else {
00255             return location;
00256          }
00257 
00258       }
00259 
00260       virtual void *GetStlStart(UInt_t i=0) {
00261          // return the address of the start of the object being proxied. Assumes
00262          // that Setup() has been called.  Assumes the object containing this data
00263          // member is held in STL Collection.
00264 
00265          char *location=0;
00266 
00267          if (fCollection) {
00268 
00269             if (fCollection->Size()<i) return 0;
00270 
00271             location = (char*)fCollection->At(i);
00272 
00273             // return location;
00274 
00275          } else if (fParent) {
00276 
00277             //tcaloc = ((unsigned char*)fParent->GetStart());
00278             location = (char*)fParent->GetStlStart(i);
00279 
00280          } else {
00281 
00282             R__ASSERT(0);
00283             //void *tcaloc;
00284             //tcaloc = fWhere;
00285             //TClonesArray *tca;
00286             //tca = (TClonesArray*)tcaloc;
00287 
00288             //if (tca->GetLast()<i) return 0;
00289 
00290             //location = (char*)tca->At(i);
00291          }
00292 
00293          if (location) location += fOffset;
00294          else return 0;
00295 
00296          if (IsaPointer()) {
00297             return *(void**)(location);
00298          } else {
00299             return location;
00300          }
00301 
00302       }
00303       
00304       Int_t GetOffset() { return fOffset; }
00305    };
00306 
00307    //____________________________________________________________________________________________
00308    // Concrete Implementation of the branch proxy around the data members which are array of char
00309    class TArrayCharProxy : public TBranchProxy {
00310    public:
00311       void Print() {
00312          TBranchProxy::Print();
00313          cout << "fWhere " << fWhere << endl;
00314          if (fWhere) cout << "value? " << *(unsigned char*)GetStart() << endl;
00315       }
00316 
00317       TArrayCharProxy() : TBranchProxy() {}
00318       TArrayCharProxy(TBranchProxyDirector *director, const char *name) : TBranchProxy(director,name) {};
00319       TArrayCharProxy(TBranchProxyDirector *director, const char *top, const char *name) :
00320          TBranchProxy(director,top,name) {};
00321       TArrayCharProxy(TBranchProxyDirector *director, const char *top, const char *name, const char *data) :
00322          TBranchProxy(director,top,name,data) {};
00323       TArrayCharProxy(TBranchProxyDirector *director, TBranchProxy *parent, const char *name, const char* top = 0, const char* mid = 0) :
00324          TBranchProxy(director,parent, name, top, mid) {};
00325       ~TArrayCharProxy() {};
00326 
00327       unsigned char At(UInt_t i) {
00328          static unsigned char default_val;
00329          if (!Read()) return default_val;
00330          // should add out-of bound test
00331          unsigned char* str = (unsigned char*)GetStart();
00332          return str[i];
00333       }
00334 
00335       unsigned char operator [](Int_t i) {
00336          return At(i);
00337       }
00338 
00339       unsigned char operator [](UInt_t i) {
00340          return At(i);
00341       }
00342 
00343       const char* c_str() {
00344          if (!Read()) return "";
00345          return (const char*)GetStart();
00346       }
00347 
00348       operator std::string() {
00349          if (!Read()) return "";
00350          return std::string((const char*)GetStart());
00351       }
00352 
00353    };
00354 
00355    //_______________________________________________________
00356    // Base class for the proxy around object in TClonesArray.
00357    class TClaProxy : public TBranchProxy {
00358    public:
00359       void Print() {
00360          TBranchProxy::Print();
00361          cout << "fWhere " << fWhere << endl;
00362          if (fWhere) {
00363             if (IsaPointer()) {
00364                cout << "location " << *(TClonesArray**)fWhere << endl;
00365             } else {
00366                cout << "location " << fWhere << endl;
00367             }
00368          }
00369       }
00370 
00371       TClaProxy() : TBranchProxy() {}
00372       TClaProxy(TBranchProxyDirector *director, const char *name) : TBranchProxy(director,name) {};
00373       TClaProxy(TBranchProxyDirector *director, const char *top, const char *name) :
00374          TBranchProxy(director,top,name) {};
00375       TClaProxy(TBranchProxyDirector *director, const char *top, const char *name, const char *data) :
00376          TBranchProxy(director,top,name,data) {};
00377       TClaProxy(TBranchProxyDirector *director, TBranchProxy *parent, const char *name, const char* top = 0, const char* mid = 0) :
00378          TBranchProxy(director,parent, name, top, mid) {};
00379       ~TClaProxy() {};
00380 
00381       const TClonesArray* GetPtr() {
00382          if (!Read()) return 0;
00383          return (TClonesArray*)GetStart();
00384       }
00385 
00386       Int_t GetEntries() {
00387          if (!ReadEntries()) return 0;
00388          TClonesArray *arr = (TClonesArray*)GetStart();
00389          if (arr) return arr->GetEntries();
00390          return 0;
00391       }
00392 
00393       const TClonesArray* operator->() { return GetPtr(); }
00394 
00395    };
00396 
00397    //_______________________________________________
00398    // Base class for the proxy around STL containers.
00399    class TStlProxy : public TBranchProxy {
00400    public:
00401       void Print() {
00402          TBranchProxy::Print();
00403          cout << "fWhere " << fWhere << endl;
00404          if (fWhere) {
00405             if (IsaPointer()) {
00406                cout << "location " << *(TClonesArray**)fWhere << endl;
00407             } else {
00408                cout << "location " << fWhere << endl;
00409             }
00410          }
00411       }
00412 
00413       TStlProxy() : TBranchProxy() {}
00414       TStlProxy(TBranchProxyDirector *director, const char *name) : TBranchProxy(director,name) {};
00415       TStlProxy(TBranchProxyDirector *director, const char *top, const char *name) :
00416          TBranchProxy(director,top,name) {};
00417       TStlProxy(TBranchProxyDirector *director, const char *top, const char *name, const char *data) :
00418          TBranchProxy(director,top,name,data) {};
00419       TStlProxy(TBranchProxyDirector *director, TBranchProxy *parent, const char *name, const char* top = 0, const char* mid = 0) :
00420          TBranchProxy(director,parent, name, top, mid) {};
00421       ~TStlProxy() {};
00422 
00423       const TVirtualCollectionProxy* GetPtr() {
00424          if (!Read()) return 0;
00425          return GetCollection();
00426       }
00427 
00428       Int_t GetEntries() {
00429          if (!ReadEntries()) return 0;
00430          return GetPtr()->Size();
00431       }
00432 
00433       const TVirtualCollectionProxy* operator->() { return GetPtr(); }
00434 
00435    };
00436 
00437    //______________________________________
00438    // Template of the proxy around objects.
00439    template <class T>
00440    class TImpProxy : public TBranchProxy {
00441    public:
00442       void Print() {
00443          TBranchProxy::Print();
00444          cout << "fWhere " << fWhere << endl;
00445          if (fWhere) cout << "value? " << *(T*)GetStart() << endl;
00446       }
00447 
00448       TImpProxy() : TBranchProxy() {};
00449       TImpProxy(TBranchProxyDirector *director, const char *name) : TBranchProxy(director,name) {};
00450       TImpProxy(TBranchProxyDirector *director, const char *top, const char *name) :
00451          TBranchProxy(director,top,name) {};
00452       TImpProxy(TBranchProxyDirector *director, const char *top, const char *name, const char *data) :
00453          TBranchProxy(director,top,name,data) {};
00454       TImpProxy(TBranchProxyDirector *director, TBranchProxy *parent, const char *name, const char* top = 0, const char* mid = 0) : 
00455          TBranchProxy(director,parent, name, top, mid) {};
00456       ~TImpProxy() {};
00457 
00458       operator T() {
00459          if (!Read()) return 0;
00460          return *(T*)GetStart();
00461       }
00462 
00463       // Make sure that the copy methods are really private
00464 #ifdef private
00465 #undef private
00466 #define private_was_replaced
00467 #endif
00468       // For now explicitly disable copying into the value (i.e. the proxy is read-only).
00469    private:
00470       TImpProxy(T);
00471       TImpProxy &operator=(T);
00472 #ifdef private_was_replaced
00473 #define private public
00474 #endif
00475 
00476    };
00477 
00478    //____________________________________________
00479    // Helper template to be able to determine and
00480    // use array dimentsions.
00481    template <class T, int d = 0> struct TArrayType {
00482       typedef T type_t;
00483       typedef T array_t[d];
00484    }; 
00485    //____________________________________________
00486    // Helper class for proxy around multi dimension array
00487    template <class T> struct TArrayType<T,0> {
00488       typedef T type_t;
00489       typedef T array_t;
00490    };
00491    //____________________________________________
00492    // Helper class for proxy around multi dimension array
00493    template <class T, int d> struct TMultiArrayType {
00494       typedef typename T::type_t type_t;
00495       typedef typename T::array_t array_t[d];
00496    };
00497 
00498    //____________________________________________
00499    // Template for concrete implementation of proxy around array of T
00500    template <class T>
00501    class TArrayProxy : public TBranchProxy {
00502    public:
00503       TArrayProxy() : TBranchProxy() {}
00504       TArrayProxy(TBranchProxyDirector *director, const char *name) : TBranchProxy(director,name) {};
00505       TArrayProxy(TBranchProxyDirector *director, const char *top, const char *name) :
00506          TBranchProxy(director,top,name) {};
00507       TArrayProxy(TBranchProxyDirector *director, const char *top, const char *name, const char *data) :
00508          TBranchProxy(director,top,name,data) {};
00509       TArrayProxy(TBranchProxyDirector *director, TBranchProxy *parent, const char *name, const char* top = 0, const char* mid = 0) :
00510          TBranchProxy(director,parent, name, top, mid) {};
00511       ~TArrayProxy() {};
00512 
00513       typedef typename T::array_t array_t;
00514       typedef typename T::type_t type_t;
00515 
00516       void Print() {
00517          TBranchProxy::Print();
00518          cout << "fWhere " << GetWhere() << endl;
00519          if (GetWhere()) cout << "value? " << *(type_t*)GetWhere() << endl;
00520       }
00521 
00522       const array_t &At(UInt_t i) {
00523          static array_t default_val;
00524          if (!Read()) return default_val;
00525          // should add out-of bound test
00526          array_t *arr = 0;
00527          arr = (array_t*)((type_t*)(GetStart()));
00528          if (arr) return arr[i];
00529          else return default_val;
00530       }
00531 
00532       const array_t &operator [](Int_t i) { return At(i); }
00533       const array_t &operator [](UInt_t i) { return At(i); }
00534    };
00535 
00536    //_____________________________________________________________________________________
00537    // Template of the Concrete Implementation of the branch proxy around TClonesArray of T
00538    template <class T>
00539    class TClaImpProxy : public TBranchProxy {
00540    public:
00541 
00542       void Print() {
00543          TBranchProxy::Print();
00544          cout << "fWhere " << fWhere << endl;
00545          if (fWhere) cout << "value? " << *(T*)GetStart() << endl;
00546       }
00547 
00548       TClaImpProxy() : TBranchProxy() {};
00549       TClaImpProxy(TBranchProxyDirector *director, const char *name) : TBranchProxy(director,name) {};
00550       TClaImpProxy(TBranchProxyDirector *director,  const char *top, const char *name) :
00551          TBranchProxy(director,top,name) {};
00552       TClaImpProxy(TBranchProxyDirector *director,  const char *top, const char *name, const char *data) :
00553          TBranchProxy(director,top,name,data) {};
00554       TClaImpProxy(TBranchProxyDirector *director, TBranchProxy *parent, const char *name, const char* top = 0, const char* mid = 0) : 
00555          TBranchProxy(director,parent, name, top, mid) {};
00556       ~TClaImpProxy() {};
00557 
00558       const T& At(UInt_t i) {
00559          static T default_val;
00560          if (!Read()) return default_val;
00561          if (fWhere==0) return default_val;
00562 
00563          T *temp = (T*)GetClaStart(i);
00564 
00565          if (temp) return *temp;
00566          else return default_val;
00567 
00568       }
00569 
00570       const T& operator [](Int_t i) { return At(i); }
00571       const T& operator [](UInt_t i) { return At(i); }
00572 
00573       // Make sure that the copy methods are really private
00574 #ifdef private
00575 #undef private
00576 #define private_was_replaced
00577 #endif
00578       // For now explicitly disable copying into the value (i.e. the proxy is read-only).
00579    private:
00580       TClaImpProxy(T);
00581       TClaImpProxy &operator=(T);
00582 #ifdef private_was_replaced
00583 #define private public
00584 #endif
00585 
00586    };
00587 
00588    //_________________________________________________________________________________________
00589    // Template of the Concrete Implementation of the branch proxy around an stl container of T
00590    template <class T>
00591    class TStlImpProxy : public TBranchProxy {
00592    public:
00593 
00594       void Print() {
00595          TBranchProxy::Print();
00596          cout << "fWhere " << fWhere << endl;
00597          if (fWhere) cout << "value? " << *(T*)GetStart() << endl;
00598       }
00599 
00600       TStlImpProxy() : TBranchProxy() {};
00601       TStlImpProxy(TBranchProxyDirector *director, const char *name) : TBranchProxy(director,name) {};
00602       TStlImpProxy(TBranchProxyDirector *director,  const char *top, const char *name) :
00603          TBranchProxy(director,top,name) {};
00604       TStlImpProxy(TBranchProxyDirector *director,  const char *top, const char *name, const char *data) :
00605          TBranchProxy(director,top,name,data) {};
00606       TStlImpProxy(TBranchProxyDirector *director, TBranchProxy *parent, const char *name, const char* top = 0, const char* mid = 0) : 
00607          TBranchProxy(director,parent, name, top, mid) {};
00608       ~TStlImpProxy() {};
00609 
00610       const T& At(UInt_t i) {
00611          static T default_val;
00612          if (!Read()) return default_val;
00613          if (fWhere==0) return default_val;
00614 
00615          T *temp = (T*)GetStlStart(i);
00616 
00617          if (temp) return *temp;
00618          else return default_val;
00619       }
00620 
00621       const T& operator [](Int_t i) { return At(i); }
00622       const T& operator [](UInt_t i) { return At(i); }
00623 
00624       // Make sure that the copy methods are really private
00625 #ifdef private
00626 #undef private
00627 #define private_was_replaced
00628 #endif
00629       // For now explicitly disable copying into the value (i.e. the proxy is read-only).
00630    private:
00631       TStlImpProxy(T);
00632       TStlImpProxy &operator=(T);
00633 #ifdef private_was_replaced
00634 #define private public
00635 #endif
00636 
00637    };
00638 
00639    //_________________________________________________________________________________________________
00640    // Template of the Concrete Implementation of the branch proxy around an TClonesArray of array of T
00641    template <class T>
00642    class TClaArrayProxy : public TBranchProxy {
00643    public:
00644       typedef typename T::array_t array_t;
00645       typedef typename T::type_t type_t;
00646 
00647       void Print() {
00648          TBranchProxy::Print();
00649          cout << "fWhere " << fWhere << endl;
00650          if (fWhere) cout << "value? " << *(type_t*)GetStart() << endl;
00651       }
00652 
00653       TClaArrayProxy() : TBranchProxy() {}
00654       TClaArrayProxy(TBranchProxyDirector *director, const char *name) : TBranchProxy(director,name) {};
00655       TClaArrayProxy(TBranchProxyDirector *director, const char *top, const char *name) :
00656          TBranchProxy(director,top,name) {};
00657       TClaArrayProxy(TBranchProxyDirector *director, const char *top, const char *name, const char *data) :
00658          TBranchProxy(director,top,name,data) {};
00659       TClaArrayProxy(TBranchProxyDirector *director, TBranchProxy *parent, const char *name, const char* top = 0, const char* mid = 0) :
00660          TBranchProxy(director,parent, name, top, mid) {};
00661       ~TClaArrayProxy() {};
00662 
00663       /* const */  array_t *At(UInt_t i) {
00664          static array_t default_val;
00665          if (!Read()) return &default_val;
00666          if (fWhere==0) return &default_val;
00667 
00668          return (array_t*)GetClaStart(i);
00669       }
00670 
00671       /* const */ array_t *operator [](Int_t i) { return At(i); }
00672       /* const */ array_t *operator [](UInt_t i) { return At(i); }
00673    };
00674 
00675    
00676    //__________________________________________________________________________________________________
00677    // Template of the Concrete Implementation of the branch proxy around an stl container of array of T
00678    template <class T>
00679    class TStlArrayProxy : public TBranchProxy {
00680    public:
00681       typedef typename T::array_t array_t;
00682       typedef typename T::type_t type_t;
00683 
00684       void Print() {
00685          TBranchProxy::Print();
00686          cout << "fWhere " << fWhere << endl;
00687          if (fWhere) cout << "value? " << *(type_t*)GetStart() << endl;
00688       }
00689 
00690       TStlArrayProxy() : TBranchProxy() {}
00691       TStlArrayProxy(TBranchProxyDirector *director, const char *name) : TBranchProxy(director,name) {};
00692       TStlArrayProxy(TBranchProxyDirector *director, const char *top, const char *name) :
00693          TBranchProxy(director,top,name) {};
00694       TStlArrayProxy(TBranchProxyDirector *director, const char *top, const char *name, const char *data) :
00695          TBranchProxy(director,top,name,data) {};
00696       TStlArrayProxy(TBranchProxyDirector *director, TBranchProxy *parent, const char *name, const char* top = 0, const char* mid = 0) :
00697          TBranchProxy(director,parent, name, top, mid) {};
00698       ~TStlArrayProxy() {};
00699 
00700       /* const */  array_t *At(UInt_t i) {
00701          static array_t default_val;
00702          if (!Read()) return &default_val;
00703          if (fWhere==0) return &default_val;
00704 
00705          return (array_t*)GetStlStart(i);
00706       }
00707 
00708       /* const */ array_t *operator [](Int_t i) { return At(i); }
00709       /* const */ array_t *operator [](UInt_t i) { return At(i); }
00710    };
00711 
00712    //TImpProxy<TObject> d;
00713    typedef TImpProxy<Double_t>   TDoubleProxy;   // Concrete Implementation of the branch proxy around the data members which are double
00714    typedef TImpProxy<Double32_t> TDouble32Proxy; // Concrete Implementation of the branch proxy around the data members which are double32
00715    typedef TImpProxy<Float_t>    TFloatProxy;    // Concrete Implementation of the branch proxy around the data members which are float
00716    typedef TImpProxy<Float16_t>  TFloat16Proxy;  // Concrete Implementation of the branch proxy around the data members which are float16
00717    typedef TImpProxy<UInt_t>     TUIntProxy;     // Concrete Implementation of the branch proxy around the data members which are unsigned int
00718    typedef TImpProxy<ULong_t>    TULongProxy;    // Concrete Implementation of the branch proxy around the data members which are unsigned long
00719    typedef TImpProxy<ULong64_t>  TULong64Proxy;  // Concrete Implementation of the branch proxy around the data members which are unsigned long long
00720    typedef TImpProxy<UShort_t>   TUShortProxy;   // Concrete Implementation of the branch proxy around the data members which are unsigned short
00721    typedef TImpProxy<UChar_t>    TUCharProxy;    // Concrete Implementation of the branch proxy around the data members which are unsigned char
00722    typedef TImpProxy<Int_t>      TIntProxy;      // Concrete Implementation of the branch proxy around the data members which are int
00723    typedef TImpProxy<Long_t>     TLongProxy;     // Concrete Implementation of the branch proxy around the data members which are long
00724    typedef TImpProxy<Long64_t>   TLong64Proxy;   // Concrete Implementation of the branch proxy around the data members which are long long
00725    typedef TImpProxy<Short_t>    TShortProxy;    // Concrete Implementation of the branch proxy around the data members which are short
00726    typedef TImpProxy<Char_t>     TCharProxy;     // Concrete Implementation of the branch proxy around the data members which are char
00727    typedef TImpProxy<Bool_t>     TBoolProxy;     // Concrete Implementation of the branch proxy around the data members which are bool
00728 
00729    typedef TArrayProxy<TArrayType<Double_t> >   TArrayDoubleProxy;   // Concrete Implementation of the branch proxy around the data members which are array of double
00730    typedef TArrayProxy<TArrayType<Double32_t> > TArrayDouble32Proxy; // Concrete Implementation of the branch proxy around the data members which are array of double32
00731    typedef TArrayProxy<TArrayType<Float_t> >    TArrayFloatProxy;    // Concrete Implementation of the branch proxy around the data members which are array of float
00732    typedef TArrayProxy<TArrayType<Float16_t> >  TArrayFloat16Proxy;  // Concrete Implementation of the branch proxy around the data members which are array of float16
00733    typedef TArrayProxy<TArrayType<UInt_t> >     TArrayUIntProxy;     // Concrete Implementation of the branch proxy around the data members which are array of unsigned int
00734    typedef TArrayProxy<TArrayType<ULong_t> >    TArrayULongProxy;    // Concrete Implementation of the branch proxy around the data members which are array of unsigned long
00735    typedef TArrayProxy<TArrayType<ULong64_t> >  TArrayULong64Proxy;  // Concrete Implementation of the branch proxy around the data members which are array of unsigned long long
00736    typedef TArrayProxy<TArrayType<UShort_t> >   TArrayUShortProxy;   // Concrete Implementation of the branch proxy around the data members which are array of unsigned short
00737    typedef TArrayProxy<TArrayType<UChar_t> >    TArrayUCharProxy;    // Concrete Implementation of the branch proxy around the data members which are array of unsigned char
00738    typedef TArrayProxy<TArrayType<Int_t> >      TArrayIntProxy;      // Concrete Implementation of the branch proxy around the data members which are array of int
00739    typedef TArrayProxy<TArrayType<Long_t> >     TArrayLongProxy;     // Concrete Implementation of the branch proxy around the data members which are array of long
00740    typedef TArrayProxy<TArrayType<Long64_t> >   TArrayLong64Proxy;   // Concrete Implementation of the branch proxy around the data members which are array of long long
00741    typedef TArrayProxy<TArrayType<UShort_t> >   TArrayShortProxy;    // Concrete Implementation of the branch proxy around the data members which are array of short
00742    //specialized ! typedef TArrayProxy<TArrayType<Char_t> >  TArrayCharProxy; // Concrete Implementation of the branch proxy around the data members which are array of char
00743    typedef TArrayProxy<TArrayType<Bool_t> >     TArrayBoolProxy;     // Concrete Implementation of the branch proxy around the data members which are array of bool
00744 
00745    typedef TClaImpProxy<Double_t>   TClaDoubleProxy;   // Concrete Implementation of the branch proxy around the data members of object in TClonesArray which are double
00746    typedef TClaImpProxy<Double32_t> TClaDouble32Proxy; // Concrete Implementation of the branch proxy around the data members of object in TClonesArray which are double32
00747    typedef TClaImpProxy<Float_t>    TClaFloatProxy;    // Concrete Implementation of the branch proxy around the data members of object in TClonesArray which are float
00748    typedef TClaImpProxy<Float16_t>  TClaFloat16Proxy;  // Concrete Implementation of the branch proxy around the data members of object in TClonesArray which are float16
00749    typedef TClaImpProxy<UInt_t>     TClaUIntProxy;     // Concrete Implementation of the branch proxy around the data members of object in TClonesArray which are unsigned int
00750    typedef TClaImpProxy<ULong_t>    TClaULongProxy;    // Concrete Implementation of the branch proxy around the data members of object in TClonesArray which are unsigned long
00751    typedef TClaImpProxy<ULong64_t>  TClaULong64Proxy;  // Concrete Implementation of the branch proxy around the data members of object in TClonesArray which are unsigned long long
00752    typedef TClaImpProxy<UShort_t>   TClaUShortProxy;   // Concrete Implementation of the branch proxy around the data members of object in TClonesArray which are unsigned short
00753    typedef TClaImpProxy<UChar_t>    TClaUCharProxy;    // Concrete Implementation of the branch proxy around the data members of object in TClonesArray which are unsigned char
00754    typedef TClaImpProxy<Int_t>      TClaIntProxy;      // Concrete Implementation of the branch proxy around the data members of object in TClonesArray which are int
00755    typedef TClaImpProxy<Long_t>     TClaLongProxy;     // Concrete Implementation of the branch proxy around the data members of object in TClonesArray which are long
00756    typedef TClaImpProxy<Long64_t>   TClaLong64Proxy;   // Concrete Implementation of the branch proxy around the data members of object in TClonesArray which are long long
00757    typedef TClaImpProxy<Short_t>    TClaShortProxy;    // Concrete Implementation of the branch proxy around the data members of object in TClonesArray which are short
00758    typedef TClaImpProxy<Char_t>     TClaCharProxy;     // Concrete Implementation of the branch proxy around the data members of object in TClonesArray which are char
00759    typedef TClaImpProxy<Bool_t>     TClaBoolProxy;     // Concrete Implementation of the branch proxy around the data members of object in TClonesArray which are bool
00760 
00761    typedef TClaArrayProxy<TArrayType<Double_t> >    TClaArrayDoubleProxy;   // Concrete Implementation of the branch proxy around the data members of object in TClonesArray which are array of double
00762    typedef TClaArrayProxy<TArrayType<Double32_t> >  TClaArrayDouble32Proxy; // Concrete Implementation of the branch proxy around the data members of object in TClonesArray which are array of double32
00763    typedef TClaArrayProxy<TArrayType<Float_t> >     TClaArrayFloatProxy;    // Concrete Implementation of the branch proxy around the data members of object in TClonesArray which are array of float
00764    typedef TClaArrayProxy<TArrayType<Float16_t> >   TClaArrayFloat16Proxy;  // Concrete Implementation of the branch proxy around the data members of object in TClonesArray which are array of float16
00765    typedef TClaArrayProxy<TArrayType<UInt_t> >      TClaArrayUIntProxy;     // Concrete Implementation of the branch proxy around the data members of object in TClonesArray which are array of unsigned int
00766    typedef TClaArrayProxy<TArrayType<ULong_t> >     TClaArrayULongProxy;    // Concrete Implementation of the branch proxy around the data members of object in TClonesArray which are array of unsigned long
00767    typedef TClaArrayProxy<TArrayType<ULong64_t> >   TClaArrayULong64Proxy;  // Concrete Implementation of the branch proxy around the data members of object in TClonesArray which are array of unsigned long long
00768    typedef TClaArrayProxy<TArrayType<UShort_t> >    TClaArrayUShortProxy;   // Concrete Implementation of the branch proxy around the data members of object in TClonesArray which are array of unsigned short
00769    typedef TClaArrayProxy<TArrayType<UChar_t> >     TClaArrayUCharProxy;    // Concrete Implementation of the branch proxy around the data members of object in TClonesArray which are array of nsigned char
00770    typedef TClaArrayProxy<TArrayType<Int_t> >       TClaArrayIntProxy;      // Concrete Implementation of the branch proxy around the data members of object in TClonesArray which are array of int
00771    typedef TClaArrayProxy<TArrayType<Long_t> >      TClaArrayLongProxy;     // Concrete Implementation of the branch proxy around the data members of object in TClonesArray which are array of long
00772    typedef TClaArrayProxy<TArrayType<Long64_t> >    TClaArrayLong64Proxy;   // Concrete Implementation of the branch proxy around the data members of object in TClonesArray which are array of long long
00773    typedef TClaArrayProxy<TArrayType<UShort_t> >    TClaArrayShortProxy;    // Concrete Implementation of the branch proxy around the data members of object in TClonesArray which are array of short
00774    typedef TClaArrayProxy<TArrayType<Char_t> >      TClaArrayCharProxy;     // Concrete Implementation of the branch proxy around the data members of object in TClonesArray which are array of char
00775    typedef TClaArrayProxy<TArrayType<Bool_t> >      TClaArrayBoolProxy;     // Concrete Implementation of the branch proxy around the data members of object in TClonesArray which are array of bool
00776    //specialized ! typedef TClaArrayProxy<TArrayType<Char_t> >  TClaArrayCharProxy;
00777 
00778    typedef TStlImpProxy<Double_t>   TStlDoubleProxy;   // Concrete Implementation of the branch proxy around an stl container of double
00779    typedef TStlImpProxy<Double32_t> TStlDouble32Proxy; // Concrete Implementation of the branch proxy around an stl container of double32
00780    typedef TStlImpProxy<Float_t>    TStlFloatProxy;    // Concrete Implementation of the branch proxy around an stl container of float
00781    typedef TStlImpProxy<Float16_t>  TStlFloat16Proxy;  // Concrete Implementation of the branch proxy around an stl container of float16_t
00782    typedef TStlImpProxy<UInt_t>     TStlUIntProxy;     // Concrete Implementation of the branch proxy around an stl container of unsigned int
00783    typedef TStlImpProxy<ULong_t>    TStlULongProxy;    // Concrete Implementation of the branch proxy around an stl container of unsigned long
00784    typedef TStlImpProxy<ULong64_t>  TStlULong64Proxy;  // Concrete Implementation of the branch proxy around an stl container of unsigned long long
00785    typedef TStlImpProxy<UShort_t>   TStlUShortProxy;   // Concrete Implementation of the branch proxy around an stl container of unsigned short
00786    typedef TStlImpProxy<UChar_t>    TStlUCharProxy;    // Concrete Implementation of the branch proxy around an stl container of unsigned char
00787    typedef TStlImpProxy<Int_t>      TStlIntProxy;      // Concrete Implementation of the branch proxy around an stl container of int
00788    typedef TStlImpProxy<Long_t>     TStlLongProxy;     // Concrete Implementation of the branch proxy around an stl container of long
00789    typedef TStlImpProxy<Long64_t>   TStlLong64Proxy;   // Concrete Implementation of the branch proxy around an stl container of long long
00790    typedef TStlImpProxy<Short_t>    TStlShortProxy;    // Concrete Implementation of the branch proxy around an stl container of short
00791    typedef TStlImpProxy<Char_t>     TStlCharProxy;     // Concrete Implementation of the branch proxy around an stl container of char
00792    typedef TStlImpProxy<Bool_t>     TStlBoolProxy;     // Concrete Implementation of the branch proxy around an stl container of bool
00793 
00794    typedef TStlArrayProxy<TArrayType<Double_t> >    TStlArrayDoubleProxy;   // Concrete Implementation of the branch proxy around an stl container of double
00795    typedef TStlArrayProxy<TArrayType<Double32_t> >  TStlArrayDouble32Proxy; // Concrete Implementation of the branch proxy around an stl container of double32
00796    typedef TStlArrayProxy<TArrayType<Float_t> >     TStlArrayFloatProxy;    // Concrete Implementation of the branch proxy around an stl container of float
00797    typedef TStlArrayProxy<TArrayType<Float16_t> >   TStlArrayFloat16Proxy;  // Concrete Implementation of the branch proxy around an stl container of float16_t
00798    typedef TStlArrayProxy<TArrayType<UInt_t> >      TStlArrayUIntProxy;     // Concrete Implementation of the branch proxy around an stl container of unsigned int
00799    typedef TStlArrayProxy<TArrayType<ULong_t> >     TStlArrayULongProxy;    // Concrete Implementation of the branch proxy around an stl container of usigned long
00800    typedef TStlArrayProxy<TArrayType<ULong64_t> >   TStlArrayULong64Proxy;  // Concrete Implementation of the branch proxy around an stl contained of unsigned long long
00801    typedef TStlArrayProxy<TArrayType<UShort_t> >    TStlArrayUShortProxy;   // Concrete Implementation of the branch proxy around an stl container of unisgned short
00802    typedef TStlArrayProxy<TArrayType<UChar_t> >     TStlArrayUCharProxy;    // Concrete Implementation of the branch proxy around an stl container of unsingned char
00803    typedef TStlArrayProxy<TArrayType<Int_t> >       TStlArrayIntProxy;      // Concrete Implementation of the branch proxy around an stl container of int
00804    typedef TStlArrayProxy<TArrayType<Long_t> >      TStlArrayLongProxy;     // Concrete Implementation of the branch proxy around an stl container of long
00805    typedef TStlArrayProxy<TArrayType<Long64_t> >    TStlArrayLong64Proxy;   // Concrete Implementation of the branch proxy around an stl container of long long
00806    typedef TStlArrayProxy<TArrayType<UShort_t> >    TStlArrayShortProxy;    // Concrete Implementation of the branch proxy around an stl container of UShort_t
00807    typedef TStlArrayProxy<TArrayType<Char_t> >      TStlArrayCharProxy;     // Concrete Implementation of the branch proxy around an stl container of char
00808    typedef TStlArrayProxy<TArrayType<Bool_t> >      TStlArrayBoolProxy;     // Concrete Implementation of the branch proxy around an stl container of bool
00809 
00810 } // namespace ROOT
00811 
00812 #endif
00813 

Generated on Tue Jul 5 14:26:35 2011 for ROOT_528-00b_version by  doxygen 1.5.1