|
Boost : |
Subject: Re: [boost] [gsoc] Boost.Process done
From: Boris Schaeling (boris_at_[hidden])
Date: 2010-09-02 16:51:08
On Wed, 01 Sep 2010 17:27:11 +0200, Ilya Sokolov <ilyasokol_at_[hidden]>
wrote:
> On 01.09.2010 18:55, Ilya Sokolov wrote:
>> class stream // I don't like this name
>> {
>> public:
>> virtual ~stream() {};
>> // create_child() calls this method
>> virtual void create_parent_and_child_end(handle&, handle&);
>> };
>
> Another try:
>
> class stream
> {
> public:
> virtual ~stream() {};
> virtual void set_fileno(int);
> virtual std::pair<handle, handle> create_parent_and_child_end();
> };
>
> class inherit : public stream
> {
> public:
> void set_fileno(int);
> void create_parent_and_child_end(handle& pe, handle& ce)
> {
> handle pe;
> handle ce(GetStdHandle(DWORD(fileno_ - 10)));
> return std::make_pair(pe, ce);
> };
>
> private:
> int fileno_;
> };
>
> class context
> {
> public:
> context& stdin(stream s)
> {
> s.set_fileno(0);
> stdin_ = s;
> return *this;
> }
> ...
> };
Here's another idea: How about using boost::function<> in the context
class? Then stream behaviors don't need to be classes anymore, don't need
to be in a class hierarchy and don't need to be created on the heap and
stored in a boost::shared_ptr.
struct context
{
boost::function<std::pair<handle, handle> ()> stdin_behavior;
...
};
context ctx;
ctx.stdin_behavior = &behavior::pipe;
How does it look like?
Boris
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk