ManualTree2Body.h

Go to the documentation of this file.
00001 #include "TEmulatedCollectionProxy.h"
00002 #include "TROOT.h"
00003 #include "TSelectorCint.h"
00004 #include "TClassEdit.h"
00005 
00006 TBranch *TTreeBranchImpRef(TTree *tree, const char* branchname, TClass* ptrClass, EDataType datatype, void* addobj, Int_t bufsize, Int_t splitlevel)
00007 {
00008    return tree->BranchImpRef(branchname,ptrClass,datatype,addobj,bufsize,splitlevel);
00009 }
00010 
00011 static int G__ManualTree2_126_0_132(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
00012 {
00013    // We need to emulate TTree::Process and properly capture the fact that we go an intepreted TSelector object.
00014 
00015    ClassInfo_t* ti = gInterpreter->ClassInfo_Factory( &libp->para[0] );
00016    TClass *ptrClass = TClass::GetClass( gInterpreter->ClassInfo_Name( ti ) );
00017    TSelector *sel = (TSelector*) G__int(libp->para[0]);
00018 
00019    //Interpreted selector: cannot be used as such
00020    //create a fake selector
00021    TSelectorCint *selectcint = 0;
00022    if (ptrClass && !ptrClass->IsLoaded()) {
00023       selectcint = new TSelectorCint();
00024       selectcint->Build(sel, ti, kFALSE);
00025       sel = selectcint;
00026    }
00027 
00028    switch (libp->paran) {
00029    case 4:
00030       G__letLonglong(result7, 110, (G__int64) ((TTree*) G__getstructoffset())->Process(sel, (Option_t*) G__int(libp->para[1])
00031 , (Long64_t) G__Longlong(libp->para[2]), (Long64_t) G__Longlong(libp->para[3])));
00032       break;
00033    case 3:
00034       G__letLonglong(result7, 110, (G__int64) ((TTree*) G__getstructoffset())->Process(sel, (Option_t*) G__int(libp->para[1])
00035 , (Long64_t) G__Longlong(libp->para[2])));
00036       break;
00037    case 2:
00038       G__letLonglong(result7, 110, (G__int64) ((TTree*) G__getstructoffset())->Process(sel, (Option_t*) G__int(libp->para[1])));
00039       break;
00040    case 1:
00041       G__letLonglong(result7, 110, (G__int64) ((TTree*) G__getstructoffset())->Process(sel));
00042       break;
00043    }
00044 
00045    delete selectcint;
00046    gInterpreter->ClassInfo_Delete( ti );
00047    return(1 || funcname || hash || result7 || libp) ;
00048 }
00049 
00050 static int G__ManualTree2_126_0_187(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
00051 {
00052   // We need to emulate
00053   // return BranchImp(name,classname,TBuffer::GetClass(typeid(T)),addobj,bufsize,splitlevel);
00054 
00055    // Here find the class name 
00056    ClassInfo_t* ti = gInterpreter->ClassInfo_Factory( &libp->para[2] );
00057    TClass *ptrClass = TClass::GetClass( gInterpreter->ClassInfo_Name( ti ) );
00058    const char* classname = (const char*)G__int(libp->para[1]);
00059    TClass *claim = TClass::GetClass(classname);
00060    void *ptr;
00061    void **addr;
00062    bool isptrptr;
00063    if (libp->para[2].type == 'U' && libp->para[2].obj.reftype.reftype == 0) {
00064       ptr = (void*)G__int(libp->para[2]);
00065       addr = &ptr;
00066       isptrptr = false;
00067    } else {
00068       addr = (void**)G__int(libp->para[2]);
00069       isptrptr = true;
00070    }
00071    
00072    const char *branchname = (const char*)G__int(libp->para[0]);
00073    Bool_t error = kFALSE;
00074 
00075    if (ptrClass && claim) {
00076       if (!(claim->InheritsFrom(ptrClass)||ptrClass->InheritsFrom(claim)) ) {
00077          // Note we currently do not warning in case of splicing or over-expectation).
00078          Error("TTree::Branch","The class requested (%s) for the branch \"%s\" is different from the type of the pointer passed (%s)",
00079                claim->GetName(),branchname,ptrClass->GetName());
00080          error = kTRUE;
00081       } else if (addr && *addr) {
00082          TClass *actualClass = ptrClass->GetActualClass(*addr);
00083          if (!actualClass) {
00084             Warning("TTree::Branch", "The actual TClass corresponding to the object provided for the definition of the branch \"%s\" is missing."
00085                     "\n\tThe object will be truncated down to its %s part",
00086                     branchname,classname);
00087          } else if (claim!=actualClass && !actualClass->InheritsFrom(claim)) {
00088             Error("TTree::Branch", "The actual class (%s) of the object provided for the definition of the branch \"%s\" does not inherit from %s",
00089                   actualClass->GetName(),branchname,claim->GetName());
00090             error = kTRUE;
00091          } else if (claim->GetCollectionProxy() && dynamic_cast<TEmulatedCollectionProxy*>(claim->GetCollectionProxy())) {
00092             Error("TTree::Branch", "The class requested (%s) for the branch \"%s\" refer to an stl collection and do not have a compiled CollectionProxy.  "
00093                   "Please generate the dictionary for this class (%s)", 
00094                   claim->GetName(), branchname, claim->GetName());
00095 
00096             error = kTRUE;
00097          }
00098       }
00099    }
00100    if (error) {
00101       G__letint(result7,85,0);   
00102    } else {
00103    
00104       //if (ptrClass) classname = ptrClass->GetName();
00105       TTree *t = (TTree*)(G__getstructoffset());
00106       if (isptrptr) {
00107          switch(libp->paran) {
00108             case 5:
00109                G__letint(result7,85,(long)t->Branch(branchname,
00110                                                     classname,
00111                                                     (void*)G__int(libp->para[2]),
00112                                                     (Int_t)G__int(libp->para[3]),
00113                                                     (Int_t)G__int(libp->para[4])));
00114                break;
00115             case 4:
00116                G__letint(result7,85,(long)t->Branch(branchname,
00117                                                     classname,
00118                                                     (void*)G__int(libp->para[2]),
00119                                                     (Int_t)G__int(libp->para[3])));
00120                break;
00121             case 3:
00122                G__letint(result7,85,(long)t->Branch(branchname,
00123                                                     classname,
00124                                                     (void*)G__int(libp->para[2])));
00125                break;
00126          }
00127       } else {
00128          switch(libp->paran) {
00129             case 5:
00130                G__letint(result7,85,(long)TTreeBranchImpRef(((TTree*) G__getstructoffset()),branchname,ptrClass,kNoType_t,
00131                                                             (void*)G__int(libp->para[2]),
00132                                                             (Int_t)G__int(libp->para[3]),
00133                                                             (Int_t)G__int(libp->para[4])));
00134                break;
00135             case 4:
00136                G__letint(result7,85,(long)TTreeBranchImpRef(((TTree*) G__getstructoffset()),branchname,ptrClass,kNoType_t,
00137                                                             (void*)G__int(libp->para[2]),
00138                                                             (Int_t)G__int(libp->para[3]),
00139                                                             (Int_t)99));
00140                break;
00141             case 3:
00142                G__letint(result7,85,(long)TTreeBranchImpRef(((TTree*) G__getstructoffset()),branchname,ptrClass,kNoType_t,
00143                                                             (void*)G__int(libp->para[2]),
00144                                                             (Int_t)32000,
00145                                                             (Int_t)99));
00146                break;
00147          }         
00148       }
00149    }
00150    gInterpreter->ClassInfo_Delete( ti );
00151    return(1 || funcname || hash || result7 || libp) ;
00152 }
00153 
00154 #include "TDataType.h"
00155 
00156 static int G__ManualTree2_126_0_188(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
00157 {
00158    // We need to emulate 
00159    // return BranchImp(name,TBuffer::GetClass(typeid(T)),addobj,bufsize,splitlevel);
00160 
00161    TypeInfo_t *ti = gInterpreter->TypeInfo_Factory( & libp->para[1] );
00162    TClass* ptrClass = 0;
00163    EDataType datatype = kOther_t;
00164    {
00165       string type(TClassEdit::ShortType( gInterpreter->TypeInfo_Name( ti ) , TClassEdit::kDropTrailStar));
00166       ptrClass = TClass::GetClass(type.c_str());
00167       TDataType* data = gROOT->GetType(type.c_str());
00168       if (data) {
00169          datatype = (EDataType) data->GetType();
00170       }
00171    }
00172 
00173    const char* branchname = (const char*) G__int(libp->para[0]);
00174 
00175    if (!gInterpreter->TypeInfo_RefType(ti)) {
00176       switch(libp->paran) {
00177          case 4:
00178             G__letint(result7,85,(long)TTreeBranchImpRef(((TTree*) G__getstructoffset()),branchname,ptrClass,datatype,
00179                                                          (void*)G__int(libp->para[1]),
00180                                                          (Int_t)G__int(libp->para[2]),
00181                                                          (Int_t)G__int(libp->para[3])));
00182             break;
00183          case 3:
00184             G__letint(result7,85,(long)TTreeBranchImpRef(((TTree*) G__getstructoffset()),branchname,ptrClass,datatype,
00185                                                          (void*)G__int(libp->para[1]),
00186                                                          (Int_t)G__int(libp->para[2]),
00187                                                          (Int_t)99));
00188             break;
00189          case 2:
00190             G__letint(result7,85,(long)TTreeBranchImpRef(((TTree*) G__getstructoffset()),branchname,ptrClass,datatype,
00191                                                          (void*)G__int(libp->para[1]),
00192                                                          (Int_t)32000,
00193                                                          (Int_t)99));
00194             break;
00195       }
00196    } else {
00197       TClass *actualClass = 0;
00198       void **addr = (void**)G__int(libp->para[1]);
00199       if (ptrClass && addr) actualClass = ptrClass->GetActualClass(*addr);
00200       if (ptrClass && ptrClass->GetCollectionProxy() && dynamic_cast<TEmulatedCollectionProxy*>(ptrClass->GetCollectionProxy())) {
00201          Error("TTree::Branch", "The class requested (%s) for the branch \"%s\" refer to an stl collection and do not have a compiled CollectionProxy.  "
00202                "Please generate the dictionary for this class (%s)",
00203                ptrClass->GetName(), branchname, ptrClass->GetName());   
00204          G__letint(result7,85,0);
00205       } else if (actualClass && actualClass->GetCollectionProxy() && dynamic_cast<TEmulatedCollectionProxy*>(actualClass->GetCollectionProxy())) {
00206          Error("TTree::Branch", "The class requested (%s) for the branch \"%s\" refer to an stl collection and do not have a compiled CollectionProxy.  "
00207                "Please generate the dictionary for this class (%s)",
00208                actualClass->GetName(), branchname, actualClass->GetName());   
00209          G__letint(result7,85,0);
00210       }
00211       if (!ptrClass) {
00212          Error("TTree::Branch","The pointer specified for %s not of a class known to ROOT", branchname);
00213          G__letint(result7,85,0);
00214       } else {
00215          const char* classname = ptrClass->GetName();
00216          if (actualClass==0) {
00217             Warning("TTree::Branch", "The actual TClass corresponding to the object provided for the definition of the branch \"%s\" is missing."
00218                     "\n\tThe object will be truncated down to its %s part",
00219                     branchname,classname);
00220          } else {
00221             classname = actualClass->GetName();
00222          }
00223          TTree *t = (TTree*)(G__getstructoffset());
00224          switch(libp->paran) {
00225          case 4:
00226             G__letint(result7,85,(long)t->Branch(branchname,
00227                                                  classname,
00228                                                  (void*)G__int(libp->para[1]),
00229                                                  (Int_t)G__int(libp->para[2]),
00230                                                  (Int_t)G__int(libp->para[3])));
00231             break;
00232          case 3:
00233             G__letint(result7,85,(long)t->Branch(branchname,
00234                                                  classname,
00235                                                  (void*)G__int(libp->para[1]),
00236                                                  (Int_t)G__int(libp->para[2])));
00237             break;
00238          case 2:
00239             G__letint(result7,85,(long)t->Branch(branchname,
00240                                                  classname,
00241                                                  (void*)G__int(libp->para[1])));
00242             break;
00243          }         
00244       }
00245    }
00246    gInterpreter->TypeInfo_Delete( ti );
00247    return(1 || funcname || hash || result7 || libp) ;
00248 }
00249 
00250 static int G__ManualTree2_126_0_190(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
00251 {
00252    // Emulate:
00253    // template <class T> void SetBranchAddress(const char *bname, T **add, TBranch **ptr);
00254 
00255    G__setnull(result7);
00256 
00257    TypeInfo_t *ti = gInterpreter->TypeInfo_Factory( & libp->para[1] );
00258    string type( TClassEdit::ShortType( gInterpreter->TypeInfo_Name( ti ) ,TClassEdit::kDropTrailStar) );
00259    TClass *ptrClass = TClass::GetClass(type.c_str());
00260    TDataType *data = gROOT->GetType(type.c_str());
00261    EDataType datatype = data ? (EDataType)data->GetType() : kOther_t;
00262    TBranch **branchPtr = 0;
00263 
00264    switch (libp->paran) {
00265    case 3:
00266       branchPtr = (TBranch**) G__int(libp->para[2]);
00267       break;
00268    case 2:
00269       break;
00270    }
00271    ((TTree*)(G__getstructoffset()))->SetBranchAddress((const char*)G__int(libp->para[0]),(void*)G__int(libp->para[1]),branchPtr,ptrClass,datatype,gInterpreter->TypeInfo_RefType(ti)==G__PARAP2P);
00272 
00273    gInterpreter->TypeInfo_Delete( ti );
00274    return(1 || funcname || hash || result7 || libp) ;
00275 }

Generated on Tue Jul 5 15:33:33 2011 for ROOT_528-00b_version by  doxygen 1.5.1