\hypertarget{classAsyncFileOperator}{
\section{AsyncFileOperator Class Reference}
\label{classAsyncFileOperator}\index{AsyncFileOperator@{AsyncFileOperator}}
}


Base class for asynchronous file transfer operations.  




{\ttfamily \#include $<$asyncio.hh$>$}

Inheritance diagram for AsyncFileOperator:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[height=2.000000cm]{classAsyncFileOperator}
\end{center}
\end{figure}
\subsection*{Public Types}
\begin{DoxyCompactItemize}
\item 
enum {\bfseries Event} \{ \par
{\bfseries DATA} =  1, 
{\bfseries FLUSHING} =  2, 
{\bfseries OS\_\-ERROR} =  4, 
{\bfseries END\_\-OF\_\-FILE} =  8, 
\par
{\bfseries WOULDBLOCK} =  16
 \}
\item 
typedef XorpCallback4$<$ void, Event, const uint8\_\-t $\ast$, size\_\-t, size\_\-t $>$::RefPtr \hyperlink{classAsyncFileOperator_a12e626e2da12221a9f4333df89ad9ffe}{Callback}
\begin{DoxyCompactList}\small\item\em Callback type user provides when adding buffers to sub-\/classes \hyperlink{classAsyncFileOperator}{AsyncFileOperator}. \item\end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
virtual size\_\-t \hyperlink{classAsyncFileOperator_a3fc1507061761564f4451d62cdb374a8}{buffers\_\-remaining} () const =0
\item 
\hypertarget{classAsyncFileOperator_a2dbea848519e130b8ac77a118c0fe4af}{
virtual void \hyperlink{classAsyncFileOperator_a2dbea848519e130b8ac77a118c0fe4af}{flush\_\-buffers} ()=0}
\label{classAsyncFileOperator_a2dbea848519e130b8ac77a118c0fe4af}

\begin{DoxyCompactList}\small\item\em Stop asynchronous operation and clear list of buffers. \item\end{DoxyCompactList}\item 
virtual bool \hyperlink{classAsyncFileOperator_a3778390e8288097d3569833418d0728b}{start} ()=0
\begin{DoxyCompactList}\small\item\em Start asynchronous operation. \item\end{DoxyCompactList}\item 
\hypertarget{classAsyncFileOperator_adab2ca2a369e1c08ed8cca2e4b5815d2}{
virtual void \hyperlink{classAsyncFileOperator_adab2ca2a369e1c08ed8cca2e4b5815d2}{stop} ()=0}
\label{classAsyncFileOperator_adab2ca2a369e1c08ed8cca2e4b5815d2}

\begin{DoxyCompactList}\small\item\em Stop asynchronous operation. \item\end{DoxyCompactList}\item 
bool \hyperlink{classAsyncFileOperator_a48af814d6d55a099f1749365d4521cd7}{resume} ()
\begin{DoxyCompactList}\small\item\em Resume stopped asynchronous operation. \item\end{DoxyCompactList}\item 
bool \hyperlink{classAsyncFileOperator_a79df6f390f4ee72f43e884e60fc60b2e}{running} () const 
\item 
\hyperlink{classXorpFd}{XorpFd} \hyperlink{classAsyncFileOperator_afd41fea013fcb1e2975d28b7298f05dc}{fd} () const 
\item 
int \hyperlink{classAsyncFileOperator_a6409ba4eb048bf198ebaa2130a6af5a5}{error} () const 
\item 
\hypertarget{classAsyncFileOperator_acb405b1e8eb56dc98f683b606dcd3112}{
virtual string {\bfseries toString} () const }
\label{classAsyncFileOperator_acb405b1e8eb56dc98f683b606dcd3112}

\end{DoxyCompactItemize}
\subsection*{Protected Member Functions}
\begin{DoxyCompactItemize}
\item 
\hypertarget{classAsyncFileOperator_a2ebb480a4436aea3b598c0378d5792cd}{
{\bfseries AsyncFileOperator} (\hyperlink{classEventLoop}{EventLoop} \&e, \hyperlink{classXorpFd}{XorpFd} fd, int priority=XorpTask::PRIORITY\_\-DEFAULT)}
\label{classAsyncFileOperator_a2ebb480a4436aea3b598c0378d5792cd}

\end{DoxyCompactItemize}
\subsection*{Protected Attributes}
\begin{DoxyCompactItemize}
\item 
\hypertarget{classAsyncFileOperator_a2e4b2bf14ad937d4ecb6d36e9c94241b}{
\hyperlink{classEventLoop}{EventLoop} \& {\bfseries \_\-eventloop}}
\label{classAsyncFileOperator_a2e4b2bf14ad937d4ecb6d36e9c94241b}

\item 
\hypertarget{classAsyncFileOperator_a4ca7a9bb5290cef7e9b2ff12012f330b}{
\hyperlink{classXorpFd}{XorpFd} {\bfseries \_\-fd}}
\label{classAsyncFileOperator_a4ca7a9bb5290cef7e9b2ff12012f330b}

\item 
\hypertarget{classAsyncFileOperator_aacfcbcc3146f3085231f1f2cb4326795}{
bool {\bfseries \_\-running}}
\label{classAsyncFileOperator_aacfcbcc3146f3085231f1f2cb4326795}

\item 
\hypertarget{classAsyncFileOperator_a9af2fbb9ba7aed7a260e6e30e622d83b}{
int {\bfseries \_\-last\_\-error}}
\label{classAsyncFileOperator_a9af2fbb9ba7aed7a260e6e30e622d83b}

\item 
\hypertarget{classAsyncFileOperator_a7538d9dc541f25b63628370d97e829f9}{
int {\bfseries \_\-priority}}
\label{classAsyncFileOperator_a7538d9dc541f25b63628370d97e829f9}

\end{DoxyCompactItemize}


\subsection{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 \hyperlink{protocolthe-p}{the} available buffers are exhausted. 

\subsection{Member Typedef Documentation}
\hypertarget{classAsyncFileOperator_a12e626e2da12221a9f4333df89ad9ffe}{
\index{AsyncFileOperator@{AsyncFileOperator}!Callback@{Callback}}
\index{Callback@{Callback}!AsyncFileOperator@{AsyncFileOperator}}
\subsubsection[{Callback}]{\setlength{\rightskip}{0pt plus 5cm}typedef XorpCallback4$<$void, Event, const uint8\_\-t$\ast$, size\_\-t, size\_\-t$>$::RefPtr {\bf AsyncFileOperator::Callback}}}
\label{classAsyncFileOperator_a12e626e2da12221a9f4333df89ad9ffe}


Callback type user provides when adding buffers to sub-\/classes \hyperlink{classAsyncFileOperator}{AsyncFileOperator}. 

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

Callback has arguments: ErrorCode e, uint8\_\-t$\ast$ buffer, size\_\-t buffer\_\-bytes, size\_\-t offset 

\subsection{Member Function Documentation}
\hypertarget{classAsyncFileOperator_a3fc1507061761564f4451d62cdb374a8}{
\index{AsyncFileOperator@{AsyncFileOperator}!buffers\_\-remaining@{buffers\_\-remaining}}
\index{buffers\_\-remaining@{buffers\_\-remaining}!AsyncFileOperator@{AsyncFileOperator}}
\subsubsection[{buffers\_\-remaining}]{\setlength{\rightskip}{0pt plus 5cm}virtual size\_\-t AsyncFileOperator::buffers\_\-remaining (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily  \mbox{[}pure virtual\mbox{]}}}}
\label{classAsyncFileOperator_a3fc1507061761564f4451d62cdb374a8}
\begin{DoxyReturn}{Returns}
\hyperlink{protocolthe-p}{the} number of buffers available. 
\end{DoxyReturn}


Implemented in \hyperlink{classAsyncFileReader_a62f5167b1bf13096a4a7509c9c45b4c8}{AsyncFileReader}, and \hyperlink{classAsyncFileWriter_ae3fb9be3ef862457a14fda48b58cea7b}{AsyncFileWriter}.

\hypertarget{classAsyncFileOperator_a6409ba4eb048bf198ebaa2130a6af5a5}{
\index{AsyncFileOperator@{AsyncFileOperator}!error@{error}}
\index{error@{error}!AsyncFileOperator@{AsyncFileOperator}}
\subsubsection[{error}]{\setlength{\rightskip}{0pt plus 5cm}int AsyncFileOperator::error (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}}
\label{classAsyncFileOperator_a6409ba4eb048bf198ebaa2130a6af5a5}
\begin{DoxyReturn}{Returns}
\hyperlink{protocolthe-p}{the} last error code returned by \hyperlink{protocolthe-p}{the} underlying OS. 
\end{DoxyReturn}
\hypertarget{classAsyncFileOperator_afd41fea013fcb1e2975d28b7298f05dc}{
\index{AsyncFileOperator@{AsyncFileOperator}!fd@{fd}}
\index{fd@{fd}!AsyncFileOperator@{AsyncFileOperator}}
\subsubsection[{fd}]{\setlength{\rightskip}{0pt plus 5cm}{\bf XorpFd} AsyncFileOperator::fd (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}}
\label{classAsyncFileOperator_afd41fea013fcb1e2975d28b7298f05dc}
\begin{DoxyReturn}{Returns}
file descriptor undergoing asynchronous operation. 
\end{DoxyReturn}
\hypertarget{classAsyncFileOperator_a48af814d6d55a099f1749365d4521cd7}{
\index{AsyncFileOperator@{AsyncFileOperator}!resume@{resume}}
\index{resume@{resume}!AsyncFileOperator@{AsyncFileOperator}}
\subsubsection[{resume}]{\setlength{\rightskip}{0pt plus 5cm}bool AsyncFileOperator::resume (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}}
\label{classAsyncFileOperator_a48af814d6d55a099f1749365d4521cd7}


Resume stopped asynchronous operation. 

\begin{DoxyReturn}{Returns}
true on success, false if no buffers are available. 
\end{DoxyReturn}
\hypertarget{classAsyncFileOperator_a79df6f390f4ee72f43e884e60fc60b2e}{
\index{AsyncFileOperator@{AsyncFileOperator}!running@{running}}
\index{running@{running}!AsyncFileOperator@{AsyncFileOperator}}
\subsubsection[{running}]{\setlength{\rightskip}{0pt plus 5cm}bool AsyncFileOperator::running (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}}
\label{classAsyncFileOperator_a79df6f390f4ee72f43e884e60fc60b2e}
\begin{DoxyReturn}{Returns}
true if asynchronous I/O is started. 
\end{DoxyReturn}
\hypertarget{classAsyncFileOperator_a3778390e8288097d3569833418d0728b}{
\index{AsyncFileOperator@{AsyncFileOperator}!start@{start}}
\index{start@{start}!AsyncFileOperator@{AsyncFileOperator}}
\subsubsection[{start}]{\setlength{\rightskip}{0pt plus 5cm}virtual bool AsyncFileOperator::start (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  \mbox{[}pure virtual\mbox{]}}}}
\label{classAsyncFileOperator_a3778390e8288097d3569833418d0728b}


Start asynchronous operation. 

\begin{DoxyReturn}{Returns}
true on success, false if no buffers are available. 
\end{DoxyReturn}


Implemented in \hyperlink{classAsyncFileReader_ae3a877c216a394f60e736213f0056837}{AsyncFileReader}, and \hyperlink{classAsyncFileWriter_ab6f927fca413e15ac677743499ac0d5e}{AsyncFileWriter}.



The documentation for this class was generated from the following files:\begin{DoxyCompactItemize}
\item 
/home/greearb/git/xorp.ct.github/xorp/libxorp/asyncio.hh\item 
/home/greearb/git/xorp.ct.github/xorp/libxorp/asyncio.cc\end{DoxyCompactItemize}
