BLOCXX_NAMESPACE::UnnamedPipe Class Reference

Abstract interface for an UnnamedPipe. More...

#include <UnnamedPipe.hpp>

Inheritance diagram for BLOCXX_NAMESPACE::UnnamedPipe:

BLOCXX_NAMESPACE::SelectableIFC BLOCXX_NAMESPACE::IOIFC BLOCXX_NAMESPACE::IntrusiveCountableBase BLOCXX_NAMESPACE::PosixUnnamedPipe List of all members.

Public Types

enum  EBlockingMode { E_NONBLOCKING, E_BLOCKING }
enum  EOpen { E_DONT_OPEN, E_OPEN }

Public Member Functions

virtual ~UnnamedPipe ()
int writeInt (int value)
 Write an int (native binary representation) to the pipe.
int writeString (const String &strData)
 Writes a String to the pipe.
int readInt (int *value)
 Reads an int (native binary representation) from the pipe.
int readString (String &strData)
 Reads a String from the pipe.
void setReadTimeout (int seconds)
 Sets the read timeout value.
int getReadTimeout ()
 Gets the read timeout value.
void setWriteTimeout (int seconds)
 Sets the write timeout value.
int getWriteTimeout ()
 Gets the write timeout value.
void setTimeouts (int seconds)
 Sets the read & write timeout values.
String readAll ()
 Read from the pipe and collect into a string, until the other end of the pipe is closed.
virtual void open ()=0
 Open the pipe.
virtual int close ()=0
 Close the pipe.
virtual bool isOpen () const =0
 Is the pipe open or closed?
virtual Select_t getWriteSelectObj () const =0
 Get a write select object.
virtual void setBlocking (EBlockingMode outputIsBlocking=E_BLOCKING)=0
 Set the pipe's blocking mode.

Static Public Member Functions

static UnnamedPipeRef createUnnamedPipe (EOpen doOpen=E_OPEN)
 Create an instance of the concrete class that implements the UnnamedPipe interface.

Protected Member Functions

 UnnamedPipe ()

Protected Attributes

int m_readTimeout
int m_writeTimeout

Detailed Description

Abstract interface for an UnnamedPipe.

Blocking is enabled by default.

Definition at line 56 of file UnnamedPipe.hpp.


Member Enumeration Documentation

enum BLOCXX_NAMESPACE::UnnamedPipe::EBlockingMode
 

Enumerator:
E_NONBLOCKING 
E_BLOCKING 

Definition at line 173 of file UnnamedPipe.hpp.

enum BLOCXX_NAMESPACE::UnnamedPipe::EOpen
 

Enumerator:
E_DONT_OPEN 
E_OPEN 

Definition at line 186 of file UnnamedPipe.hpp.


Constructor & Destructor Documentation

BLOCXX_NAMESPACE::UnnamedPipe::~UnnamedPipe  )  [virtual]
 

Definition at line 51 of file UnnamedPipe.cpp.

BLOCXX_NAMESPACE::UnnamedPipe::UnnamedPipe  )  [inline, protected]
 

Definition at line 199 of file UnnamedPipe.hpp.


Member Function Documentation

virtual int BLOCXX_NAMESPACE::UnnamedPipe::close  )  [pure virtual]
 

Close the pipe.

Returns:
-1 on error, 0 on success.

Implemented in BLOCXX_NAMESPACE::PosixUnnamedPipe.

UnnamedPipeRef BLOCXX_NAMESPACE::UnnamedPipe::createUnnamedPipe EOpen  doOpen = E_OPEN  )  [static]
 

Create an instance of the concrete class that implements the UnnamedPipe interface.

Parameters:
doOpen Open the pipe or not.

Definition at line 207 of file PosixUnnamedPipe.cpp.

Referenced by BLOCXX_NAMESPACE::Socket::createShutDownMechanism().

int BLOCXX_NAMESPACE::UnnamedPipe::getReadTimeout  )  [inline]
 

Gets the read timeout value.

If blocking is enabled this is the number of seconds a read operation will block. Exception safety: No-throw

Returns:
The read timeout.

Definition at line 118 of file UnnamedPipe.hpp.

virtual Select_t BLOCXX_NAMESPACE::UnnamedPipe::getWriteSelectObj  )  const [pure virtual]
 

Get a write select object.

Implemented in BLOCXX_NAMESPACE::PosixUnnamedPipe.

int BLOCXX_NAMESPACE::UnnamedPipe::getWriteTimeout  )  [inline]
 

Gets the write timeout value.

If blocking is enabled this is the number of seconds a write operation will block. Exception safety: No-throw

Returns:
seconds The write timeout.

Definition at line 132 of file UnnamedPipe.hpp.

virtual bool BLOCXX_NAMESPACE::UnnamedPipe::isOpen  )  const [pure virtual]
 

Is the pipe open or closed?

Implemented in BLOCXX_NAMESPACE::PosixUnnamedPipe.

virtual void BLOCXX_NAMESPACE::UnnamedPipe::open  )  [pure virtual]
 

Open the pipe.

Implemented in BLOCXX_NAMESPACE::PosixUnnamedPipe.

String BLOCXX_NAMESPACE::UnnamedPipe::readAll  ) 
 

Read from the pipe and collect into a string, until the other end of the pipe is closed.

Exception safety: Strong for the C++ instance. Fubared for the pipe. If an exception is thrown, the pipe won't be reset to it's pre-call state.

Exceptions:
IOException on error

Definition at line 99 of file UnnamedPipe.cpp.

References BLOCXX_NAMESPACE::IOIFC::read(), and BLOCXX_NAMESPACE::StringBuffer::releaseString().

int BLOCXX_NAMESPACE::UnnamedPipe::readInt int *  value  ) 
 

Reads an int (native binary representation) from the pipe.

If blocking is enabled, readInt() will block for up to getReadTimeout() seconds or forever if getReadTimeout() == -1. Exception safety: No-throw

Parameters:
value Out parameter where the read int will be stored.
Returns:
The number of bytes read, -1 on error, ETIMEDOUT on timeout.

Definition at line 74 of file UnnamedPipe.cpp.

References BLOCXX_NAMESPACE::IOIFC::read().

int BLOCXX_NAMESPACE::UnnamedPipe::readString String strData  ) 
 

Reads a String from the pipe.

If blocking is enabled, readInt() will block for up to getReadTimeout() seconds or forever if getReadTimeout() == -1. Exception safety: Strong for the C++ instance. Fubared for the pipe. If an exception is thrown, the pipe won't be reset to it's pre-call state.

Parameters:
strData Out parameter where the read int will be stored as string.
Returns:
The number of bytes read, -1 on error, ETIMEDOUT on timeout.
Exceptions:
std::bad_alloc 

Definition at line 80 of file UnnamedPipe.cpp.

References BLOCXX_NAMESPACE::String::E_TAKE_OWNERSHIP, BLOCXX_NAMESPACE::AutoPtrVec< X >::get(), and BLOCXX_NAMESPACE::AutoPtrVec< X >::release().

virtual void BLOCXX_NAMESPACE::UnnamedPipe::setBlocking EBlockingMode  outputIsBlocking = E_BLOCKING  )  [pure virtual]
 

Set the pipe's blocking mode.

Precondition: The pipe is open.

Parameters:
outputIsBlocking new blocking mode.

void BLOCXX_NAMESPACE::UnnamedPipe::setReadTimeout int  seconds  )  [inline]
 

Sets the read timeout value.

If blocking is enabled this is the number of seconds a read operation will block. Exception safety: No-throw

Parameters:
seconds The new read timeout.

Definition at line 111 of file UnnamedPipe.hpp.

void BLOCXX_NAMESPACE::UnnamedPipe::setTimeouts int  seconds  )  [inline]
 

Sets the read & write timeout values.

If blocking is enabled this is the number of seconds a read or write operation will block. Exception safety: No-throw

Parameters:
seconds The new timeout.

Definition at line 139 of file UnnamedPipe.hpp.

void BLOCXX_NAMESPACE::UnnamedPipe::setWriteTimeout int  seconds  )  [inline]
 

Sets the write timeout value.

If blocking is enabled this is the number of seconds a write operation will block. Exception safety: No-throw

Parameters:
seconds The new write timeout.

Definition at line 125 of file UnnamedPipe.hpp.

int BLOCXX_NAMESPACE::UnnamedPipe::writeInt int  value  ) 
 

Write an int (native binary representation) to the pipe.

If blocking is enabled, writeInt() will block for up to getWriteTimeout() seconds or forever if getWriteTimeout() == -1. Exception safety: No-throw

Parameters:
value The value to write.
Returns:
The number of bytes written, -1 on error, ETIMEDOUT on timeout.

Definition at line 56 of file UnnamedPipe.cpp.

References BLOCXX_NAMESPACE::IOIFC::write().

int BLOCXX_NAMESPACE::UnnamedPipe::writeString const String strData  ) 
 

Writes a String to the pipe.

This should be read from the other side by readString. If blocking is enabled, writeString() will block for up to getWriteTimeout() seconds or forever if getWriteTimeout() == -1. Exception safety: No-throw

Parameters:
strData The String to write.
Returns:
The number of bytes written, -1 on error, ETIMEDOUT on timeout.

Definition at line 62 of file UnnamedPipe.cpp.

References BLOCXX_NAMESPACE::String::c_str(), BLOCXX_NAMESPACE::String::length(), and BLOCXX_NAMESPACE::IOIFC::write().


Member Data Documentation

int BLOCXX_NAMESPACE::UnnamedPipe::m_readTimeout [protected]
 

Definition at line 202 of file UnnamedPipe.hpp.

Referenced by BLOCXX_NAMESPACE::PosixUnnamedPipe::read().

int BLOCXX_NAMESPACE::UnnamedPipe::m_writeTimeout [protected]
 

Definition at line 203 of file UnnamedPipe.hpp.

Referenced by BLOCXX_NAMESPACE::PosixUnnamedPipe::write().


The documentation for this class was generated from the following files:
Generated on Fri Jun 16 15:39:12 2006 for blocxx by  doxygen 1.4.6