|
Boost : |
From: Hamish Mackenzie (hamish_at_[hidden])
Date: 2002-11-28 05:30:54
On Wed, 2002-11-27 at 19:13, Boris Schäling wrote:
> I use std::string as a buffer which grows when needed. This is sufficient
> for what I do but may not what others need.
In that case you would be well catered for by.....
class buffered_observer : public observer
{
std::stringstream write_stream_;
protected:
std::ostream & out() { return write_stream_; }
public:
std::istream & write_stream()
{
return write_stream_;
}
};
Note: I am assuming that the multiplexor will not reenter the observer
on another thread during an on_xxx call
Now your example could become
class my_observer : public buffered_observer
{
public:
void on_connect()
{
...
out() << "Hello World" << std::flush;
}
};
I will take an ostream over writen any day.
-- Hamish Mackenzie <hamish_at_[hidden]>
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk