Hi Brett,
in the example of collections (like you mention below) the reading is done
via:
inline TBuffer &operator>>(TBuffer &buf, const TObject *&obj)
{ obj = buf.ReadObject(0); return buf; }
as you can see this calls TBuffer::ReadObject(). ReadObject() will find as
first token for a new object its class identifier (either class name of
reference
to already read class name). Then it will do TClass::New() to create a new
object
of the correct class and next it will read the data members for the object by
calling the class' Streamer() method. Simple magic :-).
Cheers, Fons.
Brett Viren wrote:
>
> Valeri Fine (Faine) writes:
> >
> > You may provide a custom Registry::Streamer method for you class
> > That defines how to stream you objects from your container into ROOT buffer and how to recreate
> > your container back.
> >
> > You can use
> > http://root.cern.ch/root/htmldoc/src/TCollection.cxx.html#TCollection:Streamer
> >
> > as example.
> > Hope this helps.
>
> It does somewhat. I was thinking something like this must be
> necessary, but I am still confused about the following: In the
> b.IsReading() block of TCollection's Streamer (which I will need to
> mirror), one loops over the number of objects to input and there is
> code like:
>
> TObject* obj;
> //...
> loop {
> b >> obj;
> }
>
> If I write a RegistryItemXxx<T>:RegistryItem:TObject object in the
> ``IsWriting'' block, how will ROOT know to give me this full object
> back, when all I call is TObject's operator>>().
>
> I know that rootcint will generate an operator>>(TBuffer&,Class*&) for
> the Class it is run on. Is this somehow called durring ``b >> obj;''?
>
> Maybe this magic (using A.C. Clark's definition) is something
> fundamental (seperate from the complication of templates) about ROOT's
> I/O that I don't understand.
>
> Thanks,
> -Brett.
--
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:35 MET