Boost logo

Boost :

From: Christopher Kohlhoff (chris_at_[hidden])
Date: 2006-02-26 07:50:32


Hi,

--- stas garifulin <s.garifulin_at_[hidden]> wrote:
<snip>
> In other words i'm talking about some infrastructure like
> boost::iostreams but built on top of asio dispatcher. Async
> analogue of boost::iostreams which allows me to create async
> chains of filters in run-time. For example, it can be done
> with non-templated versions of functions async_read,
> async_write, handler parameter of this functions will have
> type like boost::function<void (asio::error, size_T)>. SSL
> class could be implemented as such async filter and would
> allow attaching at run-time.

Dynamic chaining of filters is something I consider beyond the
scope of asio. Of course, it could be implemented as a library
on top of asio.

However, I am planning to add virtual wrapper stream templates
that could be used to allow runtime polymorphism with streams.
It might look something like:

template <
  typename Const_Buffers,
  typename Mutable_Buffers,
  typename Handler>
class polymorphic_stream_base
{
public:
  virtual size_t read_some(const Mutable_Buffers& bufs) = 0;
  virtual void async_read_some(const Mutable_Buffers& bufs,
      Handler handler) = 0;
  virtual size_t write_some(const Const_Buffers& bufs) = 0;
  virtual void async_write_some(const Const_Buffers& bufs,
      Handler handler) = 0;
};

template <
  typename Stream,
  typename Const_Buffers,
  typename Mutable_Buffers,
  typename Handler>
class polymorphic_stream
  : public polymorphic_stream_base<...>
{
  ...
};

This might be used to accomplish the same sort of thing as you
describe.

Cheers,
Chris


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk