Hello everyone,
I’m trying to import some c++ compiled class consisting of vector of pair of custom classes.
While this work in ROOT I can’t get it to work in pyROOT.
Here are more details :
My source :
[code]#include
#include
class AA {
public:
int a;
};
class BB {
public:
int a;
};
typedef std::vector< AA > vAA;
typedef std::pair<AA ,BB> pAB;
typedef std::vector< std::pair<AA ,BB> > vAB;
#ifdef MAKECINT
#pragma link C++ class vAA;
#pragma link C++ class pAB;
#pragma link C++ class vAB;
#endif
[/code]
I compile it with Aclic. Now here is my pyRoot sequence :
>>> gROOT.ProcessLine(".L vectorpair.C+")
0L
>>> pab = pAB()
>>> pab.first
<ROOT.AA object at 0x941d208>
>>> vab = vAB()
>>> vab
<ROOT.vector<pair<AA,BB> > object at 0x(nil)>
>>> vab.push_back(p)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'vAB' object has no attribute 'push_back'
>>> dir(vab)
['__class__', '__delattr__', '__dict__', '__doc__', '__eq__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__nonzero__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__', '__weakref__']
>>> dir(pab)
['__class__', '__delattr__', '__dict__', '__doc__', '__eq__', '__ge__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__init__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__nonzero__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__', '__weakref__', '_pair<AA,BB>____assign__', 'first', 'pair', 'second']
>>>
The exact equivalent in CINT works as expected (i.e vab has all the vector method recognized).
I’m working with ROOT 5.22.
Am I missing something specific to PyRoot ?
Cheers,
P.A.