|
Boost : |
Subject: Re: [boost] [gsoc] Boost.Process done
From: Boris Schaeling (boris_at_[hidden])
Date: 2010-09-01 15:20:41
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;
> }
> ...
> };
Looking at your proposed stream class I'd call it now a factory class.
This makes sense to me and is even easier to explain (as many developers
should be familiar with that pattern). The factory method could be called
in create_child() making it possible to reuse contexts.
But why did you add set_fileno()? Do we need this method if we have
create_parent_and_child_end() already? The example looks like as if it's
only required by inherit and thus shouldn't be added to stream really?
Boris
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk