Re: class version

From: Rene Brun (Rene.Brun@cern.ch)
Date: Fri Jun 19 1998 - 13:03:08 MEST


Piergiorgio Cerello wrote:
> 
> Dear Rooters,
> 
> concerning the ROOT extension with my own classes, I have a question.
> In case I change the data part of a class, as explained in the tutorial
> "Adding your own classes to ROOT", I must change the ClassVersionID in the
> header file.
> But then, if I recompile, can I still manage files written with the
> previous version?
> In other words, what happens if I try to read an old file with a library
> compiled with the new header file?
> Thanks in advance,
> 

The Class Version identifier (in ClassDef) can be used in
your class Streamer function to take into account different versions
of the same class. If you add/remove data members, you must modify
the Streamer function to take into account the changes.
Only the Read part of Streamer must be modified with statements like:
   if (R__v > 1) {
      R__b >> newdata;   // if you add a data member
   }

where R__v is the class version as specified in the ClassDef when
the class object was written to the file.

With this mechanism, you can always read your old files with
the latest version of your classes.

Rene Brun



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