Re: Custom streamer example

From: Axel Naumann <Axel.Naumann_at_cern.ch>
Date: Thu, 7 Oct 2010 12:41:18 +0200


Hi,

why don't you simply do

double *ArrKLM; //[KLM]
int KLM
int K;
int L;

double *GetK() { return ArrKLM; }
double *GetL() { return ArrKLM + K; }
double *GetM() { return ArrKML + K + L; }

Cheers, Axel.

Vassili Maroussov wrote on 10/07/2010 12:22 PM:
> 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:41:21 CEST

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