Boost logo

Boost Users :

From: Olaf Peter (ope-devel_at_[hidden])
Date: 2008-08-14 14:18:03


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<stdout_redirector>
make_stdout_redirector(EmbeddedPython& console) {

    std::auto_ptr<stdout_redirector> ptr(new stdout_redirector);

    *ptr.m_write_fn = boost.bind(EmbeddedPython::write, &console);

    return ptr;
}

or even:

static std::auto_ptr<stdout_redirector>
make_stdout_redirector(EmbeddedPython& console) {

    std::auto_ptr<stdout_redirector>
        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




Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net