$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-users] multi-type containers
From: László Marák (ujoimro_at_[hidden])
Date: 2009-04-16 07:11:13
Dear Boost Users,
I am getting started with boost.python. I want to port an image processing
library into python. My problem is, that I have several pixel types (like
int, float, etc.) which I'd love to handle in the same object by
downcasting. In c++ it's something like this:
class image {};
class float_image : image {
float * pixels; // or boost::array_ptr<float>
}
class int_image : image {
int * pixels; // or boost::array_ptr<int>
}
I can create the image object by:
image * A = new float_image()
image * B = new int_image()
Now I'd have a virtual functions
virtual float image::get_element()
virtual int image::get_element()
obviously this won't pass in c++, but in python it should pose no
difficulty, as python uses dynamic casting. Is there a manner to do this
with c++/boost/python?
thank you for considering,
Laszlo