Sophie

Sophie

distrib > Mandriva > 2007.0 > i586 > by-pkgid > ad1ba1135a9c9eeffc2e538163e00373 > files > 621

libCommonC++2_1.4-devel-1.4.1-1mdv2007.0.i586.rpm

\section{ost::Buffer Class Reference}
\label{classost_1_1_buffer}\index{ost::Buffer@{ost::Buffer}}
The buffer class represents an IPC service that is built upon a buffer of fixed capacity that can be used to transfer objects between one or more producer and consumer threads.Producer/Consumer buffer for use between threads.  


{\tt \#include $<$buffer.h$>$}

Inheritance diagram for ost::Buffer::\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[height=3cm]{classost_1_1_buffer}
\end{center}
\end{figure}
\subsection*{Public Member Functions}
\begin{CompactItemize}
\item 
{\bf Buffer} (size\_\-t capacity)
\begin{CompactList}\small\item\em Create a buffer object of known capacity. \item\end{CompactList}\item 
virtual {\bf $\sim$Buffer} ()
\begin{CompactList}\small\item\em In derived functions, may be used to free the actual memory used to hold buffered data. \item\end{CompactList}\item 
size\_\-t {\bf get\-Size} (void)
\begin{CompactList}\small\item\em Return the capacity of the buffer as specified at creation. \item\end{CompactList}\item 
size\_\-t {\bf get\-Used} (void)
\begin{CompactList}\small\item\em Return the current capacity in use for the buffer. \item\end{CompactList}\item 
size\_\-t {\bf wait} (void $\ast$buf, {\bf timeout\_\-t} {\bf timeout}=0)
\begin{CompactList}\small\item\em Let one or more threads wait for an object to become available in the buffer. \item\end{CompactList}\item 
size\_\-t {\bf post} (void $\ast$buf, {\bf timeout\_\-t} {\bf timeout}=0)
\begin{CompactList}\small\item\em Post an object into the buffer and enable a waiting thread to receive it. \item\end{CompactList}\item 
size\_\-t {\bf peek} (void $\ast$buf)
\begin{CompactList}\small\item\em Peek at the current content (first object) in the buffer. \item\end{CompactList}\item 
virtual bool {\bf is\-Valid} (void)
\begin{CompactList}\small\item\em New virtual to test if buffer is a valid object. \item\end{CompactList}\end{CompactItemize}
\subsection*{Static Public Attributes}
\begin{CompactItemize}
\item 
static const size\_\-t {\bf timeout}
\begin{CompactList}\small\item\em value to return when a timed operation returned with a timeout. \item\end{CompactList}\end{CompactItemize}
\subsection*{Protected Member Functions}
\begin{CompactItemize}
\item 
virtual size\_\-t {\bf on\-Peek} (void $\ast$buf)=0
\begin{CompactList}\small\item\em Invoke derived class buffer peeking method. \item\end{CompactList}\item 
virtual size\_\-t {\bf on\-Wait} (void $\ast$buf)=0
\begin{CompactList}\small\item\em Invoke derived class object request from buffer. \item\end{CompactList}\item 
virtual size\_\-t {\bf on\-Post} (void $\ast$buf)=0
\begin{CompactList}\small\item\em Invoke derived class posting of object to buffer. \item\end{CompactList}\end{CompactItemize}
\subsection*{Related Functions}
(Note that these are not member functions.) \begin{CompactItemize}
\item 
size\_\-t {\bf get} ({\bf Buffer} \&b, void $\ast$o, {\bf timeout\_\-t} t=0)
\item 
size\_\-t {\bf put} ({\bf Buffer} \&b, void $\ast$o, {\bf timeout\_\-t} t=0)
\item 
size\_\-t {\bf peek} ({\bf Buffer} \&b, void $\ast$o)
\end{CompactItemize}


\subsection{Detailed Description}
The buffer class represents an IPC service that is built upon a buffer of fixed capacity that can be used to transfer objects between one or more producer and consumer threads.Producer/Consumer buffer for use between threads. 

Producer threads post objects into the buffer, and consumer threads wait for and receive objects from the buffer. Semaphores are used to to block the buffer from overflowing and indicate when there is data available, and mutexes are used to protect multiple consumers and producer threads from stepping over each other.

The buffer class is an abstract class in that the actual data being buffered is not directly specified within the buffer class itself. The buffer class should be used as a base class for a class that actually impliments buffering and which may be aware of the data types actually are being buffered. A template class could be created based on buffer for this purpose. Another possibility is to create a class derived from both {\bf Thread}{\rm (p.\,\pageref{classost_1_1_thread})} and {\bf Buffer}{\rm (p.\,\pageref{classost_1_1_buffer})} which can be used to implement message passing threads.

\begin{Desc}
\item[Author:]David Sugar $<${\tt dyfet@ostel.com}$>$ \end{Desc}




\subsection{Constructor \& Destructor Documentation}
\index{ost::Buffer@{ost::Buffer}!Buffer@{Buffer}}
\index{Buffer@{Buffer}!ost::Buffer@{ost::Buffer}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}ost::Buffer::Buffer (size\_\-t {\em capacity})}\label{classost_1_1_buffer_facde25a803bcf18ed0fc2791fca525d}


Create a buffer object of known capacity. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em capacity}]is the integer capacity of the buffer. \end{description}
\end{Desc}
\index{ost::Buffer@{ost::Buffer}!~Buffer@{$\sim$Buffer}}
\index{~Buffer@{$\sim$Buffer}!ost::Buffer@{ost::Buffer}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}virtual ost::Buffer::$\sim$Buffer ()\hspace{0.3cm}{\tt  [virtual]}}\label{classost_1_1_buffer_ef3a7f472cebcdeca059e2618bf1879c}


In derived functions, may be used to free the actual memory used to hold buffered data. 



\subsection{Member Function Documentation}
\index{ost::Buffer@{ost::Buffer}!getSize@{getSize}}
\index{getSize@{getSize}!ost::Buffer@{ost::Buffer}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}size\_\-t ost::Buffer::get\-Size (void)\hspace{0.3cm}{\tt  [inline]}}\label{classost_1_1_buffer_edd8b294e02c08a60bde023bd2c1ff47}


Return the capacity of the buffer as specified at creation. 

\begin{Desc}
\item[Returns:]size of buffer. \end{Desc}
\index{ost::Buffer@{ost::Buffer}!getUsed@{getUsed}}
\index{getUsed@{getUsed}!ost::Buffer@{ost::Buffer}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}size\_\-t ost::Buffer::get\-Used (void)\hspace{0.3cm}{\tt  [inline]}}\label{classost_1_1_buffer_462525b42df6660894ccf8141d73071e}


Return the current capacity in use for the buffer. 

Free space is technically {\bf get\-Size()}{\rm (p.\,\pageref{classost_1_1_buffer_edd8b294e02c08a60bde023bd2c1ff47})} - {\bf get\-Used()}{\rm (p.\,\pageref{classost_1_1_buffer_462525b42df6660894ccf8141d73071e})}. \begin{Desc}
\item[Returns:]integer used capacity of the buffer. \end{Desc}
\begin{Desc}
\item[See also:]{\bf get\-Size}{\rm (p.\,\pageref{classost_1_1_buffer_edd8b294e02c08a60bde023bd2c1ff47})} \end{Desc}
\index{ost::Buffer@{ost::Buffer}!isValid@{isValid}}
\index{isValid@{isValid}!ost::Buffer@{ost::Buffer}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}virtual bool ost::Buffer::is\-Valid (void)\hspace{0.3cm}{\tt  [virtual]}}\label{classost_1_1_buffer_255237cf9eebf6010546e884933ff8ba}


New virtual to test if buffer is a valid object. 

\begin{Desc}
\item[Returns:]true if object is valid. \end{Desc}


Reimplemented in {\bf ost::Fixed\-Buffer} {\rm (p.\,\pageref{classost_1_1_fixed_buffer_0a374a1a50ae78ce64db9e4ab25991d2})}.\index{ost::Buffer@{ost::Buffer}!onPeek@{onPeek}}
\index{onPeek@{onPeek}!ost::Buffer@{ost::Buffer}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}virtual size\_\-t ost::Buffer::on\-Peek (void $\ast$ {\em buf})\hspace{0.3cm}{\tt  [protected, pure virtual]}}\label{classost_1_1_buffer_5879caf00bd75cd972d84b822cb77ef0}


Invoke derived class buffer peeking method. 

\begin{Desc}
\item[Returns:]size of object found. \end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em buf}]pointer to copy contents of head of buffer to. \end{description}
\end{Desc}


Implemented in {\bf ost::Fixed\-Buffer} {\rm (p.\,\pageref{classost_1_1_fixed_buffer_e0a0b8dcb25e97313de5b998e1f22bfd})}.\index{ost::Buffer@{ost::Buffer}!onPost@{onPost}}
\index{onPost@{onPost}!ost::Buffer@{ost::Buffer}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}virtual size\_\-t ost::Buffer::on\-Post (void $\ast$ {\em buf})\hspace{0.3cm}{\tt  [protected, pure virtual]}}\label{classost_1_1_buffer_7ee3158e74f0e50e91f14bf370feb1fa}


Invoke derived class posting of object to buffer. 

\begin{Desc}
\item[Returns:]size of object posted. \end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em buf}]pointer to object being posted to the buffer. \end{description}
\end{Desc}


Implemented in {\bf ost::Fixed\-Buffer} {\rm (p.\,\pageref{classost_1_1_fixed_buffer_5d39b3282dd4a18d79456f7f16962b35})}.\index{ost::Buffer@{ost::Buffer}!onWait@{onWait}}
\index{onWait@{onWait}!ost::Buffer@{ost::Buffer}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}virtual size\_\-t ost::Buffer::on\-Wait (void $\ast$ {\em buf})\hspace{0.3cm}{\tt  [protected, pure virtual]}}\label{classost_1_1_buffer_9662e8def92667057121de0847dcabf0}


Invoke derived class object request from buffer. 

\begin{Desc}
\item[Returns:]size of object returned. \end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em buf}]pointer to hold object returned from the buffer. \end{description}
\end{Desc}


Implemented in {\bf ost::Fixed\-Buffer} {\rm (p.\,\pageref{classost_1_1_fixed_buffer_8364661c1b2d2114d87be12479b04a47})}.\index{ost::Buffer@{ost::Buffer}!peek@{peek}}
\index{peek@{peek}!ost::Buffer@{ost::Buffer}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}size\_\-t ost::Buffer::peek (void $\ast$ {\em buf})}\label{classost_1_1_buffer_e613b6a13146b782ce5749b810cceba8}


Peek at the current content (first object) in the buffer. 

\begin{Desc}
\item[Returns:]size of object in the buffer. \end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em buf}]pointer to store object found in the buffer. \end{description}
\end{Desc}
\index{ost::Buffer@{ost::Buffer}!post@{post}}
\index{post@{post}!ost::Buffer@{ost::Buffer}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}size\_\-t ost::Buffer::post (void $\ast$ {\em buf}, {\bf timeout\_\-t} {\em timeout} = {\tt 0})}\label{classost_1_1_buffer_9d106bd44d9bee8d9ef049cfa264e5b7}


Post an object into the buffer and enable a waiting thread to receive it. 

\begin{Desc}
\item[Returns:]size of object posted in bytes. \end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em buf}]pointer to object to store in the buffer. \item[{\em timeout}]time to wait. \end{description}
\end{Desc}
\index{ost::Buffer@{ost::Buffer}!wait@{wait}}
\index{wait@{wait}!ost::Buffer@{ost::Buffer}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}size\_\-t ost::Buffer::wait (void $\ast$ {\em buf}, {\bf timeout\_\-t} {\em timeout} = {\tt 0})}\label{classost_1_1_buffer_5f67183f492fe6600456d919ed811fac}


Let one or more threads wait for an object to become available in the buffer. 

The waiting thread(s) will wait forever if no object is ever placed into the buffer.

\begin{Desc}
\item[Returns:]size of object passed by buffer in bytes. \end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em buf}]pointer to store object retrieved from the buffer. \item[{\em timeout}]time to wait. \end{description}
\end{Desc}


\subsection{Friends And Related Function Documentation}
\index{ost::Buffer@{ost::Buffer}!get@{get}}
\index{get@{get}!ost::Buffer@{ost::Buffer}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}size\_\-t get ({\bf Buffer} \& {\em b}, void $\ast$ {\em o}, {\bf timeout\_\-t} {\em t} = {\tt 0})\hspace{0.3cm}{\tt  [related]}}\label{classost_1_1_buffer_be2397b9087bd1651ee67ed5702c01dd}


\index{ost::Buffer@{ost::Buffer}!peek@{peek}}
\index{peek@{peek}!ost::Buffer@{ost::Buffer}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}size\_\-t peek ({\bf Buffer} \& {\em b}, void $\ast$ {\em o})\hspace{0.3cm}{\tt  [related]}}\label{classost_1_1_buffer_2066fdf67ab3b6727be90a51fc5c4d64}


\index{ost::Buffer@{ost::Buffer}!put@{put}}
\index{put@{put}!ost::Buffer@{ost::Buffer}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}size\_\-t put ({\bf Buffer} \& {\em b}, void $\ast$ {\em o}, {\bf timeout\_\-t} {\em t} = {\tt 0})\hspace{0.3cm}{\tt  [related]}}\label{classost_1_1_buffer_1dc4ad52b6f17817e4afa981d1db6fae}




\subsection{Member Data Documentation}
\index{ost::Buffer@{ost::Buffer}!timeout@{timeout}}
\index{timeout@{timeout}!ost::Buffer@{ost::Buffer}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}const size\_\-t {\bf ost::Buffer::timeout}\hspace{0.3cm}{\tt  [static]}}\label{classost_1_1_buffer_e416c78e4d5dc50bfa3c4e0b98fd7a98}


value to return when a timed operation returned with a timeout. 



The documentation for this class was generated from the following file:\begin{CompactItemize}
\item 
{\bf buffer.h}\end{CompactItemize}