Custom streamer example

From: Vassili Maroussov <Vassili.Maroussov_at_cern.ch>
Date: Thu, 7 Oct 2010 12:22:39 +0200


Dear ROOTers,

my object contains several dynamically allocated arrays of the same simple type like:

class MyObject : public TObject {
...

    double *ArrK; //[K]
    double *ArrL; //[L]
    double *ArrM; //[M]

...

};

In order to decrease the number of time-consuming new/delete I'd like to have the constructor and destructor like

MyObject::MyObject(int K, int L, int M) {
...

    ArrK = new double [K+L+M]; //Continuous space ArrL = ArrK+K; //for all arrays ArrM = ArrL+L;
...

}

MyObject::~MyObject() {
...

    delete [] ArrK; //Single delete for all
...

}

But then I cannot use the nice feature of rootcint, the automatic streamer generation, since rootcint doesn't accept expressions like //[K+L+M] (is it still correct for rootcint7 ?). Could you please recommend a good simple example of the custom streamer in the ROOT source tree (the Event.h mentioned in the "Streamers with Special Additions" chapter of the ROOT Users Guide 5.26 actually uses an automatically generated streamer)?

Regards,

Vassili Received on Thu Oct 07 2010 - 12:22:50 CEST

This archive was generated by hypermail 2.2.0 : Thu Oct 07 2010 - 17:50:01 CEST