Hi Thomas,
if you used purely generated streamers it is very likely that the
automatic schema evolution streamers will be able to read the old files.
Just try it. Add a + in the linkdef behind the class name and try to
read some old files. If this fails, or if your classes were written via
a custom streamer, do:
- in LinkDef.h add '-' behind class name (you want to use a custom
streamer)
- cut and paste the Streamer() code from the dictionary file and place
it in your class implementation file
- in the Streamer() add code like this:
//______________________________________________________________________________
void TH3::Streamer(TBuffer &R__b)
{
// Stream an object of class TH3.
if (R__b.IsReading()) {
UInt_t R__s, R__c;
Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
if (R__v > 2) { // use now automatic schema evolution
TH3::Class()->ReadBuffer(R__b, this, R__v, R__s, R__c);
return;
}
//====process old versions before automatic schema evolution
TH1::Streamer(R__b);
TAtt3D::Streamer(R__b);
R__b.CheckByteCount(R__s, R__c, TH3::IsA());
//====end of old versions
} else {
TH3::Class()->WriteBuffer(R__b,this); // write with new mechanism
}
}
notice the Class()->ReadBuffer() and Class()->WriteBuffer().
Cheers, Fons.
On Wed, 2002-03-06 at 13:57, Thomas Bretz wrote:
> Hi Rene,
>
> let's clarify the situation a bit more:
> We introduced the class using root 2.25/? without any '+' or '-' or
> similar in the LinkDef file. And we produced some files. Then we moved
> to root 3.02/06 again without any additional sign in the LinkDef file,
> and we produced again some files and were able to read the old created
> files. Now we want first to 'add the plus in the LinkDef file' and in
> the future we may want to change the class definition (eg. adding a new
> data member). What do we have to do when we want still to be able to
> read the old created files. Is it enough to add the '+' or may this
> result in some incompatibilities?
>
> Thomas.
>
> > Clarification. The text in the documentation that you are quoting refers
> > to the process of moving from old Root versions to the version 3.
> > If you had always been using the option "+" in LinkDef.h, things should be
> > totally automatic and schema evolution is supported by default.
> > As soon as version 3 is used with option "+", Root I/O will be able to
> > read evolutive versions of your classes automatically.
> >
> > > from: http://root.cern.ch/root/SchemaEvolution.html
> > > ------------------------
> > > How to use the new system
> > >
> > > We will distinguish the following cases:
> > >
> > > Case A: You have your own Streamer function in your class
> > > implementation
> > > [...]
> > > Case B: You use the automatic streamer in the dictionary file.
> > > Move the old Streamer from the file generated by rootcint to
> > > your class implementation file, then modified the Streamer
> > > function as in case A above.
> > > Increment your class version id in ClassDef by 1, eg.
> > > ClassDef(MyClass, 2)
> > > Add option "-" in the pragma line of LinkDef.
> > > Case C: You use the automatic streamer in the dictionary file and
> > > you
> > > already use the option "+" in the LinkDef file. If the old
> > > automatic Streamer does not contain any statement using the
> > > functions ReadArray, ReadStaticArray, WriteArray,
> > > WriteStaticArray you have nothing to do, except running rootcint
> > > again to regenerate the new form of the Streamer function,
> > > otherwise proceed like for case B.
> > > -------------------------
> > >
> > > In our case we have classes with some basic data types (Float_t, Int_t,
> > > etc.) and some fixed size arrays (Float_t[16], ...) without an own
> > > streamer. Someone made a test (with root 3.02/06) and found out: that if
> > > we compile a writing version of the program and a reading one, both
> > > versions once with auto scheme evolution enabled ('+' added in the
> > > LinkDef file) and without it: both readers can read both files without
> > > any further changes. Does this work by chance or did I missunderstood
> > > the stetement above.
> > >
> > > Best regards,
> > > Thomas.
> > >
--
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 7679480
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:44 MET