Re: [ROOT] I/O on STL vector derived class?

From: Pasha Murat (630)840-8237 FNAL (630)859-3463 home (murat@murat.fnal.gov)
Date: Fri Nov 02 2001 - 21:02:59 MET


Hi Robert, 

I'm sure that you know well that the mechanism of
C++ templates and the mechanism of overloaded virtual functions, both provided 
by C++, are pretty much complementary, and in principle, one can live more or less 
happily using only one technique out of 2. One certainly can also combine both.
However one of the best and most attractive features of ROOT - full integration 
of C++ interpreter into the environment - from my [very pragmatic] point of view 
strongly favors the second  approach: interpreting templated code is a real 
challenge and I believe that it is quite easy for everybody to write a templated 
class which Masa would then see in his nightmare dreams every night for many 
years... -:)
	So as a user, I'd weigh the advantages of having the pleasure of writing out 
the AlternativeList's versus the pleasure of having fully interactive access to 
the code and data without pushing the envelope of CINT's abilities - ROOT provides 
polymorfic containers which can be used instead of the templated ones without any 
loss of functionality. 
	Although I completely agree that pushing the envelope often leads 
to a progress,
						-best, Pasha


Robert Hatcher wrote:
> 
> Hi,
>   I've developed a class that derives from STL vector, ala:
> 
> #include <vector>
> #include "AltListItem.h"
> class AlternativeList : public vector<AltListItem*>
> {
> public:
>   // specialized methods, eg.
>   void   KeepTopChoices(UInt_t n=2, Bool_t keepOrder=false);
>   Bool_t CheckConsistency() const;
> 
>   // additional member variable access
>   Float_t         GetQualityFactor() const;
>   void            SetQualityFactor(Float_t quality);
> 
> protected:
>   Float_t         fQuality; // an overall evaluation of this collection
> }
> 
> What doesn't seem to work is I/O.  If I have a TObject derived class
> that has one of these as a member variable and I write it out to a
> file and then read it back in then the fQuality field is correctly
> restored but the vector itself is empty.  I know that I/O of vector
> objects themselves works, so what would it take to make this case of
> "Is A" work?
> 
> -robert
> 
> Robert W. Hatcher   | rhatcher@fnal.gov   650-840-3102
> FNAL CD/CP (MINOS)  | MS 220, PO Box 500, Batavia IL 60510



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:51:06 MET