Hi,
for my redirected output boost.python (bpl) program I like to set
special writing functions at construction time. The idea is to use a
boost.function for this, like (my won't work):
static std::auto_ptr
make_stdout_redirector(EmbeddedPython& console) {
std::auto_ptr ptr(new stdout_redirector);
*ptr.m_write_fn = boost.bind(EmbeddedPython::write, &console);
return ptr;
}
or even:
static std::auto_ptr
make_stdout_redirector(EmbeddedPython& console) {
std::auto_ptr
ptr(new stdout_redirector(boost.bind(EmbeddedPython::write,
&console)));
return ptr;
}
using the constructor, which would be different for that what python
would see (here comes my idea using bpl::make_constructor into play).
So each time my redirector is called, EmbeddedPython::write can call the
underlying (not seen here, std::cout used here for simplicity) write
instance.
The problem: I can not make those calls from boost.python's class_ ,
isn't it?
Any ideas for this? I don't want to use global variables.
Thanks,
Olaf