Here is my problem. I am supposed to make a python code able to fill a C++ vector of pointer on object of a class of the c++ code. I am using Boost::Python. It's look as follow:
C++ code:
class A_Base {}
class A_derived_1 {}
...
class A_derived_N {}
class B {
...
setAderivediList(vector<A *> &_AderivedList){}
}
What I need to do in Python:
B.setAderivediList(_AderivedList)
I cannot modified the method in the C++ code, I can only add other objects in-between #ifdef python_interface in order not to impact other developpers work. At first, I tried to write a converter from what I found on the Internet, but I failed to make it works for my code. Then I tried to add a _AderivedList in class B and a setter which fill the vector. Though it compile in C++, it dosen't work in Python.
New B class:
class B {
...
setAderivediList(vector<A *> &_AderivedList){}
#ifdef myPython_code
public:
vector<A *> * _AderivedListPy;
setAListPy(A * &my_Aderived){ //Actually, I tried without the reference as well
this->_AderivedListPy->push_back(my_Aderived);
};
#endif
}
In python it becomes:
myB = mydll.B()
Ai = mydll.A_derived_i()
myB.setAListPy(Ai) #stopping here
myB.setAderivediList(myB._AderivedListPy)
If I use the reference, it will throw a "python argument types did not match C++ signature" error message at myB.setAListPy(Ai), without the reference, it will stop at the same line without throwing any error message. Any clue of how I could improve this or any other way to do it? Thank you in advance.