RE: How to stream this?

From: Anton Fokin (fokin@tsl.uu.se)
Date: Mon Jan 31 2000 - 18:03:04 MET


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



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:18 MET