diff --git a/cint/src/init.c b/cint/src/init.c index e2d04599a336b4f151655e9d002c53f9f5b85f83..8aa0b91db3ceffba6d84dc34a4d31c0a904bb1e5 100644 --- a/cint/src/init.c +++ b/cint/src/init.c @@ -683,21 +683,6 @@ char *argv[] ; G__set_stdio(); -#ifndef G__OLDIMPLEMENTATION1817 -#ifdef G__ROOT - { - int xtagnum,xtypenum; - G__cpp_setuplongif(); - xtagnum=G__defined_tagname("G__longlong",2); - xtypenum=G__search_typename("long long",'u',xtagnum,G__PARANORMAL); - xtagnum=G__defined_tagname("G__ulonglong",2); - xtypenum=G__search_typename("unsigned long long",'u',xtagnum,G__PARANORMAL); - xtagnum=G__defined_tagname("G__longdouble",2); - xtypenum=G__search_typename("long double",'u',xtagnum,G__PARANORMAL); - } -#endif -#endif - /* Signal handling moved after getopt to enable core dump with 'E' */ #ifdef G__HSTD @@ -734,6 +719,21 @@ char *argv[] ; #ifndef G__OLDIMPLEMENTATION442 G__do_p2fsetup(); #endif +#ifndef G__OLDIMPLEMENTATION1817 +#ifdef G__ROOT + { + int xtagnum,xtypenum; + G__cpp_setuplongif(); + xtagnum=G__defined_tagname("G__longlong",2); + xtypenum=G__search_typename("long long",'u',xtagnum,G__PARANORMAL); + xtagnum=G__defined_tagname("G__ulonglong",2); + xtypenum=G__search_typename("unsigned long long",'u',xtagnum,G__PARANORMAL); + xtagnum=G__defined_tagname("G__longdouble",2); + xtypenum=G__search_typename("long double",'u',xtagnum,G__PARANORMAL); + } +#endif +#endif + G__prerun=0; G__setdebugcond(); diff --git a/cint/src/v6_init.cxx b/cint/src/v6_init.cxx index e2d04599a336b4f151655e9d002c53f9f5b85f83..8aa0b91db3ceffba6d84dc34a4d31c0a904bb1e5 100644 --- a/cint/src/v6_init.cxx +++ b/cint/src/v6_init.cxx @@ -683,21 +683,6 @@ char *argv[] ; G__set_stdio(); -#ifndef G__OLDIMPLEMENTATION1817 -#ifdef G__ROOT - { - int xtagnum,xtypenum; - G__cpp_setuplongif(); - xtagnum=G__defined_tagname("G__longlong",2); - xtypenum=G__search_typename("long long",'u',xtagnum,G__PARANORMAL); - xtagnum=G__defined_tagname("G__ulonglong",2); - xtypenum=G__search_typename("unsigned long long",'u',xtagnum,G__PARANORMAL); - xtagnum=G__defined_tagname("G__longdouble",2); - xtypenum=G__search_typename("long double",'u',xtagnum,G__PARANORMAL); - } -#endif -#endif - /* Signal handling moved after getopt to enable core dump with 'E' */ #ifdef G__HSTD @@ -734,6 +719,21 @@ char *argv[] ; #ifndef G__OLDIMPLEMENTATION442 G__do_p2fsetup(); #endif +#ifndef G__OLDIMPLEMENTATION1817 +#ifdef G__ROOT + { + int xtagnum,xtypenum; + G__cpp_setuplongif(); + xtagnum=G__defined_tagname("G__longlong",2); + xtypenum=G__search_typename("long long",'u',xtagnum,G__PARANORMAL); + xtagnum=G__defined_tagname("G__ulonglong",2); + xtypenum=G__search_typename("unsigned long long",'u',xtagnum,G__PARANORMAL); + xtagnum=G__defined_tagname("G__longdouble",2); + xtypenum=G__search_typename("long double",'u',xtagnum,G__PARANORMAL); + } +#endif +#endif + G__prerun=0; G__setdebugcond(); diff --git a/io/src/TStreamerInfo.cxx b/io/src/TStreamerInfo.cxx index 9755e00a4930a9d80da2de7234fdf69f714b8172..fc607aa9c80c19b9180b9619c9882be12696d48e 100644 --- a/io/src/TStreamerInfo.cxx +++ b/io/src/TStreamerInfo.cxx @@ -1,4 +1,4 @@ -// @(#)root/meta:$Name: $:$Id: TStreamerInfo.cxx,v 1.215 2004/12/10 09:28:47 brun Exp $ +// @(#)root/meta:$Name: $:$Id: TStreamerInfo.cxx,v 1.216 2005/01/04 19:54:31 brun Exp $ // Author: Rene Brun 12/10/2000 /************************************************************************* @@ -133,6 +133,13 @@ void TStreamerInfo::Build() // This is used to avoid unwanted recursive call to Build fIsBuilt = kTRUE; + if (fClass->GetCollectionProxy()) { + TStreamerElement *element = new TStreamerSTL("This","Used to call the proper TStreamerInfo case",0,fClass->GetName(),fClass->GetName(),0); + fElements->Add(element); + Compile(); + return; + } + TStreamerElement::Class()->IgnoreTObjectStreamer(); //if (!strcmp(fClass->GetName(),"TVector3")) fClass->IgnoreTObjectStreamer(); @@ -667,6 +674,10 @@ void TStreamerInfo::BuildOld() fClass->GetStreamerInfo(); } + if (fClass->GetCollectionProxy() && + fElements->GetEntries()==1 && + strcmp(fElements->At(0)->GetName(),"This")==0) { + } TIter next(fElements); TStreamerElement *element; Int_t offset = 0; @@ -676,6 +687,11 @@ void TStreamerInfo::BuildOld() sp = 8; #endif int nBaze=0; + if (fClass->GetCollectionProxy() && + fElements->GetEntries()==1 && + strcmp(fElements->At(0)->GetName(),"This")==0) { + next(); + } while ((element = (TStreamerElement*)next())) { element->SetNewType(element->GetType()); element->Init(); diff --git a/meta/inc/TDataType.h b/meta/inc/TDataType.h index 3875d885aef63e0c813aa32eb0fc1cabc920989b..28ad41a2491573daa0b2cc2df1b5d23443e03e31 100644 --- a/meta/inc/TDataType.h +++ b/meta/inc/TDataType.h @@ -1,4 +1,4 @@ -// @(#)root/meta:$Name: $:$Id: TDataType.h,v 1.8 2004/07/30 01:16:17 rdm Exp $ +// @(#)root/meta:$Name: $:$Id: TDataType.h,v 1.9 2004/07/30 19:09:51 brun Exp $ // Author: Rene Brun 04/02/95 /************************************************************************* @@ -64,6 +64,7 @@ public: const char *AsString(void *buf) const; Long_t Property() const; + static const char *GetTypeName(EDataType type); static EDataType GetType(const type_info &typeinfo); ClassDef(TDataType,0) //Basic data type descriptor diff --git a/meta/src/TClass.cxx b/meta/src/TClass.cxx index 7bad3b65c2c4ade665426c05de8c27eeddf52a8f..5b67d0eb8da9cd48ab33b1dc2535d69fa439671a 100644 --- a/meta/src/TClass.cxx +++ b/meta/src/TClass.cxx @@ -1,4 +1,4 @@ -// @(#)root/meta:$Name: $:$Id: TClass.cxx,v 1.154 2004/10/29 18:03:10 brun Exp $ +// @(#)root/meta:$Name: $:$Id: TClass.cxx,v 1.155 2005/01/04 19:54:31 brun Exp $ // Author: Rene Brun 07/01/95 /************************************************************************* @@ -2000,7 +2000,7 @@ TStreamerInfo *TClass::GetStreamerInfo(Int_t version) sinfo = new TStreamerInfo(this,""); fStreamerInfo->AddAtAndExpand(sinfo,fClassVersion); if (gDebug > 0) printf("Creating StreamerInfo for class: %s, version: %d\n",GetName(),fClassVersion); - if (fClassInfo) { + if (fClassInfo || fCollectionProxy) { // if we do not have a StreamerInfo for this version and we do not // have a ClassInfo, there is nothing to built! sinfo->Build(); diff --git a/meta/src/TDataType.cxx b/meta/src/TDataType.cxx index 5ca9d0f5442f5ee0efe4b537c64d5f30d2443c0b..3cbb04851e62142d9f4835002509ff73fb8ab824 100644 --- a/meta/src/TDataType.cxx +++ b/meta/src/TDataType.cxx @@ -1,4 +1,4 @@ -// @(#)root/meta:$Name: $:$Id: TDataType.cxx,v 1.14 2004/07/30 01:16:17 rdm Exp $ +// @(#)root/meta:$Name: $:$Id: TDataType.cxx,v 1.15 2004/11/11 20:42:26 rdm Exp $ // Author: Rene Brun 04/02/95 /************************************************************************* @@ -66,6 +66,30 @@ TDataType::~TDataType() delete fInfo; } +//______________________________________________________________________________ +const char *TDataType::GetTypeName(EDataType type) +{ + switch (type) { + case 1: return "Char_t"; + case 2: return "Short_t"; + case 3: return "Int_t"; + case 4: return "Long_t"; + case 5: return "Float_t"; + case 6: return "Int_t"; + case 7: return "char*"; + case 8: return "Double_t"; + case 9: return "Double32_t"; + case 11: return "UChar_t"; + case 12: return "UShort_t"; + case 13: return "UInt_t"; + case 14: return "ULong_t"; + case 15: return "UInt_t"; + case 16: return "Long64_t"; + case 17: return "ULong64_t"; + } + return ""; +} + //______________________________________________________________________________ const char *TDataType::GetTypeName() const { diff --git a/meta/src/TStreamerElement.cxx b/meta/src/TStreamerElement.cxx index bfed815b707ca6f6f1323f5c3a4cba5e3b74a29a..50b1f5be341fda0b442c650cf03d20729a0c036c 100644 --- a/meta/src/TStreamerElement.cxx +++ b/meta/src/TStreamerElement.cxx @@ -1,4 +1,4 @@ -// @(#)root/meta:$Name: $:$Id: TStreamerElement.cxx,v 1.70 2004/11/17 08:46:43 brun Exp $ +// @(#)root/meta:$Name: $:$Id: TStreamerElement.cxx,v 1.71 2004/11/17 17:56:53 brun Exp $ // Author: Rene Brun 12/10/2000 /************************************************************************* @@ -209,22 +209,7 @@ const char *TStreamerElement::GetTypeNameBasic() const if (fType < 1 || fType > 55) return fTypeName.Data(); if (dt && dt->GetType() > 0) return fTypeName.Data(); Int_t dtype = fType%20; - switch (dtype) { - case 1: return "Char_t"; - case 2: return "Short_t"; - case 3: return "Int_t"; - case 4: return "Long_t"; - case 5: return "Float_t"; - case 6: return "Int_t"; - case 7: return "char*"; - case 8: return "Double_t"; - case 11: return "UChar_t"; - case 12: return "UShort_t"; - case 13: return "UInt_t"; - case 14: return "ULong_t"; - case 15: return "UInt_t"; - } - return ""; + return TDataType::GetTypeName((EDataType)dtype); } //______________________________________________________________________________ diff --git a/meta/src/TStreamerInfo.cxx b/meta/src/TStreamerInfo.cxx index 9755e00a4930a9d80da2de7234fdf69f714b8172..fc607aa9c80c19b9180b9619c9882be12696d48e 100644 --- a/meta/src/TStreamerInfo.cxx +++ b/meta/src/TStreamerInfo.cxx @@ -1,4 +1,4 @@ -// @(#)root/meta:$Name: $:$Id: TStreamerInfo.cxx,v 1.215 2004/12/10 09:28:47 brun Exp $ +// @(#)root/meta:$Name: $:$Id: TStreamerInfo.cxx,v 1.216 2005/01/04 19:54:31 brun Exp $ // Author: Rene Brun 12/10/2000 /************************************************************************* @@ -133,6 +133,13 @@ void TStreamerInfo::Build() // This is used to avoid unwanted recursive call to Build fIsBuilt = kTRUE; + if (fClass->GetCollectionProxy()) { + TStreamerElement *element = new TStreamerSTL("This","Used to call the proper TStreamerInfo case",0,fClass->GetName(),fClass->GetName(),0); + fElements->Add(element); + Compile(); + return; + } + TStreamerElement::Class()->IgnoreTObjectStreamer(); //if (!strcmp(fClass->GetName(),"TVector3")) fClass->IgnoreTObjectStreamer(); @@ -667,6 +674,10 @@ void TStreamerInfo::BuildOld() fClass->GetStreamerInfo(); } + if (fClass->GetCollectionProxy() && + fElements->GetEntries()==1 && + strcmp(fElements->At(0)->GetName(),"This")==0) { + } TIter next(fElements); TStreamerElement *element; Int_t offset = 0; @@ -676,6 +687,11 @@ void TStreamerInfo::BuildOld() sp = 8; #endif int nBaze=0; + if (fClass->GetCollectionProxy() && + fElements->GetEntries()==1 && + strcmp(fElements->At(0)->GetName(),"This")==0) { + next(); + } while ((element = (TStreamerElement*)next())) { element->SetNewType(element->GetType()); element->Init(); diff --git a/test/MainEvent.cxx b/test/MainEvent.cxx index 4e2584157987e1656345ab7f02d60d5cb5e0ef6b..164e1be723f59f8d21434780aef486aad7d413af 100644 --- a/test/MainEvent.cxx +++ b/test/MainEvent.cxx @@ -1,4 +1,4 @@ -// @(#)root/test:$Name: $:$Id: MainEvent.cxx,v 1.26 2003/12/30 18:16:43 brun Exp $ +// @(#)root/test:$Name: $:$Id: MainEvent.cxx,v 1.27 2003/12/30 18:31:13 brun Exp $ // Author: Rene Brun 19/01/97 //////////////////////////////////////////////////////////////////////// @@ -16,7 +16,7 @@ // Event 400 1 1 1 // // In this example, the tree consists of one single "super branch" -// The statement ***tree->Branch("event", event, 64000,split);*** below +// The statement ***tree->Branch("event", &event, 64000,split);*** below // will parse the structure described in Event.h and will make // a new branch for each data member of the class if split is set to 1. // - 9 branches corresponding to the basic types fType, fNtrack,fNseg, @@ -207,7 +207,7 @@ int main(int argc, char **argv) if (split) bufsize /= 4; event = new Event(); TTree::SetBranchStyle(branchStyle); - TBranch *branch = tree->Branch("event", "Event", &event, bufsize,split); + TBranch *branch = tree->Branch("event", &event, bufsize,split); branch->SetAutoDelete(kFALSE); Float_t ptmin = 1; diff --git a/test/stress.cxx b/test/stress.cxx index 1f754a07d4b2bd1bd9059cc1f0f23104b7e61313..a247924a0e9166242230e620a7aaba7e085c49e4 100644 --- a/test/stress.cxx +++ b/test/stress.cxx @@ -1,4 +1,4 @@ -// @(#)root/test:$Name: $:$Id: stress.cxx,v 1.54 2004/02/09 21:00:57 rdm Exp $ +// @(#)root/test:$Name: $:$Id: stress.cxx,v 1.55 2004/12/17 12:19:02 brun Exp $ // Author: Rene Brun 05/11/98 ///////////////////////////////////////////////////////////////// @@ -752,7 +752,7 @@ Int_t stress8write(Int_t nevent, Int_t comp, Int_t split) tree->SetAutoSave(100000000); // autosave when 100 Mbytes written Int_t bufsize = 64000; if (split) bufsize /= 4; - tree->Branch("event", "Event", &event, bufsize,split); + tree->Branch("event", &event, bufsize,split); //Fill the Tree Int_t ev, nb=0, meanTracks=600; diff --git a/tree/Module.mk b/tree/Module.mk index f070ca626ab36b01da2680e3f7df44a2acfecfe7..ece76aaabe0505bd1277226a3e892bb2149dfedf 100644 --- a/tree/Module.mk +++ b/tree/Module.mk @@ -17,6 +17,13 @@ TREEDS := $(MODDIRS)/G__Tree.cxx TREEDO := $(TREEDS:.cxx=.o) TREEDH := $(TREEDS:.cxx=.h) +# ManualBase4 only needs to be regenerated (and then changed manually) when +# the dictionary interface changes +TREEL2 := $(MODDIRI)/LinkDef2.h +TREEDS2 := $(MODDIRS)/ManualTree2.cxx +TREEDO2 := $(TREEDS2:.cxx=.o) +TREEDH2 := TTree.h + TREEH := $(filter-out $(MODDIRI)/LinkDef%,$(wildcard $(MODDIRI)/*.h)) TREES := $(filter-out $(MODDIRS)/G__%,$(wildcard $(MODDIRS)/*.cxx)) TREEO := $(TREES:.cxx=.o) @@ -45,6 +52,12 @@ $(TREEDS): $(TREEH) $(TREEL) $(ROOTCINTTMP) @echo "Generating dictionary $@..." $(ROOTCINTTMP) -f $@ -c $(TREEH) $(TREEL) +# pre-requisites intentionally not specified... should be called only +# on demand after deleting the file +$(TREEDS2): + @echo "Generating dictionary $@..." + $(ROOTCINTTMP) -f $@ -c $(TREEDH2) $(TREEL2) + $(TREEDO): $(TREEDS) $(CXX) $(NOOPT) $(CXXFLAGS) -I. -o $@ -c $< diff --git a/tree/inc/LinkDef2.h b/tree/inc/LinkDef2.h new file mode 100644 index 0000000000000000000000000000000000000000..c3f5dc68daeadd228183beed4e9a55da8b01c50b --- /dev/null +++ b/tree/inc/LinkDef2.h @@ -0,0 +1,35 @@ +/* @(#)root/base:$Name: $:$Id: LinkDef2.h,v 1.2 2004/07/01 04:55:05 brun Exp $ */ + +/************************************************************************* + * Copyright (C) 1995-2004, Rene Brun, Fons Rademakers and al. * + * All rights reserved. * + * * + * For the licensing terms see $ROOTSYS/LICENSE. * + * For the list of contributors see $ROOTSYS/README/CREDITS. * + *************************************************************************/ + +#ifdef __CINT__ + +// This linkdef is used to generate the skeleton for the customized +// dictionary to emulated access to the templated methods TTree::Branch +// and TTree::SetBranchAddress + +// The procedure is as follow (this should be needed only if and when the +// dictionary format changes). + +// rm tree/src/ManualTree2.cxx +// gmake tree/src/ManualTree2.cxx +// replace the implementation of the 2 wrappers by +// #include "ManualTree2Body.cxx" +// you might have to update the syntax in ManualTree2Body.cxx +// +// You also we need to remove +// #include "base/inc/TROOT.h" +// #include "base/inc/TDataMember.h" +// and replace the string "SetBranchAddress<void>" by "SetBranchAddress" + +#pragma link C++ function TTree::Branch(const char *, const char *, void **, Int_t, Int_t); +#pragma link C++ function TTree::Branch(const char *, void **, Int_t, Int_t); +#pragma link C++ function TTree::SetBranchAddress(const char*, void**); + +#endif diff --git a/tree/inc/TBranchElement.h b/tree/inc/TBranchElement.h index 3514d6d29aa327124455dde31bfdba6acee6f0ec..1a0adc884459b654ba49d55d898b476c8254d710 100644 --- a/tree/inc/TBranchElement.h +++ b/tree/inc/TBranchElement.h @@ -1,4 +1,4 @@ -// @(#)root/tree:$Name: $:$Id: TBranchElement.h,v 1.35 2004/10/17 11:55:47 brun Exp $ +// @(#)root/tree:$Name: $:$Id: TBranchElement.h,v 1.36 2004/11/02 21:51:10 brun Exp $ // Author: Rene Brun 14/01/2001 /************************************************************************* @@ -77,7 +77,7 @@ public: TBranchElement *GetBranchCount2() const {return fBranchCount2;} TList *GetBrowsableMethods(); UInt_t GetCheckSum() {return fCheckSum;} - virtual const char *GetClassName() const {return fClassName.Data();} + virtual const char *GetClassName() const {return fClassName.Data();} virtual const char *GetClonesName() const {return fClonesName.Data();} Int_t GetEntry(Long64_t entry=0, Int_t getall = 0); const char *GetIconName() const; diff --git a/tree/inc/TChain.h b/tree/inc/TChain.h index 7fce5c64106237da86c9e582b7f45efd2907811d..5a75329176f4964f3dcec7e39ae2c0006c93decd 100644 --- a/tree/inc/TChain.h +++ b/tree/inc/TChain.h @@ -1,4 +1,4 @@ -// @(#)root/tree:$Name: $:$Id: TChain.h,v 1.39 2004/10/31 09:28:06 brun Exp $ +// @(#)root/tree:$Name: $:$Id: TChain.h,v 1.40 2004/12/11 08:26:45 brun Exp $ // Author: Rene Brun 03/02/97 /************************************************************************* @@ -108,6 +108,7 @@ public: virtual void Reset(Option_t *option=""); virtual void SetAutoDelete(Bool_t autodel=kTRUE); virtual void SetBranchAddress(const char *bname,void *add); + virtual void SetBranchAddress(const char *bname,void *add, TClass *realClass, EDataType datatype, Bool_t ptr); virtual void SetBranchStatus(const char *bname,Bool_t status=1, UInt_t *found=0); virtual void SetDirectory(TDirectory *dir); virtual void SetMakeClass(Int_t make) { TTree::SetMakeClass(make); if (fTree) fTree->SetMakeClass(make);} diff --git a/tree/inc/TChainElement.h b/tree/inc/TChainElement.h index ae40ddb687ffc9d58ada21bea62cd76768fbb563..a0135240843ecd28aca356b8656c8665c1a65ff4 100644 --- a/tree/inc/TChainElement.h +++ b/tree/inc/TChainElement.h @@ -1,4 +1,4 @@ -// @(#)root/tree:$Name: $:$Id: TChainElement.h,v 1.4 2000/12/26 14:23:05 brun Exp $ +// @(#)root/tree:$Name: $:$Id: TChainElement.h,v 1.5 2001/01/23 21:09:08 brun Exp $ // Author: Rene Brun 11/02/97 /************************************************************************* @@ -28,12 +28,15 @@ class TChainElement : public TNamed { protected: - Int_t fEntries; //Number of entries in the tree of this chain element - Int_t fNPackets; //Number of packets - Int_t fPacketSize; //Number of events in one packet for parallel root - Int_t fStatus; //branch status when used as a branch - void *fBaddress; //!branch address when used as a branch - char *fPackets; //!Packet descriptor string + Int_t fEntries; //Number of entries in the tree of this chain element + Int_t fNPackets; //Number of packets + Int_t fPacketSize; //Number of events in one packet for parallel root + Int_t fStatus; //branch status when used as a branch + void *fBaddress; //!branch address when used as a branch + TString fBaddressClassName;//!Name of the class pointed to by fBaddress + UInt_t fBaddressType; //!Type of the value pointed to by fBaddress + Bool_t fBaddressIsPtr; //!True if the address is a pointer to an address + char *fPackets; //!Packet descriptor string public: TChainElement(); @@ -41,12 +44,18 @@ public: virtual ~TChainElement(); virtual void CreatePackets(); virtual void *GetBaddress() const {return fBaddress;} + virtual const char*GetBaddressClassName() const { return fBaddressClassName; } + virtual Bool_t GetBaddressIsPtr() const { return fBaddressIsPtr; } + virtual UInt_t GetBaddressType() const { return fBaddressType; } virtual Int_t GetEntries() const {return fEntries;} virtual char *GetPackets() const {return fPackets;} virtual Int_t GetPacketSize() const {return fPacketSize;} virtual Int_t GetStatus() const {return fStatus;} virtual void ls(Option_t *option="") const; virtual void SetBaddress(void *add) {fBaddress = add;} + virtual void SetBaddressClassName(const char* clname) { fBaddressClassName = clname; } + virtual void SetBaddressIsPtr(Bool_t isptr) { fBaddressIsPtr = isptr; } + virtual void SetBaddressType(UInt_t type) { fBaddressType = type; } virtual void SetNumberEntries(Int_t n) {fEntries=n;} virtual void SetPacketSize(Int_t size = 100); virtual void SetStatus(Int_t status) {fStatus = status;} diff --git a/tree/inc/TTree.h b/tree/inc/TTree.h index f67cd4514fcc9629d872b347577af7967e946102..8a61ddcd9140d956a11ec1055d9db62fe4594611 100644 --- a/tree/inc/TTree.h +++ b/tree/inc/TTree.h @@ -1,4 +1,4 @@ -// @(#)root/tree:$Name: $:$Id: TTree.h,v 1.72 2004/10/18 12:32:12 brun Exp $ +// @(#)root/tree:$Name: $:$Id: TTree.h,v 1.73 2004/11/24 14:11:38 brun Exp $ // Author: Rene Brun 12/01/96 /************************************************************************* @@ -67,6 +67,10 @@ #include "TVirtualTreePlayer.h" #endif +#ifndef ROOT_TDataType +#include "TDataType.h" +#endif + class TBrowser; class TFile; class TDirectory; @@ -132,6 +136,9 @@ protected: virtual void KeepCircular(); virtual void MakeIndex(TString &varexp, Int_t *index); virtual TFile *ChangeFile(TFile *file); + virtual TBranch *BranchImp(const char *name, const char *classname, TClass *realClass, void *addobj, Int_t bufsize, Int_t splitlevel); + virtual TBranch *BranchImp(const char *name, TClass *realClass, void *addobj, Int_t bufsize, Int_t splitlevel); + virtual Bool_t CheckBranchAddressType(TBranch *branch, TClass *realClass, EDataType datatype, Bool_t ptr); public: // TTree status bits @@ -153,8 +160,20 @@ public: virtual Int_t Branch(TList *list, Int_t bufsize=32000, Int_t splitlevel=99); virtual Int_t Branch(const char *folder, Int_t bufsize=32000, Int_t splitlevel=99); virtual TBranch *Branch(const char *name, void *address, const char *leaflist, Int_t bufsize=32000); - virtual TBranch *Branch(const char *name, void *clonesaddress, Int_t bufsize=32000, Int_t splitlevel=1); + virtual TBranch *Branch(const char *name, TClonesArray **clonesaddress, Int_t bufsize=32000, Int_t splitlevel=1); +#if !defined(__CINT__) virtual TBranch *Branch(const char *name, const char *classname, void *addobj, Int_t bufsize=32000, Int_t splitlevel=99); +#endif + template <class T> TBranch *Branch(const char *name, const char *classname, T **addobj, Int_t bufsize=32000, Int_t splitlevel=99) + { + // See BranchImp for details + return BranchImp(name,classname,TBuffer::GetClass(typeid(T)),addobj,bufsize,splitlevel); + } + template <class T> TBranch *Branch(const char *name, T **addobj, Int_t bufsize=32000, Int_t splitlevel=99) + { + // See BranchImp for details + return BranchImp(name,TBuffer::GetClass(typeid(T)),addobj,bufsize,splitlevel); + } virtual TBranch *Bronch(const char *name, const char *classname, void *addobj, Int_t bufsize=32000, Int_t splitlevel=99); virtual TBranch *BranchOld(const char *name, const char *classname, void *addobj, Int_t bufsize=32000, Int_t splitlevel=1); virtual TBranch *BranchRef(); @@ -285,7 +304,20 @@ public: virtual Bool_t SetAlias(const char *aliasName, const char *aliasFormula); virtual void SetAutoSave(Long64_t autos=10000000) {fAutoSave=autos;} virtual void SetBasketSize(const char *bname,Int_t buffsize=16000); +#if !defined(__CINT__) virtual void SetBranchAddress(const char *bname,void *add); +#endif + virtual void SetBranchAddress(const char *bname,void *add, TClass *realClass, EDataType datatype, Bool_t ptr); + template <class T> void SetBranchAddress(const char *bname, T **add) { + SetBranchAddress(bname,add,gROOT->GetClass(typeid(T)),TDataType::GetType(typeid(T)),true); + } +#ifndef R__NO_CLASS_TEMPLATE_SPECIALIZATION + // This can only be used when the template overload resolution can distringuish between + // T* and T** + template <class T> void SetBranchAddress(const char *bname, T *add) { + SetBranchAddress(bname,add,gROOT->GetClass(typeid(T)),TDataType::GetType(typeid(T)),false); + } +#endif virtual void SetBranchStatus(const char *bname,Bool_t status=1,UInt_t *found=0); static void SetBranchStyle(Int_t style=1); //style=0 for old branch, =1 for new branch style virtual void SetChainOffset(Int_t offset=0) {fChainOffset=offset;} diff --git a/tree/src/ManualTree2.cxx b/tree/src/ManualTree2.cxx new file mode 100644 index 0000000000000000000000000000000000000000..99a71a997590e1d24cbc56c163673e450081717a --- /dev/null +++ b/tree/src/ManualTree2.cxx @@ -0,0 +1,326 @@ +// +// File generated by c:\Devel\root_working\code\root.vc7\utils\src\rootcint_tmp.exe at Tue Jan 11 11:30:51 2005. +// Do NOT change. Changes will be lost next time file is generated +// + +#include "RConfig.h" +#if !defined(R__ACCESS_IN_SYMBOL) +//Break the privacy of classes -- Disabled for the moment +#define private public +#define protected public +#endif + +// Since CINT ignores the std namespace, we need to do so in this file. +namespace std {} using namespace std; + +#include "ManualTree2.h" +#include "TClass.h" +#include "TBuffer.h" +#include "TStreamerInfo.h" +#include "TMemberInspector.h" +#include "TError.h" + +#ifndef G__ROOT +#define G__ROOT +#endif + +#include "RtypesImp.h" + +#include "TCollectionProxy.h" + +namespace ROOT { + namespace Shadow { + } // Of namespace ROOT::Shadow +} // Of namespace ROOT + +/******************************************************** +* tree/src/ManualTree2.cxx +* CAUTION: DON'T CHANGE THIS FILE. THIS FILE IS AUTOMATICALLY GENERATED +* FROM HEADER FILES LISTED IN G__setup_cpp_environmentXXX(). +* CHANGE THOSE HEADER FILES AND REGENERATE THIS FILE. +********************************************************/ + +#ifdef G__MEMTEST +#undef malloc +#undef free +#endif + +extern "C" void G__cpp_reset_tagtableManualTree2(); + +extern "C" void G__set_cpp_environmentManualTree2() { + G__add_compiledheader("base/inc/TROOT.h"); + G__add_compiledheader("base/inc/TMemberInspector.h"); + G__add_compiledheader("TTree.h"); + G__cpp_reset_tagtableManualTree2(); +} +class G__treedIsrcdIManualTree2dOcxx_tag {}; + +void* operator new(size_t size,G__treedIsrcdIManualTree2dOcxx_tag* p) { + if(p && G__PVOID!=G__getgvp()) return((void*)p); +#ifndef G__ROOT + return(malloc(size)); +#else + return(::operator new(size)); +#endif +} + +/* dummy, for exception */ +#ifdef G__EH_DUMMY_DELETE +void operator delete(void *p,G__treedIsrcdIManualTree2dOcxx_tag* x) { + if((long)p==G__getgvp() && G__PVOID!=G__getgvp()) return; +#ifndef G__ROOT + free(p); +#else + ::operator delete(p); +#endif +} +#endif + +static void G__operator_delete(void *p) { + if((long)p==G__getgvp() && G__PVOID!=G__getgvp()) return; +#ifndef G__ROOT + free(p); +#else + ::operator delete(p); +#endif +} + +void G__DELDMY_treedIsrcdIManualTree2dOcxx() { G__operator_delete(0); } + +extern "C" int G__cpp_dllrevManualTree2() { return(30051515); } + +/********************************************************* +* Member function Interface Method +*********************************************************/ + +/* TTree */ +#include "ManualTree2Body.h" + +/* Setting up global function */ + +/********************************************************* +* Member function Stub +*********************************************************/ + +/********************************************************* +* Global function Stub +*********************************************************/ + +/********************************************************* +* Get size of pointer to member function +*********************************************************/ +class G__Sizep2memfuncManualTree2 { + public: + G__Sizep2memfuncManualTree2() {p=&G__Sizep2memfuncManualTree2::sizep2memfunc;} + size_t sizep2memfunc() { return(sizeof(p)); } + private: + size_t (G__Sizep2memfuncManualTree2::*p)(); +}; + +size_t G__get_sizep2memfuncManualTree2() +{ + G__Sizep2memfuncManualTree2 a; + G__setsizep2memfunc((int)a.sizep2memfunc()); + return((size_t)a.sizep2memfunc()); +} + + +/********************************************************* +* virtual base class offset calculation interface +*********************************************************/ + + /* Setting up class inheritance */ + +/********************************************************* +* Inheritance information setup/ +*********************************************************/ +extern "C" void G__cpp_setup_inheritanceManualTree2() { + + /* Setting up class inheritance */ +} + +/********************************************************* +* typedef information setup/ +*********************************************************/ +extern "C" void G__cpp_setup_typetableManualTree2() { + + /* Setting up typedef entry */ + G__search_typename2("Int_t",105,-1,0, +-1); + G__setnewtype(-1,"Signed integer 4 bytes (int)",0); + G__search_typename2("vector<TStreamerInfo*>",117,G__get_linked_tagnum(&G__ManualTree2LN_vectorlETStreamerInfomUcOallocatorlETStreamerInfomUgRsPgR),0,-1); + G__setnewtype(-1,"// @(#)root/base:$Name: $:$Id: TROOT.h,v 1.41 2004/11/19 07:25:43 brun Exp $",0); + G__search_typename2("_Ranit<TStreamerInfo*,difference_type,const_pointer,const_reference>",117,G__get_linked_tagnum(&G__ManualTree2LN__RanitlETStreamerInfomUcOlongcOTStreamerInfomUmUcOTStreamerInfomUaNgR),0,G__get_linked_tagnum(&G__ManualTree2LN_vectorlETStreamerInfomUcOallocatorlETStreamerInfomUgRsPgR)); + G__setnewtype(-1,"// @(#)root/base:$Name: $:$Id: TROOT.h,v 1.41 2004/11/19 07:25:43 brun Exp $",0); + G__search_typename2("reverse_iterator<iterator>",117,G__get_linked_tagnum(&G__ManualTree2LN_reverse_iteratorlEvectorlETStreamerInfomUcOallocatorlETStreamerInfomUgRsPgRcLcLiteratorgR),0,G__get_linked_tagnum(&G__ManualTree2LN_vectorlETStreamerInfomUcOallocatorlETStreamerInfomUgRsPgR)); + G__setnewtype(-1,"// @(#)root/base:$Name: $:$Id: TROOT.h,v 1.41 2004/11/19 07:25:43 brun Exp $",0); + G__search_typename2("iterator<iterator_traits<vector<TStreamerInfo*,allocator<TStreamerInfo*> >::iterator>::iterator_category,iterator_traits<vector<TStreamerInfo*,allocator<TStreamerInfo*> >::iterator>::value_type,iterator_traits<vector<TStreamerInfo*,allocator<TStreamerInfo*> >::iterator>::difference_type,iterator_traits<vector<TStreamerInfo*,allocator<TStreamerInfo*> >::iterator>::pointer,iterator_traits<vector<TStreamerInfo*,allocator<TStreamerInfo*> >::iterator>::reference>",117,G__get_linked_tagnum(&G__ManualTree2LN_iteratorlErandom_access_iterator_tagcOTStreamerInfomUcOvectorlETStreamerInfomUcOallocatorlETStreamerInfomUgRsPgRcLcLiteratorcLcLdifference_typecOTStreamerInfomUmUcOTStreamerInfomUaNgR),0,-1); + G__setnewtype(-1,"// @(#)root/base:$Name: $:$Id: TROOT.h,v 1.41 2004/11/19 07:25:43 brun Exp $",0); + G__search_typename2("iterator<random_access_iterator_tag,TStreamerInfo*>",117,G__get_linked_tagnum(&G__ManualTree2LN_iteratorlErandom_access_iterator_tagcOTStreamerInfomUcOvectorlETStreamerInfomUcOallocatorlETStreamerInfomUgRsPgRcLcLiteratorcLcLdifference_typecOTStreamerInfomUmUcOTStreamerInfomUaNgR),0,-1); + G__setnewtype(-1,"// @(#)root/base:$Name: $:$Id: TROOT.h,v 1.41 2004/11/19 07:25:43 brun Exp $",0); + G__search_typename2("iterator<random_access_iterator_tag,TStreamerInfo*>vector<TStreamerInfo*,allocator<TStreamerInfo*> >::iterator::difference_type>",117,G__get_linked_tagnum(&G__ManualTree2LN_iteratorlErandom_access_iterator_tagcOTStreamerInfomUcOvectorlETStreamerInfomUcOallocatorlETStreamerInfomUgRsPgRcLcLiteratorcLcLdifference_typecOTStreamerInfomUmUcOTStreamerInfomUaNgR),0,-1); + G__setnewtype(-1,"// @(#)root/base:$Name: $:$Id: TROOT.h,v 1.41 2004/11/19 07:25:43 brun Exp $",0); + G__search_typename2("iterator<random_access_iterator_tag,TStreamerInfo*>vector<TStreamerInfo*,allocator<TStreamerInfo*> >::iterator::difference_type>TStreamerInfo**>",117,G__get_linked_tagnum(&G__ManualTree2LN_iteratorlErandom_access_iterator_tagcOTStreamerInfomUcOvectorlETStreamerInfomUcOallocatorlETStreamerInfomUgRsPgRcLcLiteratorcLcLdifference_typecOTStreamerInfomUmUcOTStreamerInfomUaNgR),0,-1); + G__setnewtype(-1,"// @(#)root/base:$Name: $:$Id: TROOT.h,v 1.41 2004/11/19 07:25:43 brun Exp $",0); + G__search_typename2("reverse_iterator<const_iterator>",117,G__get_linked_tagnum(&G__ManualTree2LN_reverse_iteratorlEvectorlETStreamerInfomUcOallocatorlETStreamerInfomUgRsPgRcLcLconst_iteratorgR),0,G__get_linked_tagnum(&G__ManualTree2LN_vectorlETStreamerInfomUcOallocatorlETStreamerInfomUgRsPgR)); + G__setnewtype(-1,"// @(#)root/base:$Name: $:$Id: TROOT.h,v 1.41 2004/11/19 07:25:43 brun Exp $",0); + G__search_typename2("iterator<iterator_traits<vector<TStreamerInfo*,allocator<TStreamerInfo*> >::const_iterator>::iterator_category,iterator_traits<vector<TStreamerInfo*,allocator<TStreamerInfo*> >::const_iterator>::value_type,iterator_traits<vector<TStreamerInfo*,allocator<TStreamerInfo*> >::const_iterator>::difference_type,iterator_traits<vector<TStreamerInfo*,allocator<TStreamerInfo*> >::const_iterator>::pointer,iterator_traits<vector<TStreamerInfo*,allocator<TStreamerInfo*> >::const_iterator>::reference>",117,G__get_linked_tagnum(&G__ManualTree2LN_iteratorlErandom_access_iterator_tagcOTStreamerInfomUcOlongcOTStreamerInfomUmUcOTStreamerInfomUaNgR),0,-1); + G__setnewtype(-1,"// @(#)root/base:$Name: $:$Id: TROOT.h,v 1.41 2004/11/19 07:25:43 brun Exp $",0); + G__search_typename2("iterator<random_access_iterator_tag,TStreamerInfo*>long>",117,G__get_linked_tagnum(&G__ManualTree2LN_iteratorlErandom_access_iterator_tagcOTStreamerInfomUcOlongcOTStreamerInfomUmUcOTStreamerInfomUaNgR),0,-1); + G__setnewtype(-1,"// @(#)root/base:$Name: $:$Id: TROOT.h,v 1.41 2004/11/19 07:25:43 brun Exp $",0); + G__search_typename2("iterator<random_access_iterator_tag,TStreamerInfo*>long>TStreamerInfo**>",117,G__get_linked_tagnum(&G__ManualTree2LN_iteratorlErandom_access_iterator_tagcOTStreamerInfomUcOlongcOTStreamerInfomUmUcOTStreamerInfomUaNgR),0,-1); + G__setnewtype(-1,"// @(#)root/base:$Name: $:$Id: TROOT.h,v 1.41 2004/11/19 07:25:43 brun Exp $",0); +} + +/********************************************************* +* Data Member information setup/ +*********************************************************/ + + /* Setting up class,struct,union tag member variable */ +extern "C" void G__cpp_setup_memvarManualTree2() { +} +/*********************************************************** +************************************************************ +************************************************************ +************************************************************ +************************************************************ +************************************************************ +************************************************************ +***********************************************************/ + +/********************************************************* +* Member function information setup for each class +*********************************************************/ +static void G__setup_memfuncTTree(void) { + /* TTree */ + G__tag_memfunc_setup(G__get_linked_tagnum(&G__ManualTree2LN_TTree)); + G__memfunc_setup("Branch",590,G__ManualTree2_165_5_17,85,G__get_linked_tagnum(&G__ManualTree2LN_TBranch),-1,0,5,1,1,0, +"C - - 10 - name C - - 10 - classname " +"Y - - 3 - addobj i - 'Int_t' 0 32000 bufsize " +"i - 'Int_t' 0 99 splitlevel",(char*)NULL,(void*)NULL,0); + G__memfunc_setup("Branch",590,G__ManualTree2_165_6_17,85,G__get_linked_tagnum(&G__ManualTree2LN_TBranch),-1,0,4,1,1,0, +"C - - 10 - name Y - - 3 - addobj " +"i - 'Int_t' 0 32000 bufsize i - 'Int_t' 0 99 splitlevel",(char*)NULL,(void*)NULL,0); + G__memfunc_setup("SetBranchAddress",1600,G__ManualTree2_165_8_17,121,-1,-1,0,2,1,1,0, +"C - - 10 - bname Y - - 2 - add",(char*)NULL,(void*)NULL,0); + G__tag_memfunc_reset(); +} + + +/********************************************************* +* Member function information setup +*********************************************************/ +extern "C" void G__cpp_setup_memfuncManualTree2() { +} + +/********************************************************* +* Global variable information setup for each class +*********************************************************/ +static void G__cpp_setup_global0() { + + /* Setting up global variables */ + G__resetplocal(); + +} + +static void G__cpp_setup_global1() { +} + +static void G__cpp_setup_global2() { + + G__resetglobalenv(); +} +extern "C" void G__cpp_setup_globalManualTree2() { + G__cpp_setup_global0(); + G__cpp_setup_global1(); + G__cpp_setup_global2(); +} + +/********************************************************* +* Global function information setup for each class +*********************************************************/ +static void G__cpp_setup_func0() { + G__lastifuncposition(); + +} + +static void G__cpp_setup_func1() { +} + +static void G__cpp_setup_func2() { +} + +static void G__cpp_setup_func3() { + + G__resetifuncposition(); +} + +extern "C" void G__cpp_setup_funcManualTree2() { + G__cpp_setup_func0(); + G__cpp_setup_func1(); + G__cpp_setup_func2(); + G__cpp_setup_func3(); +} + +/********************************************************* +* Class,struct,union,enum tag information setup +*********************************************************/ +/* Setup class/struct taginfo */ +G__linked_taginfo G__ManualTree2LN_vectorlETStreamerInfomUcOallocatorlETStreamerInfomUgRsPgR = { "vector<TStreamerInfo*,allocator<TStreamerInfo*> >" , 99 , -1 }; +G__linked_taginfo G__ManualTree2LN__RanitlETStreamerInfomUcOlongcOTStreamerInfomUmUcOTStreamerInfomUaNgR = { "_Ranit<TStreamerInfo*,long,TStreamerInfo**,TStreamerInfo*&>" , 115 , -1 }; +G__linked_taginfo G__ManualTree2LN_iteratorlErandom_access_iterator_tagcOTStreamerInfomUcOlongcOTStreamerInfomUmUcOTStreamerInfomUaNgR = { "iterator<random_access_iterator_tag,TStreamerInfo*,long,TStreamerInfo**,TStreamerInfo*&>" , 115 , -1 }; +G__linked_taginfo G__ManualTree2LN_reverse_iteratorlEvectorlETStreamerInfomUcOallocatorlETStreamerInfomUgRsPgRcLcLiteratorgR = { "reverse_iterator<vector<TStreamerInfo*,allocator<TStreamerInfo*> >::iterator>" , 99 , -1 }; +G__linked_taginfo G__ManualTree2LN_iteratorlErandom_access_iterator_tagcOTStreamerInfomUcOvectorlETStreamerInfomUcOallocatorlETStreamerInfomUgRsPgRcLcLiteratorcLcLdifference_typecOTStreamerInfomUmUcOTStreamerInfomUaNgR = { "iterator<random_access_iterator_tag,TStreamerInfo*,vector<TStreamerInfo*,allocator<TStreamerInfo*> >::iterator::difference_type,TStreamerInfo**,TStreamerInfo*&>" , 115 , -1 }; +G__linked_taginfo G__ManualTree2LN_reverse_iteratorlEvectorlETStreamerInfomUcOallocatorlETStreamerInfomUgRsPgRcLcLconst_iteratorgR = { "reverse_iterator<vector<TStreamerInfo*,allocator<TStreamerInfo*> >::const_iterator>" , 99 , -1 }; +G__linked_taginfo G__ManualTree2LN_TTree = { "TTree" , 99 , -1 }; +G__linked_taginfo G__ManualTree2LN_TBranch = { "TBranch" , 99 , -1 }; + +/* Reset class/struct taginfo */ +extern "C" void G__cpp_reset_tagtableManualTree2() { + G__ManualTree2LN_vectorlETStreamerInfomUcOallocatorlETStreamerInfomUgRsPgR.tagnum = -1 ; + G__ManualTree2LN__RanitlETStreamerInfomUcOlongcOTStreamerInfomUmUcOTStreamerInfomUaNgR.tagnum = -1 ; + G__ManualTree2LN_iteratorlErandom_access_iterator_tagcOTStreamerInfomUcOlongcOTStreamerInfomUmUcOTStreamerInfomUaNgR.tagnum = -1 ; + G__ManualTree2LN_reverse_iteratorlEvectorlETStreamerInfomUcOallocatorlETStreamerInfomUgRsPgRcLcLiteratorgR.tagnum = -1 ; + G__ManualTree2LN_iteratorlErandom_access_iterator_tagcOTStreamerInfomUcOvectorlETStreamerInfomUcOallocatorlETStreamerInfomUgRsPgRcLcLiteratorcLcLdifference_typecOTStreamerInfomUmUcOTStreamerInfomUaNgR.tagnum = -1 ; + G__ManualTree2LN_reverse_iteratorlEvectorlETStreamerInfomUcOallocatorlETStreamerInfomUgRsPgRcLcLconst_iteratorgR.tagnum = -1 ; + G__ManualTree2LN_TBranch.tagnum = -1 ; +} + + +extern "C" void G__cpp_setup_tagtableManualTree2() { + + /* Setting up class,struct,union tag entry */ + G__get_linked_tagnum(&G__ManualTree2LN_vectorlETStreamerInfomUcOallocatorlETStreamerInfomUgRsPgR); + G__get_linked_tagnum(&G__ManualTree2LN__RanitlETStreamerInfomUcOlongcOTStreamerInfomUmUcOTStreamerInfomUaNgR); + G__get_linked_tagnum(&G__ManualTree2LN_iteratorlErandom_access_iterator_tagcOTStreamerInfomUcOlongcOTStreamerInfomUmUcOTStreamerInfomUaNgR); + G__get_linked_tagnum(&G__ManualTree2LN_reverse_iteratorlEvectorlETStreamerInfomUcOallocatorlETStreamerInfomUgRsPgRcLcLiteratorgR); + G__get_linked_tagnum(&G__ManualTree2LN_iteratorlErandom_access_iterator_tagcOTStreamerInfomUcOvectorlETStreamerInfomUcOallocatorlETStreamerInfomUgRsPgRcLcLiteratorcLcLdifference_typecOTStreamerInfomUmUcOTStreamerInfomUaNgR); + G__get_linked_tagnum(&G__ManualTree2LN_reverse_iteratorlEvectorlETStreamerInfomUcOallocatorlETStreamerInfomUgRsPgRcLcLconst_iteratorgR); + G__tagtable_setup(G__get_linked_tagnum(&G__ManualTree2LN_TTree),sizeof(TTree),-1,62720,"Tree descriptor (the main ROOT I/O class)",NULL,G__setup_memfuncTTree); + G__get_linked_tagnum(&G__ManualTree2LN_TBranch); +} +extern "C" void G__cpp_setupManualTree2(void) { + G__check_setup_version(30051515,"G__cpp_setupManualTree2()"); + G__set_cpp_environmentManualTree2(); + G__cpp_setup_tagtableManualTree2(); + + G__cpp_setup_inheritanceManualTree2(); + + G__cpp_setup_typetableManualTree2(); + + G__cpp_setup_memvarManualTree2(); + + G__cpp_setup_memfuncManualTree2(); + G__cpp_setup_globalManualTree2(); + G__cpp_setup_funcManualTree2(); + + if(0==G__getsizep2memfunc()) G__get_sizep2memfuncManualTree2(); + return; +} +class G__cpp_setup_initManualTree2 { + public: + G__cpp_setup_initManualTree2() { G__add_setup_func("ManualTree2",(G__incsetup)(&G__cpp_setupManualTree2)); G__call_setup_funcs(); } + ~G__cpp_setup_initManualTree2() { G__remove_setup_func("ManualTree2"); } +}; +G__cpp_setup_initManualTree2 G__cpp_setup_initializerManualTree2; + diff --git a/tree/src/ManualTree2.h b/tree/src/ManualTree2.h new file mode 100644 index 0000000000000000000000000000000000000000..5e3e006ec711bc30916c7d207606ed1e1af59d7c --- /dev/null +++ b/tree/src/ManualTree2.h @@ -0,0 +1,46 @@ +/******************************************************************** +* tree/src/ManualTree2.h +* CAUTION: DON'T CHANGE THIS FILE. THIS FILE IS AUTOMATICALLY GENERATED +* FROM HEADER FILES LISTED IN G__setup_cpp_environmentXXX(). +* CHANGE THOSE HEADER FILES AND REGENERATE THIS FILE. +********************************************************************/ +#ifdef __CINT__ +#error tree/src/ManualTree2.h/C is only for compilation. Abort cint. +#endif +#include <stddef.h> +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include <string.h> +#define G__ANSIHEADER +#define G__DICTIONARY +#include "G__ci.h" +extern "C" { +extern void G__cpp_setup_tagtableManualTree2(); +extern void G__cpp_setup_inheritanceManualTree2(); +extern void G__cpp_setup_typetableManualTree2(); +extern void G__cpp_setup_memvarManualTree2(); +extern void G__cpp_setup_globalManualTree2(); +extern void G__cpp_setup_memfuncManualTree2(); +extern void G__cpp_setup_funcManualTree2(); +extern void G__set_cpp_environmentManualTree2(); +} + +#include "TTree.h" +#include <algorithm> +namespace std { } +using namespace std; + +#ifndef G__MEMFUNCBODY +#endif + +extern G__linked_taginfo G__ManualTree2LN_vectorlETStreamerInfomUcOallocatorlETStreamerInfomUgRsPgR; +extern G__linked_taginfo G__ManualTree2LN__RanitlETStreamerInfomUcOlongcOTStreamerInfomUmUcOTStreamerInfomUaNgR; +extern G__linked_taginfo G__ManualTree2LN_iteratorlErandom_access_iterator_tagcOTStreamerInfomUcOlongcOTStreamerInfomUmUcOTStreamerInfomUaNgR; +extern G__linked_taginfo G__ManualTree2LN_reverse_iteratorlEvectorlETStreamerInfomUcOallocatorlETStreamerInfomUgRsPgRcLcLiteratorgR; +extern G__linked_taginfo G__ManualTree2LN_iteratorlErandom_access_iterator_tagcOTStreamerInfomUcOvectorlETStreamerInfomUcOallocatorlETStreamerInfomUgRsPgRcLcLiteratorcLcLdifference_typecOTStreamerInfomUmUcOTStreamerInfomUaNgR; +extern G__linked_taginfo G__ManualTree2LN_reverse_iteratorlEvectorlETStreamerInfomUcOallocatorlETStreamerInfomUgRsPgRcLcLconst_iteratorgR; +extern G__linked_taginfo G__ManualTree2LN_TTree; +extern G__linked_taginfo G__ManualTree2LN_TBranch; + +/* STUB derived class for protected member access */ diff --git a/tree/src/ManualTree2Body.h b/tree/src/ManualTree2Body.h new file mode 100644 index 0000000000000000000000000000000000000000..a39a4b32503926e0f20359dc86a6c29c3953f92b --- /dev/null +++ b/tree/src/ManualTree2Body.h @@ -0,0 +1,101 @@ +static int G__ManualTree2_165_5_17(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) +{ + // We need to emulate + // return BranchImp(name,classname,TBuffer::GetClass(typeid(T)),addobj,bufsize,splitlevel); + + // Here find the class name + G__ClassInfo ti( libp->para[2].tagnum ); + TClass *realClass = gROOT->GetClass(ti.Name()); + const char* classname = (const char*)G__int(libp->para[1]); + TClass *claim = gROOT->GetClass(classname); + + const char *branchname = (const char*)G__int(libp->para[0]); + if (realClass && claim && !(claim->InheritsFrom(realClass)||realClass->InheritsFrom(claim)) ) { + // Note we currently do not warning in case of splicing or over-expectation). + Error("TTree::Branch","The class requested (%s) for the branch \"%s\" is different from the type of the pointer passed (%s)", + claim->GetName(),branchname,realClass->GetName()); + G__letint(result7,85,0); + } else { + + if (realClass) classname = realClass->GetName(); + TTree *t = (TTree*)(G__getstructoffset()); + switch(libp->paran) { + case 5: + G__letint(result7,85,(long)t->Branch(branchname, + classname, + (void*)G__int(libp->para[2]), + (Int_t)G__int(libp->para[3]), + (Int_t)G__int(libp->para[4]))); + break; + case 4: + G__letint(result7,85,(long)t->Branch(branchname, + classname, + (void*)G__int(libp->para[2]), + (Int_t)G__int(libp->para[3]))); + break; + case 3: + G__letint(result7,85,(long)t->Branch(branchname, + classname, + (void*)G__int(libp->para[2]))); + break; + } + } + return(1 || funcname || hash || result7 || libp) ; +} + +static int G__ManualTree2_165_6_17(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) +{ + // We need to emulate + // return BranchImp(name,TBuffer::GetClass(typeid(T)),addobj,bufsize,splitlevel); + + G__ClassInfo ti( libp->para[1].tagnum ); + TClass *realClass = gROOT->GetClass(ti.Name()); + + const char *branchname = (const char*)G__int(libp->para[0]); + if (realClass == 0) { + Error("TTree::Branch","The pointer specified for %s not of a class known to ROOT", + branchname); + G__letint(result7,85,0); + } else { + TTree *t = (TTree*)(G__getstructoffset()); + switch(libp->paran) { + case 5: + G__letint(result7,85,(long)t->Branch(branchname, + realClass->GetName(), + (void*)G__int(libp->para[1]), + (Int_t)G__int(libp->para[2]), + (Int_t)G__int(libp->para[3]))); + break; + case 4: + G__letint(result7,85,(long)t->Branch(branchname, + realClass->GetName(), + (void*)G__int(libp->para[1]), + (Int_t)G__int(libp->para[2]))); + break; + case 3: + G__letint(result7,85,(long)t->Branch(branchname, + realClass->GetName(), + (void*)G__int(libp->para[1]), + (Int_t)G__int(libp->para[2]), + (Int_t)G__int(libp->para[3]))); + break; + } + } + return(1 || funcname || hash || result7 || libp) ; +} + +#include "TDataType.h" + +static int G__ManualTree2_165_8_17(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) +{ + G__setnull(result7); + + G__TypeInfo ti( libp->para[1] ); + string type( TClassEdit::ShortType(ti.Name(),TClassEdit::kDropTrailStar) ); + TClass *realClass = gROOT->GetClass(type.c_str()); + TDataType *data = gROOT->GetType(type.c_str()); + EDataType datatype = data ? (EDataType)data->GetType() : kOther_t; + + ((TTree*)(G__getstructoffset()))->SetBranchAddress((const char*)G__int(libp->para[0]),(void*)G__int(libp->para[1]),realClass,datatype,ti.Reftype()==G__PARAP2P); + return(1 || funcname || hash || result7 || libp) ; +} diff --git a/tree/src/TBranchElement.cxx b/tree/src/TBranchElement.cxx index d95cadb3d81c579a10a0c6fe17a6812caeeb0c8f..f8e6b0493cc62c9ce2f0ff5bc93553fa571452be 100644 --- a/tree/src/TBranchElement.cxx +++ b/tree/src/TBranchElement.cxx @@ -1,4 +1,4 @@ -// @(#)root/tree:$Name: $:$Id: TBranchElement.cxx,v 1.159 2004/11/19 20:08:58 brun Exp $ +// @(#)root/tree:$Name: $:$Id: TBranchElement.cxx,v 1.160 2005/01/03 21:58:52 brun Exp $ // Authors Rene Brun , Philippe Canal, Markus Frank 14/01/2001 /************************************************************************* @@ -428,13 +428,14 @@ TBranchElement::TBranchElement(const char *bname, TVirtualCollectionProxy *cont, // // If splitlevel > 0 this branch in turn is split into sub branches - fCollProxy = cont; + fCollProxy = cont->Generate(); char name[kMaxLen]; strcpy(name,bname); + if (name[strlen(name)-1]=='.') name[strlen(name)-1]=0; fSplitLevel = splitlevel; fInfo = 0; - fID = 0; - fStreamerType = -1; + fID = -1; + fStreamerType = -1; // TStreamerInfo::kSTLp; fType = 0; fClassVersion = cont->GetCollectionClass()->GetClassVersion(); fBranchCount = 0; @@ -451,9 +452,9 @@ TBranchElement::TBranchElement(const char *bname, TVirtualCollectionProxy *cont, SetName(name); SetTitle(name); - Bool_t Implemented=kFALSE; - Assert(Implemented); - // fClassName = cont->GetName(); + //Bool_t Implemented=kFALSE; + //Assert(Implemented); + fClassName = cont->GetCollectionClass()->GetName(); fCompress = compress; if (compress == -1 && fTree->GetDirectory()) { TFile *bfile = fTree->GetDirectory()->GetFile(); @@ -481,7 +482,8 @@ TBranchElement::TBranchElement(const char *bname, TVirtualCollectionProxy *cont, // create sub branches if requested by splitlevel - if (splitlevel > 0) { + if (splitlevel > 0 && + GetCollectionProxy()->GetCollectionClass()->CanSplit()) { // ===> Create a leafcount TLeaf *leaf = new TLeafElement(name,fID, fStreamerType); leaf->SetBranch(this); @@ -506,8 +508,6 @@ TBranchElement::TBranchElement(const char *bname, TVirtualCollectionProxy *cont, return; } - SetBit(kBranchObject); - TLeaf *leaf = new TLeafElement(GetTitle(),fID, fStreamerType); leaf->SetTitle(GetTitle()); leaf->SetBranch(this); @@ -821,6 +821,7 @@ void TBranchElement::Browse(TBrowser *b) if (GetBrowsableMethods()) GetBrowsableMethods()->Browse(b); } else { + // Get the name and strip any extra brackets // in order to get the full arrays. TString slash("/"), escapedSlash("\\/"); @@ -1100,6 +1101,7 @@ TList *TBranchElement::GetBrowsableMethods() { cl=clsub; } + if (cl && cl->GetCollectionProxy()) cl = cl->GetCollectionProxy()->GetValueClass(); if (!cl) return 0; fBrowsableMethods=TMethodBrowsable::GetMethodBrowsables(this, cl); return fBrowsableMethods; @@ -1769,7 +1771,7 @@ void TBranchElement::ReadLeaves(TBuffer &b) // and Commit == noop. // TODO: Exception safety a la TPushPop TVirtualCollectionProxy* proxy = GetCollectionProxy(); - TVirtualCollectionProxy::TPushPop helper(proxy,fAddress); + TVirtualCollectionProxy::TPushPop helper(proxy,fObject); void* env = proxy->Allocate(fNdata,true); Int_t i, nbranches = fBranches.GetEntriesFast(); switch(fSTLtype) { @@ -1883,7 +1885,14 @@ namespace { // Get the current type of this data member! TStreamerInfo *brInfo = br->GetInfo(); + if (brInfo==0) { + TClass *coll = gROOT->GetClass(br->GetClassName()); + Assert(coll && coll->GetCollectionProxy()); + return coll; + } TClass *motherCl = brInfo->GetClass(); + if (motherCl->GetCollectionProxy()) + return motherCl->GetCollectionProxy()->GetCollectionClass(); TStreamerElement *currentStreamerElement = ((TStreamerElement*)brInfo->GetElems()[br->GetID()]); @@ -2458,6 +2467,11 @@ Int_t TBranchElement::Unroll(const char *name, TClass *cltop, TClass *cl,Int_t b char branchname[kMaxLen]; Int_t jd = 0; Int_t unroll = 0; + if (ndata==1 && cl->GetCollectionProxy() && + strcmp(((TStreamerElement*)elems[0])->GetName(),"This")==0) { + // This streamerInfo only refers to the collection itself + return 1; + } for (Int_t i=0;i<ndata;i++) { elem = (TStreamerElement*)elems[i]; Int_t offset = elem->GetOffset(); @@ -2583,7 +2597,9 @@ TVirtualCollectionProxy *TBranchElement::GetCollectionProxy() TBranchElement *This = const_cast<TBranchElement*>(this); if (fType==4 ) { - const char *ty = ((TStreamerElement*)This->GetInfo()->GetElems()[fID])->GetTypeName(); + const char *ty; + if (fID>=0) ty = ((TStreamerElement*)This->GetInfo()->GetElems()[fID])->GetTypeName(); + else ty = fClassName.Data(); TClass *cl = gROOT->GetClass(ty); fCollProxy = cl->GetCollectionProxy()->Generate(); fSTLtype = TClassEdit::IsSTLCont(ty); diff --git a/tree/src/TBranchObject.cxx b/tree/src/TBranchObject.cxx index 61c7c4587535c8929e49a031aa39ef333c17271f..5c590451be0d84d255672d52ae2fcfdcb885e760 100644 --- a/tree/src/TBranchObject.cxx +++ b/tree/src/TBranchObject.cxx @@ -1,4 +1,4 @@ -// @(#)root/tree:$Name: $:$Id: TBranchObject.cxx,v 1.28 2004/07/29 10:54:54 brun Exp $ +// @(#)root/tree:$Name: $:$Id: TBranchObject.cxx,v 1.29 2004/09/24 18:22:02 brun Exp $ // Author: Rene Brun 11/02/96 /************************************************************************* @@ -67,7 +67,7 @@ TBranchObject::TBranchObject(const char *name, const char *classname, void *addo delobj = kTRUE; } gTree->BuildStreamerInfo(cl,obj); - if (delobj) delete obj; + if (delobj) cl->Destructor(obj); SetName(name); SetTitle(name); diff --git a/tree/src/TChain.cxx b/tree/src/TChain.cxx index 6660e5d9b5a1fbd8983459344bc7ed2e993c9432..30d5cc106788140a094b639c50d1486a325587ae 100644 --- a/tree/src/TChain.cxx +++ b/tree/src/TChain.cxx @@ -1,4 +1,4 @@ -// @(#)root/tree:$Name: $:$Id: TChain.cxx,v 1.96 2004/10/31 09:28:06 brun Exp $ +// @(#)root/tree:$Name: $:$Id: TChain.cxx,v 1.97 2004/12/11 08:26:45 brun Exp $ // Author: Rene Brun 03/02/97 /************************************************************************* @@ -1222,6 +1222,9 @@ void TChain::SetBranchAddress(const char *bname, void *add) if (fTreeNumber >= 0) { TBranch *branch = fTree->GetBranch(bname); if (branch) { + CheckBranchAddressType(branch, + gROOT->GetClass(element->GetBaddressClassName()), + (EDataType)element->GetBaddressType(),element->GetBaddressIsPtr()); if (fClones) { void *oldAdd = branch->GetAddress(); TObjLink *lnk = fClones->FirstLink(); @@ -1240,6 +1243,24 @@ void TChain::SetBranchAddress(const char *bname, void *add) } } +//_______________________________________________________________________ +void TChain::SetBranchAddress(const char *bname,void *add, + TClass *realClass, EDataType datatype, + Bool_t ptr) +{ + //Check if bname is already in the Status list + //Otherwise create a TChainElement object and set its address + TChainElement *element = (TChainElement*)fStatus->FindObject(bname); + if (!element) { + element = new TChainElement(bname,""); + fStatus->Add(element); + } + if (realClass) element->SetBaddressClassName(realClass->GetName()); + element->SetBaddressType((UInt_t)datatype); + element->SetBaddressIsPtr(ptr); + SetBranchAddress(bname,add); +} + //_______________________________________________________________________ void TChain::SetBranchStatus(const char *bname, Bool_t status, UInt_t *found) { diff --git a/tree/src/TTree.cxx b/tree/src/TTree.cxx index 18f95018539d039cee80fb60e8d0b4d59bfd5020..6e97268e41f73715d429ad25fb2bdcbefbb2a024 100644 --- a/tree/src/TTree.cxx +++ b/tree/src/TTree.cxx @@ -1,4 +1,4 @@ -// @(#)root/tree:$Name: $:$Id: TTree.cxx,v 1.218 2004/12/22 17:06:47 brun Exp $ +// @(#)root/tree:$Name: $:$Id: TTree.cxx,v 1.219 2005/01/11 13:15:39 brun Exp $ // Author: Rene Brun 12/01/96 /************************************************************************* @@ -738,6 +738,39 @@ Long64_t TTree::AutoSave(Option_t *option) return nbytes; } +//______________________________________________________________________________ +TBranch* TTree::BranchImp(const char *name, const char *classname, + TClass *realClass, void *addobj, Int_t bufsize, + Int_t splitlevel) +{ + // Same as TTree::Branch with added check that the address passed in addobj + // corresponding to className. See TTree::Branch for other details. + + if (realClass==0) return Branch(name,classname,(void*)addobj,bufsize,splitlevel); + TClass *claim = gROOT->GetClass(classname); + if (realClass && claim && !(claim->InheritsFrom(realClass)||realClass->InheritsFrom(claim)) ) { + // Note we currently do not warning in case of splicing or over-expectation). + Error("Branch","The class requested (%s) for \"%s\" is different from the type of the pointer passed (%s)", + claim->GetName(),name,realClass->GetName()); + } + return Branch(name,realClass->GetName(),(void*)addobj,bufsize,splitlevel); +} + +//______________________________________________________________________________ +TBranch* TTree::BranchImp(const char *name, TClass *realClass, void *addobj, + Int_t bufsize, Int_t splitlevel) +{ + // Same as TTree::Branch but automatic detection of the class name + // See TTree::Branch for other details. + + if (realClass == 0) { + Error("Branch","The pointer specified for %s not of a class known to ROOT", + name); + return 0; + } + return Branch(name,realClass->GetName(),(void*)addobj,bufsize,splitlevel); +} + //______________________________________________________________________________ Int_t TTree::Branch(TList *list, Int_t bufsize, Int_t splitlevel) { @@ -938,7 +971,7 @@ TBranch *TTree::Branch(const char *name, void *address, const char *leaflist,Int } //______________________________________________________________________________ -TBranch *TTree::Branch(const char *name, void *clonesaddress, Int_t bufsize, Int_t splitlevel) +TBranch *TTree::Branch(const char *name, TClonesArray **clonesaddress, Int_t bufsize, Int_t splitlevel) { // Special constructor for TClonesArray. // Note that this function is only provided for backward compatibility. @@ -973,9 +1006,7 @@ TBranch *TTree::Branch(const char *name, void *clonesaddress, Int_t bufsize, Int if (clonesaddress == 0) return 0; - char *cpointer =(char*)clonesaddress; - char **ppointer =(char**)cpointer; - TClonesArray *list = (TClonesArray*)(*ppointer); + TClonesArray *list = *clonesaddress; if (list == 0) return 0; gTree = this; if (fgBranchStyle == 1) { @@ -1343,37 +1374,42 @@ TBranch *TTree::Bronch(const char *name, const char *classname, void *add, Int_t return branch; } } -// Now look vector<> or list<> - TString inclass; - int stlcont = TClassEdit::IsSTLCont(classname); - - if ( (stlcont>=1 && stlcont<=8) || (stlcont>=-8 && stlcont<=-1) ) { - inclass = TClassEdit::ShortType(classname,1+2+4).c_str(); - TClass *inklass = gROOT->GetClass(inclass.Data()); - if (!inklass) { + // Now look vector<> or list<> + //int stlcont = TClassEdit::IsSTLCont(classname); + + //if ( (stlcont>=1 && stlcont<=8) || (stlcont>=-8 && stlcont<=-1) || cl->GetCollectionProxy() ) { + if (cl->GetCollectionProxy()) { + TVirtualCollectionProxy *collProxy = cl->GetCollectionProxy(); + //if( !collProxy ) { + // Error("Bronch","%s is missing its CollectionProxy (for branch %s)",classname,name); + //} + TClass *inklass = collProxy->GetValueClass(); + if (!inklass && collProxy->GetType()==0 ) { Error("Bronch","%s with no class defined in branch: %s",classname,name); return 0; } - G__ClassInfo* classinfo = inklass->GetClassInfo(); - if (!classinfo) { - Error("Bronch","%s with no dictionary defined in branch: %s",classname,name); - return 0; - } - if (splitlevel > 0) { + + if (splitlevel > 0 && inklass && inklass->GetCollectionProxy()==0) { + G__ClassInfo *classinfo = inklass->GetClassInfo(); + if (!classinfo) { + Error("Bronch","Container with no dictionary defined in branch: %s",name); + return 0; + } if (classinfo->RootFlag() & 1) - Warning("Bronch","Using split mode on a class: %s with a custom Streamer",inclass.Data()); - } else { - TBranchObject *branch = new TBranchObject(name,classname,add,bufsize,0); - fBranches.Add(branch); - return branch; + Warning("Bronch","Using split mode on a class: %s with a custom Streamer",inklass->GetName()); } + TBranchElement *branch = new TBranchElement(name,collProxy,bufsize,splitlevel); + fBranches.Add(branch); + branch->SetAddress(add); + return branch; } + Bool_t hasCustomStreamer = kFALSE; - if (!cl->GetClassInfo()) { + if (!cl->GetClassInfo() && !cl->GetCollectionProxy()) { Error("Bronch","Cannot find dictionary for class: %s",classname); return 0; } - if (cl->GetClassInfo()->RootFlag() & 1) hasCustomStreamer = kTRUE; + if (cl->GetCollectionProxy()==0 && cl->GetClassInfo()->RootFlag() & 1 ) hasCustomStreamer = kTRUE; if (splitlevel < 0 || (splitlevel == 0 && hasCustomStreamer)) { TBranchObject *branch = new TBranchObject(name,classname,add,bufsize,0); fBranches.Add(branch); @@ -1389,18 +1425,7 @@ TBranch *TTree::Bronch(const char *name, const char *classname, void *add, Int_t branch->SetAddress(add); return branch; } - //====> - //====> special case of vector<...> or list<...> - TVirtualCollectionProxy *collProxy = cl->GetCollectionProxy(); - if( collProxy ) { // MSF: stlcont>=1 && stlcont<=2) { - TVirtualCollectionProxy *collProxy = cl->GetCollectionProxy()->Generate(); // TSTLCont *tstl = new TSTLCont(classname,(void*)objadd); - TBranchElement *branch = new TBranchElement(name,collProxy,bufsize,splitlevel); - fBranches.Add(branch); - branch->SetAddress(add); - return branch; - } - //====> - + if (!objadd) { objadd = (char*)cl->New(); *ppointer = objadd; @@ -1653,6 +1678,71 @@ TFile *TTree::ChangeFile(TFile *file) return newfile; } +//______________________________________________________________________________ +Bool_t TTree::CheckBranchAddressType(TBranch *branch, TClass *realClass, + EDataType datatype, Bool_t ptr) +{ + // Check whether the address described by the last 3 parameters match the + // content of the branch. + + // Let determine what we need! + TClass *expectedClass = 0; + EDataType expectedType = kOther_t; + + if (branch->InheritsFrom(TBranchObject::Class()) ) { + + TLeafObject *lobj = (TLeafObject*)branch->GetListOfLeaves()->At(0); + expectedClass = lobj->GetClass(); + + } else if (branch->InheritsFrom(TBranchElement::Class()) ) { + TBranchElement *branchEl = (TBranchElement *)branch; + Int_t type = branchEl->GetStreamerType(); + if (type==-1 || branchEl->GetID()==-1) { + expectedClass = branchEl->GetInfo()->GetClass(); + } else { + // Case of an object data member. Here we allow for the + // variable name to be ommitted. Eg, for Event.root with split + // level 1 or above Draw("GetXaxis") is the same as Draw("fH.GetXaxis()") + TStreamerElement* element = (TStreamerElement*) + branchEl->GetInfo()->GetElems()[branchEl->GetID()]; + if (element) expectedClass = element->GetClassPointer(); + if (expectedClass==0) { + expectedType = (EDataType)gROOT->GetType(element->GetTypeNameBasic())->GetType(); + } + } + if (branch->GetMother()==branch) { + // Top Level branch + if (!ptr) { + Error("SetBranchAddress", + "The address for \"%s\" should be the address of a pointer!",branch->GetName()); + } + } + } else { + TLeaf *l = (TLeaf*)branch->GetListOfLeaves()->At(0); + if (l) expectedType = (EDataType)gROOT->GetType(l->GetTypeName())->GetType(); + } + + if (expectedType == kDouble32_t) expectedType = kDouble_t; + if (datatype == kDouble32_t) datatype = kDouble_t; + if (expectedClass && realClass && !expectedClass->InheritsFrom(realClass)) { + Error("SetBranchAddress", + "The pointer type give (%s) does not correspond to the class needed (%s) by the branch: %s", + realClass->GetName(),expectedClass->GetName(),branch->GetName()); + return kFALSE; + } else if (expectedType != kOther_t && datatype != kOther_t && + expectedType != kNoType_t && datatype != kNoType_t && + expectedType != datatype) { + if (datatype != kChar_t) { + // For backward compatibility we assume that (char*) was just a cast and/or a generic address + Error("SetBranchAddress", + "The pointer type given \"%s\" (%d) does not correspond to the type needed \"%s\" (%d) by the branch: %s", + TDataType::GetTypeName(datatype),datatype,TDataType::GetTypeName(expectedType),expectedType, branch->GetName()); + return kFALSE; + } + } + return kTRUE; +} + //______________________________________________________________________________ TTree *TTree::CloneTree(Long64_t nentries, Option_t *) { @@ -1787,7 +1877,7 @@ void TTree::CopyAddresses(TTree *tree) branch->GetEntry(0); } if (branch->GetAddress()) { - tree->SetBranchAddress(branch->GetName(),branch->GetAddress()); + tree->SetBranchAddress(branch->GetName(),(void*)branch->GetAddress()); } else { leaf2->SetAddress(leaf->GetValuePointer()); } @@ -2127,6 +2217,9 @@ Long64_t TTree::Draw(const char *varexp, const char *selection, Option_t *option // Iteration$: return the current iteration over this formula for this // entry (i.e. varies from 0 to Length$). // +// Length$(formula): return the total number of element of the formula given as a +// parameter. +// // Alt$(primary,alternate) : return the value of "primary" if it is available // for the current iteration otherwise return the value of "alternate". // For example, with arr1[3] and arr2[2] @@ -3980,6 +4073,24 @@ Bool_t TTree::SetAlias(const char *aliasName, const char *aliasFormula) } else Error("SetBranchAddress", "unknown branch -> %s", bname); } +//_______________________________________________________________________ + void TTree::SetBranchAddress(const char *bname, void *add, + TClass *realClass, EDataType datatype, + Bool_t ptr) +{ + // Verify the validity of the type of add before calling SetBranchAddress. + + TBranch *branch = GetBranch(bname); + if (branch) { + + CheckBranchAddressType(branch,realClass,datatype,ptr); + return SetBranchAddress(bname,add); + + } else { + Error("SetBranchAddress", "unknown branch -> %s", bname); + } +} + //_______________________________________________________________________ void TTree::SetBranchStatus(const char *bname, Bool_t status, UInt_t *found) { diff --git a/treeplayer/src/TTreeFormula.cxx b/treeplayer/src/TTreeFormula.cxx index ed3a5384bdf1ead817843a8d62062a1b9784c981..aaed9b8f642cf4f0c7ec25707afacc6479a98688 100644 --- a/treeplayer/src/TTreeFormula.cxx +++ b/treeplayer/src/TTreeFormula.cxx @@ -1,4 +1,4 @@ -// @(#)root/treeplayer:$Name: $:$Id: TTreeFormula.cxx,v 1.156 2004/11/17 08:46:43 brun Exp $ +// @(#)root/treeplayer:$Name: $:$Id: TTreeFormula.cxx,v 1.157 2004/11/17 17:56:53 brun Exp $ // Author: Rene Brun 19/01/96 /************************************************************************* @@ -1295,6 +1295,23 @@ Int_t TTreeFormula::DefinedVariable(TString &name, Int_t &action) maininfo = collectioninfo; previnfo = maininfo; + } else if (BranchEl->GetStreamerType()==-1 && cl && cl->GetCollectionProxy()) { + + TFormLeafInfo* collectioninfo = new TFormLeafInfoCollection(cl, 0, cl, kTRUE); + // The dimension needs to be handled! + numberOfVarDim += RegisterDimensions(code,collectioninfo); + + maininfo = collectioninfo; + if (cl->GetCollectionProxy()->GetValueClass()==0 && + cl->GetCollectionProxy()->GetType()>0) { + + collectioninfo->fNext = + new TFormLeafInfoNumerical(cl->GetCollectionProxy()->GetType()); + previnfo = collectioninfo->fNext; + } else { + previnfo = collectioninfo; + } + } else if (strlen(right)==0 && cl && element && !element->IsaPointer() && final) { if (element->GetClassPointer() && element->GetClassPointer()->GetCollectionProxy() diff --git a/tutorials/tree0.C b/tutorials/tree0.C index b77dcc2aecf6449ce8368a1ce43e923b414fd919..ae2ec5df12fdc6e8b81f6a2d3774b95ee549e4f5 100644 --- a/tutorials/tree0.C +++ b/tutorials/tree0.C @@ -66,7 +66,7 @@ void tree0() { Event *e = new Event; // create a branch with energy - tree->Branch("event","Event",&e); + tree->Branch("event",&e); // fill some events with random numbers Int_t nevent=10000; diff --git a/tutorials/tree2a.C b/tutorials/tree2a.C index 2af908f9d7f795a168299b1190c05259d880bfb1..07884650bb6790cd7a74dc652246d141998e0e66 100644 --- a/tutorials/tree2a.C +++ b/tutorials/tree2a.C @@ -85,7 +85,7 @@ void tree2aw() TFile f("tree2.root","recreate"); TTree t2("t2","a Tree with data from a fake Geant3"); Gctrak *gstep = new Gctrak; - t2.Branch("track","Gctrak",&gstep,8000,1); + t2.Branch("track",&gstep,8000,1); //Initialize particle parameters at first point Float_t px,py,pz,p,charge=0; diff --git a/tutorials/tree3.C b/tutorials/tree3.C index d0ea7b8ae45c0920b0d523e3cdb424505dfbb16b..55f05a8c4a0ab6c7338bdda573420d4553b1edd4 100644 --- a/tutorials/tree3.C +++ b/tutorials/tree3.C @@ -1,3 +1,8 @@ +#include "TFile.h" +#include "TTree.h" +#include "TRandom.h" +#include "TCanvas.h" + void tree3w() { // Example of a Tree where branches are variable length arrays // A second Tree is created and filled in parallel. diff --git a/tutorials/tree4.C b/tutorials/tree4.C index 2d1751b9fd69a033928da37c740a08a27a060c80..7f8d9632ed08227043a3773178a92b89c29c3213 100644 --- a/tutorials/tree4.C +++ b/tutorials/tree4.C @@ -59,8 +59,8 @@ void tree4w() Event *event = new Event(); // Create two branches, split one. - t4.Branch("event_split", "Event", &event,16000,99); - t4.Branch("event_not_split", "Event", &event,16000,0); + t4.Branch("event_split", &event,16000,99); + t4.Branch("event_not_split", &event,16000,0); // a local variable for the event type char etype[20];