Re: ClassDef version

From: Rene Brun (Rene.Brun@cern.ch)
Date: Thu Jul 01 1999 - 16:23:29 MEST


Hi Nick,
as you say, support for schema evolution is a key feature.
I understand your point below. You can already implement a Streamer
function
as you describe. The main problem is;
 Where do you keep all Streamer_Vx functions?
In the dictionary file generated by rootcint, we can only keep the
latest definition, by definition (called Streamer).
Note that rootcint has an option to generate only the Streamer function.
In your makefile system, you can implement a scheme to automatize this
process.
It may be a bit complex. I am a bit hesitating on this scheme.
I think it is important to expose to users the real differences between
the class versions. Having everything in one function gives a global
view
on the evolution. I may be wrong!

Rene Brun


Nick West wrote:
> 
> Hi Rene,
> 
> of course I understand why you write:-
> 
> > > I have a question about increasing the id of ClassDef ; I add members to
> > > a existing class
> > > but I want to be able to read older objects of this class. I understood
> > > that I have to modify the streamer function to take that into account in
> > > the Dictonary file. I have done that and all seems to work but is there
> > > a way to do that automatically (because in the make file I use, the
> > > dictonary file is automatically generated without the modification
> > > if(R__v>1){...}?
> > > Thanks a lot
> > > Olivier Meplan
> >
> > Hi Olivier,
> > By definition, this process cannot be automatized.
> > You should follow the following steps:
> >   - Increase class version in ClassDef
> >   - Take a copy of your old Streamer in the dictionary and add this
> >     function in your class implementation.
> >   - Modify your Linkdef.h file to add the symbol "-" after the class
> > name
> >     This instructs rootcint to not generate the Streamer function.
> >   - run rootcint with the new Linkdef.
> 
> but this is a problem that is going to hit a lot of people.  Schema evolution is
> essential, many structures change over the lifetime of an experiment, but the
> price to be paid is to take control and loose all the power of CINT to build
> streamer methods.  How about if we were to adopt a convention that old
> Streamer methods were renamed with a postfix of the version number?  So, CINT
> builds:-
> 
>   void MyClass::Streamer(TBuffer &R__b)
> 
> for version 1.  When we move to version 2 we manually rename this to:-
> 
>   void MyClass::Streamer_v1(TBuffer &R__b)
> 
> the linkdef.h option is extended to offer 2 choices:-
> 
>   1)   No streamer generation
>   2)   Backward support generation
> 
> in the second case the code for any version greater than 1 looks like this:-
> 
>    Version_t R__v = R__b.ReadVersion();
>    if (R__v==1) {
>     Streamer_v1(R__b);
>     return;
>    } else if (R__v==2) {
>     Streamer_v2(R__b);
>     return;
>    } else if (R__v==3) {
>     Streamer_v2(R__b);
>     return;
>    }
> 
>    etc.
> 
> that covers all old cases.  Of course that is not always going to work, but if
> the MyClass ctor properly initialises everything at least everything is in a
> well defined state.  At the very least this allows people to have the streamer
> generated for the latest version and gives them a starting point to patch up
> old versions.
> 
> Cheers,
> 
> Nick.



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:35 MET