Re: Custom streamer example

From: Vassili Maroussov <Vassili.Maroussov_at_cern.ch>
Date: Thu, 7 Oct 2010 15:17:36 +0200


Dear Rene and Axel,

thank you so much for your advices. I think the Rene's recipe (if you want a custom streamer, first take a look at the automatically generated one) should be in the "Streamers with Special Additions" chapter of the ROOT Users Guide . The recipe looks absolutely trivial... when you know it.

Regards,

Vassili

On 10/07/2010 12:50 PM, Rene Brun wrote:
> Hi Vassili,
>
> see example using the 2 files MyObject.h and MyLinkDef.h
> Note that the declaration of KLM must precede the declaration of the
> array.
>
> Run rootcint with
> rootcint -f MyDict.cxx -c MyObject.h MyLinkDef.h
>
> Extract MyObject::Streamer from MyDict.cxx and add the necessary lines
> computing your 2 pointers ArrL, ArrM after reading the main array.
>
> As a last step modify the MyLinkDef file replacing
> #pragma link C++ class MyObject;
> by
> #pragma link C++ class MyObject-;
>
>
> Rene Brun
>
> Maroussov wrote:
>> 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 - 15:17:40 CEST

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