Hi Ed, TExMap was not designed to be persistent. I have modified the class such that your example works. Now in CVS. Rene Brun Edward Moyse wrote: > > > The problem is you didn't write your TExMap in the file, so it's normal > > you can't get it back afterwards ;-) > > Oops! ;-) > > > However if you replace > > > > hfile->Write("TestMap", TObject::kSingleKey); > > > > with > > > > testMap->Write(); > > That was a typo. I actually meant to do: > testMap->Write("TestMap", TObject::kSingleKey); > because I had already tried the approach you suggested, and got/get the > following problem: > > root [0] TFile* hfile = new TFile("test.root","RECREATE"); > root [1] TExMap* testMap = new TExMap(); > root [2] testMap->Add(1,2); > root [3] testMap->Add(2,56); > root [4] testMap->Add(3,256); > root [5] cout << (testMap->GetValue(2))<<endl;; > 56 > root [6] cout << (testMap->GetValue(1))<<endl;; > 2 > root [8] testMap->Write(); > root [9] hfile->Close(); > root [10] gROOT->Reset() > > Sure enough the TExMap appears to be added to the root file properly: > > root [14] TFile f("test.root") > root [15] f.ls() > TFile** test.root > TFile* test.root > KEY: TExMap TestMap;1 Map with external hash > > But I can't seem to "Get" it properly: > > root [12] TExMap *map = (TExMap*)f2.Get("TExMap"); > root [13] cout << (map->GetValue(2))<<endl;; > 0 > root [14] cout << (map->GetValue(1))<<endl;; > 0 > > i.e. it seems to be empty! > > Any help would be much appreciated! > > Cheers, > > Ed
This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:12 MET