I'm using boost python to create a binding to a c++ library. A number of classes in this library have virtual methods which accept iterator/const_iterator types as arguments. I don't particularly want to expose these types but would prefer to create some wrappers around these virtual methods that accept the appropriate container instead. My question is, is it safe to do this wrapping in the 'default implementation' function ?
e.g.
class Test
{
public:
Test();
virtual ~Test();
virtual void iterate(std::vector<int>::iterator it);
};
then with the wrapper class wrap the default..
struct Test_wrapper: Test, boost::python::wrapper<Test>
{
.....
virtual void iterate(std::vector<int>::iterator it);
void default_iterate(std::vector<int> it)
{
Test::iterate(it.begin());
}
};
and setting up the binding with...
boost::python::class_< Test_wrapper >("Test")
.def("iterate" ,(void ( Test_wrapper::* )(std::vector<int>))(&Test_wrapper::default_iterate));
I'm unsure about this because the tutorial says that two functions need to be passed to 'def' but just passing one seems to work.. (http://www.boost.org/doc/libs/1_43_0/libs/python/doc/tutorial/doc/html/python/exposing.html#python.class_virtual_functions)
Any advice with this would be greatly appreciated.
thanks in advance,
Babak
Edit:
More specifically I'm trying to bind a class which contains a method 'voxelToWorld'. This method transforms the positions in wsP based on points in vsP/end. I would like to wrap this function up so that its interface is more 'pythonic', however I'm not sure of the correct way to do this while kepping it virtual as well.
class FieldMapping
{
public:
...
virtual void voxelToWorld(std::vector<V3d>::const_iterator vsP,
std::vector<V3d>::const_iterator end,
std::vector<V3d>::iterator wsP);
};