Hi Carlos,
The requirement that fSize has to be a member of the class has been lifted in
version 3.04. fSize can be in a base class with the latest versions.
Rene Brun
Carlos Muņoz Camacho wrote:
>
> Hi,
>
> I have a class similar to Event.h with an array of Float_t as a member.
> I want the dimension of the array to be a non-const parameter (as it will
> be read from an input file). The parameter is a static member of an
> inherited class, but this can change. The important thing is I don't want
> to hardcode the value of the parameter, because it is read from a file.
>
> The solution I found in the documentation is to allocate it dynamically
> via a pointer and tell the streamer the size of the array in the
> commentary field : //[fSize] . However, fSize needs to be a data member of
> the class. Obviously, I don't want to save this data member to file
> because it is constant for all the events. If I use fSize //! to avoid
> writing it, I get an Error in <TStreamerInfo::Build>. Below is a short
> example which reproduces the problem.
>
> Is there a way around this?
>
> ROOT 3.03/08 on a RH 7.2
>
> File: class.C
> ______________________________________________________
>
> #include "TObject.h"
>
> class TEvent : public TObject {
>
> private :
>
> Int_t fSize; //!
> Float_t* fBlocks; //[fSize]
>
> ClassDef(TEvent,1)
>
> };
> _______________________________________________
>
> Result:
>
> CINT/ROOT C/C++ Interpreter version 5.15.53, Aug 15 2002
> Type ? for help. Commands must be C++ statements.
> Enclose multiple statements between { }.
> root [0] .L class.C+
> Info in <TUnixSystem::ACLiC>: creating shared library
> /dsm/phnpcd232/local/home/cmunoz/./class_C.so
> root [1] TEvent *ev=new TEvent();
> root [2] TTree t("t","My tree");
> root [3] t.Branch("event","TEvent",&ev,16000,99);
> Error in <TStreamerInfo::Build>: TEvent, discarding: Float_t* fBlocks,
> illegal [fSize]
>
> Carlos Munoz Camacho
> SPhN/CEA-Saclay
This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:09 MET