[ROOT] STL and ROOT classes

From: Heather Kelly (heather@lheapop.gsfc.nasa.gov)
Date: Fri Apr 05 2002 - 16:38:55 MEST


Hi,

I know this is just my ignorance... but I am trying to include a map inside
a ROOT class and I am running into trouble.  My search through roottalk has
not provided me with enough details...seeing a full example would probably
solve my problem - so if someone has some code they are willing to share -
it would be greatly appreciated.

I am using Root 3.02.07 on Windows.

I have a class, which contains a map:

class MyClass: public TObject {
    
public:    
    MyClass();
    
    ~MyClass();
 
private:
    std::map<McParticle*,Double_t> m_energyItem;
    
    ClassDef(MyClass,1)
};

Where McParticle is itself a class derived from TObject.

In my MyLinkDef.h file I have:

#ifdef __CINT__

#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;

#pragma link C++ class McParticle+;
#pragma link C++ class map<McParticle*, Double_t>-!;
#pragma link C++ class MyClass+;

#endif


Right now I get compiler errors, starting with:
mcRootDataCint.h(62) : error C2143: syntax error : missing ';' before '<'
for this line:
/* STUB derived class for protected member access */
typedef map<McParticle*,double,less<McParticle*>,allocator<double> >
G__maplEMcParticlemUcOdoublecOlesslEMcParticlemUgRcOallocatorlEdoublegRsPgR;


Some questions:
Would it be better to use double, rather than Double_t as the second type
in the map?  Does it matter?

In the pragma statement, of the MyLinkDef.h file, I used "-!", per an
example I saw in an old roottalk message...  I also tried "!".  It seems to
me that I should allow the Streamer() method to be generated - as I thought
it was no longer necessary to write your own streamer for relatively simple
STL classes.  Am I correct in assuming that it is not possible to use "+"
with an STL class?

Do I need to add anything else to the MyLinkDef.h file to make this work?

Is it possible to use a typedef in my ROOT class to create more simple name
for the map?  Will that cause trouble for rootcint?  Originally, I was
using such a typedef, but removed it once I started to have trouble.

Is there something I can read to tell me how to do this correctly?

Thank you,
Heather



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:48 MET