Writing a user class to file [SOLVED]

Dear all,

i’m trying to write a class called CutFlowMap that inherits from TObject to a ROOT file.
This class has a private member of type map<int,string> that i fill run time.

I added the ClassDef macro and created a dictionary with linkdef.h as

#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;
#pragma link off all typedef;
#pragma link C++ class CutFlowMap;
#pragma link C++ class std::map<int, std::string >;
#pragma link C++ class std::map<int, std::string >::iterator;

then i tried writing it with both:

CutFlowMap->Write(“myname”)

or

outfile->WriteTObject(CutFlowMapPtr, “myname”)

In both cases i got no error messages and when i read back the ROOT file i can take
the pointer to my class and call its methods. But the internal map is EMPTY!
I printed it before writing the file and run time is filled correctly.

Any hint ?

thanks!
Max

i tried also with a private member of basic type. It’s always 0…

Max

Hi all,

i got the trick … from the manual …

I had ClassDef(CutFlowMap, 0) in my header file.

Reading the section “rootcint: The CINT Dictionary Generator” of chapter 15 i understood
that the “0” indeed means that the Streamer() method will not be created in the dictionary
so no data members read/write indeed. Putting “1” works nicely.

Bottom line, i should have red better that section but maybe also this point should be made more evident there or when the ClassDef macro is introduced. Of course if it’s not already done in another section that i still have to read carefully :wink:

best,
Max