senf::WriteHelper< Handle > Class Template Reference

Asynchronous writing helper. More...

#include <senf/Scheduler/WriteHelper.hh>

Inheritance diagram for senf::WriteHelper< Handle >:
Inheritance graph
[legend]

List of all members.


Detailed Description

template<class Handle>
class senf::WriteHelper< Handle >

Asynchronous writing helper.

This class provides a simple asynchronous writing facility. This helper will register with the Scheduler to write the requested data. It will stay registered until the data has been completely sent or some error condition is encountered. As soon as the WriteHelper is done, the callback will be called.

The WriteHelper accepts the same flexible file handle interfaces as the Scheduler.

The callback must take a WriteHelper::ptr argument. Using this WriteHelper instance, the callback can access the state information and check the termination status.

Todo:
Add additional interface to better access the intermediate status (data sent so far)

Definition at line 54 of file WriteHelper.hh.


Public Types

typedef boost::intrusive_ptr
< WriteHelper
ptr
  Smart pointer type for this class.
typedef boost::function< void(ptr)>  Callback
  Callback type.

Public Member Functions

Handle  handle () const
std::string const &  data () const
  Return the data.
bool  complete () const
  Check whether the write has completed successfully.
bool  error () const
  Check for error condition.
void  throw_error () const
  If an error occurred, throw it.
void  revoke ()
  Remove the WriteHelper from the scheduler.

Structors and default members

static ptr  dispatch (Handle handle, std::string const &data, Callback callback)
  Register new WriteHelper instance.

Member Typedef Documentation

template<class Handle>
typedef boost::function<void (ptr)> senf::WriteHelper< Handle >::
Callback

Callback type.

Definition at line 62 of file WriteHelper.hh.

template<class Handle>
typedef boost::intrusive_ptr<WriteHelper> senf::WriteHelper< Handle >::
ptr

Smart pointer type for this class.

Definition at line 61 of file WriteHelper.hh.


Member Function Documentation

template<class Handle >
bool senf::WriteHelper< Handle >::
complete ()

Check whether the write has completed successfully.

Definition at line 47 of file WriteHelper.cti.

template<class Handle >
std::string const & senf::WriteHelper< Handle >::
data ()

Return the data.

After all data has been sent, this member will return an empty string. Until then, the complete string will be returned.

Definition at line 43 of file WriteHelper.ct.

template<class Handle>
senf::WriteHelper< Handle >::ptr senf::WriteHelper< Handle >::
dispatch ( Handle  handle,
std::string const &  data,
Callback  callback )

Register new WriteHelper instance.

The registered callback will be called after all data has been sent or when some error condition is encountered.

Parameters:
[in]  handle  file descriptor or handle providing the Handle interface defined above.
[in]  data  data to send
[in]  callback  callback
Returns:
smart pointer to new WriteHelper instance

Definition at line 34 of file WriteHelper.cti.

template<class Handle >
bool senf::WriteHelper< Handle >::
error ()

Check for error condition.

Definition at line 54 of file WriteHelper.cti.

template<class Handle >
Handle senf::WriteHelper< Handle >::
handle ()

Definition at line 40 of file WriteHelper.cti.

template<class Handle >
void senf::WriteHelper< Handle >::
revoke ()

Remove the WriteHelper from the scheduler.

Definition at line 54 of file WriteHelper.ct.

template<class Handle >
void senf::WriteHelper< Handle >::
throw_error ()

If an error occurred, throw it.

Definition at line 61 of file WriteHelper.cti.


The documentation for this class was generated from the following files: