Hi Anton, the example you gave looks simple but can quickly become quite complex, which makes an automatic solution to solve the problem tricky. Example 1: List1->Write(1); Object->ChangeObject(); List2->Write(1); what would you like to save in the second write? A reference to the object written by List1? But then List2 will not restore the object like it was at the time of writing. Example 2: List1->Write(1); file2->cd(); List2->Write(1); now the second list is written in another file. This file cannot be read without first reading the file containing List1. One could imagine using a special bit in TObject denoting the object to be written only once per session or per file. In that case we could keep track of the object in a hashtable like is done in TBuffer, but the implementation would be far from trivial (to cover all cases and order in which things are read). Cheers, Fons. Anton Fokin wrote: > > Well, yes, I knew this, and I know a bit how ROOT serialization works. So > what I have asked was a rather general question. It is a common situation > when several objects contain pointer data fields which may point to the same > object. The question is how to store and restore such configurations? ROOT > work nicely with "chain" containers and data structures like lists, b-trees, > etc. But how to serialize a randomly interconnected graph-like structure? > Perhaps it is not a ROOT question, but anyway. Any ideas? > > Best, > Anton > > -----Original Message----- > From: perev@rcf.rhic.bnl.gov [mailto:perev@rcf.rhic.bnl.gov]On Behalf Of > Victor Perevoztchikov > Sent: Monday, January 31, 2000 5:27 PM > To: Anton Fokin > Cc: roottalk@pcroot.cern.ch > Subject: Re: How to stream this? > > Hi Anton, > > > List1->Write(1); > > List2->Write(1); > > > here you asked to write twice. Of course if you asked it, > it will be twice. I told that in ONE ROOT record no repetition. > > > would not Object be written twice? What happens if I read these two lists > > back? Will I get one or two different Objects? > > Yes, here you will have 2 same object. But it is not a ROOT problem. > The same will be in ZEBRA or in any other system. > Anton Fokin wrote: > > > > Hi Viktor, > > > > Well, if I do for example > > > > TList* List1 = new TList(); > > TList* List2 = new TList(); > > > > TObject *Object = new TObject(); > > > > List1->AddLast(Object); > > List2->AddLast(Object); > > > > List1->Write(1); > > List2->Write(1); > > > > would not Object be written twice? What happens if I read these two lists > > back? Will I get one or two different Objects? > > > > Best, > > Anton > > > > -----Original Message----- > > From: perev@rcf.rhic.bnl.gov [mailto:perev@rcf.rhic.bnl.gov]On Behalf Of > > Victor Perevoztchikov > > Sent: Monday, January 31, 2000 3:26 PM > > To: Anton Fokin > > Cc: roottalk@pcroot.cern.ch > > Subject: Re: How to stream this? > > > > Hi Anton, > > > I will get two copies of Obj. I could not find a solution except writing > a > > > > ROOT I/O does not write the same object twice. Probably you did something > in > > non standard way. > > Show please your example how do you write. > > > > Victor > > > > Anton Fokin wrote: > > > > > > Hi, > > > > > > I would like to stream a structure like this > > > > > > Obj1 *--> Obj <--* Obj2 > > > > > > where Obj1 and Obj2 have pointers to the same object Obj. If I stream it > > in > > > a "normal" way, Obj1::Streamer() will invoke Streamer() of Obj and > > > Obj2::Streamer() will do the same. The same happens if I read it back, > > i.e. > > > I will get two copies of Obj. I could not find a solution except writing > a > > > numerical id instead of pointers and connecting object after reading. > Any > > > suggestions? > > > > > > Best, > > > Anton > > > > -- > > Victor M. Perevoztchikov perev@bnl.gov perev@vxcern.cern.ch > > Brookhaven National Laboratory MS 510A PO Box 5000 Upton NY 11973-5000 > > tel office : 631-344-7894; fax 631-344-4206; home 631-345-2690 > > -- > Victor M. Perevoztchikov perev@bnl.gov perev@vxcern.cern.ch > Brookhaven National Laboratory MS 510A PO Box 5000 Upton NY 11973-5000 > tel office : 631-344-7894; fax 631-344-4206; home 631-345-2690 -- Org: CERN, European Laboratory for Particle Physics. Mail: 1211 Geneve 23, Switzerland E-Mail: Fons.Rademakers@cern.ch Phone: +41 22 7679248 WWW: http://root.cern.ch/~rdm/ Fax: +41 22 7677910
This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:18 MET