xorp

AsyncFileOperator Class Reference

Base class for asynchronous file transfer operations. More...

#include <asyncio.hh>

Inheritance diagram for AsyncFileOperator:
AsyncFileReader AsyncFileWriter

List of all members.

Public Types

enum  Event {
  DATA = 1, FLUSHING = 2, OS_ERROR = 4, END_OF_FILE = 8,
  WOULDBLOCK = 16
}
typedef XorpCallback4< void,
Event, const uint8_t *, size_t,
size_t >::RefPtr 
Callback
 Callback type user provides when adding buffers to sub-classes AsyncFileOperator.

Public Member Functions

virtual size_t buffers_remaining () const =0
virtual void flush_buffers ()=0
 Stop asynchronous operation and clear list of buffers.
virtual bool start ()=0
 Start asynchronous operation.
virtual void stop ()=0
 Stop asynchronous operation.
bool resume ()
 Resume stopped asynchronous operation.
bool running () const
XorpFd fd () const
int error () const
virtual string toString () const

Protected Member Functions

 AsyncFileOperator (EventLoop &e, XorpFd fd, int priority=XorpTask::PRIORITY_DEFAULT)

Protected Attributes

EventLoop_eventloop
XorpFd _fd
bool _running
int _last_error
int _priority

Detailed Description

Base class for asynchronous file transfer operations.

Asynchronous file transfer operations allow data to be transferred to or from user supplied buffers. A callback is invoked on each transfer. Transfer stops when the available buffers are exhausted.


Member Typedef Documentation

typedef XorpCallback4<void, Event, const uint8_t*, size_t, size_t>::RefPtr AsyncFileOperator::Callback

Callback type user provides when adding buffers to sub-classes AsyncFileOperator.

Callback's are on a per buffer basis and invoked any time some I/O is performed. The offset field refers to the offset of the last byte read, or written, from the start of the buffer.

Callback has arguments: ErrorCode e, uint8_t* buffer, size_t buffer_bytes, size_t offset


Member Function Documentation

virtual size_t AsyncFileOperator::buffers_remaining ( ) const [pure virtual]
Returns:
the number of buffers available.

Implemented in AsyncFileReader, and AsyncFileWriter.

int AsyncFileOperator::error ( ) const [inline]
Returns:
the last error code returned by the underlying OS.
XorpFd AsyncFileOperator::fd ( ) const [inline]
Returns:
file descriptor undergoing asynchronous operation.
bool AsyncFileOperator::resume ( ) [inline]

Resume stopped asynchronous operation.

Returns:
true on success, false if no buffers are available.
bool AsyncFileOperator::running ( ) const [inline]
Returns:
true if asynchronous I/O is started.
virtual bool AsyncFileOperator::start ( ) [pure virtual]

Start asynchronous operation.

Returns:
true on success, false if no buffers are available.

Implemented in AsyncFileReader, and AsyncFileWriter.


The documentation for this class was generated from the following files:
 All Classes Namespaces Functions Variables Typedefs Enumerations