Hi Rooters, I am helping to interface root to a calibration module in order to monitor and to analyze constants while they are taken. The constants of each subdetector are structured in memory as STL vectors of channels, which are very simple classes like: vector<channel*> cs(2000); class channel { public: channel() {}; ... usual stuff ... private: float _slope; float _error; } I would like to be able to "decorate" channel with TObject functionality to make it browsable, streamable etc, but I don't want to have channel to inherit directly from TObject (BTW I don't think this would help because, I understand, cint does not like STL vectors). So I decided to make a memory copy of my vector into a TClonesArray of a TObject-derived RChannel. The point is that, as I have many kinds of "channel" classes, I don't want to re-write by hand each "RChannel" class with all of its member data and functions. It seemed to me a perfect case to use multiple inheritance: TClonesArray *tcs = new TClonesArray("RChannel", cs.size()); class RChannel : public channel, public TObject { public: RChannel(){} RChannel(const RChannel &c):channel(c),TObject(c) {} RChannel(const channel &c):channel(c),TObject() {} ClassDef(RChannel,1) }; and this indeed works fine as long as I access channel data in RChannel from my program. So, I thought, I can now write out data to a root file... Unfortunately the root file turns out to be empty because rootcint just ignores the fact that RChannel is a channel and considers it as an empty TObject! There is no mention to the TChannel inherited data members (slope and error) anywhere in the rootcint-generated TChannelCint.cc/.h. In particular void RChannel::Streamer(TBuffer &R__b) { // Stream an object of class RChannel. if (R__b.IsReading()) { Version_t R__v = R__b.ReadVersion(); if (R__v) { } TObject::Streamer(R__b); } else { R__b.WriteVersion(RChannel::IsA()); TObject::Streamer(R__b); } } Is this a bug of rootcint or is it expected? And if so, can anybody suggest me another way to "decorate" an existing data class with TObject behaviour, short of having the existing class itself to inherit from TObject? Thanks and Ciao -- Paolo Calafiura ------------------------------------------------------------------- | Lawrence Berkeley National Lab | NERSC group | | MS 50E 124 | office 50E 1519 | | 1 Cyclotron Rd. | phone 1-510-486-6717 | | Berkeley, CA 94720 U.S. | fax 1-510-486-4004 | -------------------------------------------------------------------
This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:34:38 MET