|
blocxx
|
#include <PosixUnnamedPipe.hpp>
Public Member Functions | |
| PosixUnnamedPipe (EOpen doOpen=E_OPEN) | |
| PosixUnnamedPipe (AutoDescriptor inputfd, AutoDescriptor outputfd) | |
| If fd_in == -1, then you cannot read from this object. | |
| virtual | ~PosixUnnamedPipe () |
| virtual int | write (const void *data, int dataLen, ErrorAction errorAsException=E_RETURN_ON_ERROR) |
| Write a specified number of bytes to the device that is exposing the IOIFC interface. | |
| virtual int | read (void *buffer, int bufferLen, ErrorAction errorAsException=E_RETURN_ON_ERROR) |
| Read a specified number of bytes from the device that is exposing the IOIFC interface. | |
| Descriptor | getInputHandle () const |
| Descriptor | getOutputHandle () const |
| virtual void | open () |
| Open the pipe. | |
| virtual int | close () |
| Close the pipe. | |
| virtual bool | isOpen () const |
| Is the pipe open or closed? | |
| virtual int | closeInputHandle () |
| virtual int | closeOutputHandle () |
| virtual void | setBlocking (EBlockingMode outputIsBlocking=E_BLOCKING) |
| Set the pipe's blocking mode. | |
| virtual void | setWriteBlocking (EBlockingMode isBlocking=E_BLOCKING) |
| Set blocking mode for writing to pipe. | |
| virtual void | setReadBlocking (EBlockingMode isBlocking=E_BLOCKING) |
| Set blocking mode for reading from pipe. | |
| virtual EBlockingMode | getReadBlocking () const |
| Get the current blocking mode for reading from pipe. | |
| virtual EBlockingMode | getWriteBlocking () const |
| Get the current blocking mode for writing from pipe. | |
| virtual Select_t | getReadSelectObj () const |
| Get the read select object. | |
| virtual Select_t | getWriteSelectObj () const |
| Get the write select object. | |
| virtual Descriptor | getInputDescriptor () const |
| Get the underlying input descriptor. | |
| virtual Descriptor | getOutputDescriptor () const |
| Get the underlying output descriptor. | |
| virtual void | passDescriptor (Descriptor h, const UnnamedPipeRef &ackPipe=0, const ProcessRef &targetProcess=0) |
Sends a Descriptor to the peer. | |
| virtual AutoDescriptor | receiveDescriptor (const UnnamedPipeRef &ackPipe) |
Gets a Descriptor from the peer. | |
Public Member Functions inherited from BLOCXX_NAMESPACE::UnnamedPipe | |
| 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 (const Timeout &timeout) |
| Sets the read timeout value. | |
| BLOCXX_DEPRECATED void | setReadTimeout (int seconds) |
| Timeout | getReadTimeout () |
| Gets the read timeout value. | |
| void | setWriteTimeout (const Timeout &timeout) |
| Sets the write timeout value. | |
| BLOCXX_DEPRECATED void | setWriteTimeout (int seconds) |
| Timeout | getWriteTimeout () |
| Gets the write timeout value. | |
| void | setTimeouts (const Timeout &timeout) |
| Sets the read & write timeout values. | |
| BLOCXX_DEPRECATED void | setTimeouts (int seconds) |
| String | readAll () |
| Read from the pipe and collect into a string, until the other end of the pipe is closed. | |
Public Member Functions inherited from BLOCXX_NAMESPACE::IOIFC | |
| virtual | ~IOIFC () |
Private Member Functions | |
| PosixUnnamedPipe (const PosixUnnamedPipe &x) | |
| PosixUnnamedPipe & | operator= (const PosixUnnamedPipe &x) |
Private Attributes | |
| Descriptor | m_fds [2] |
| EBlockingMode | m_blocking [2] |
Additional Inherited Members | |
Public Types inherited from BLOCXX_NAMESPACE::UnnamedPipe | |
| enum | EBlockingMode { E_NONBLOCKING , E_BLOCKING } |
| enum | EOpen { E_DONT_OPEN , E_OPEN } |
Public Types inherited from BLOCXX_NAMESPACE::IOIFC | |
| enum | ErrorAction { E_THROW_ON_ERROR , E_RETURN_ON_ERROR } |
Static Public Member Functions inherited from BLOCXX_NAMESPACE::UnnamedPipe | |
| static UnnamedPipeRef | createUnnamedPipe (EOpen doOpen=E_OPEN) |
| Create an instance of the concrete class that implements the UnnamedPipe interface. | |
| static UnnamedPipeRef | createUnnamedPipeFromDescriptor (AutoDescriptor inputAndOutput) |
| Create an instance of the concrete class that implements the UnnamedPipe interface connected bidirectionally to the specified descriptor. | |
| static UnnamedPipeRef | createUnnamedPipeFromDescriptor (AutoDescriptor input, AutoDescriptor output) |
| Create an instance of the concrete class that implements the UnnamedPipe interface connected to the specified descriptors. | |
| static void | createConnectedPipes (UnnamedPipeRef &first, UnnamedPipeRef &second) |
| Create a connected pair of pipes. | |
| static UnnamedPipeRef | createStdin () |
| Create an instance of the concrete class that implements the UnnamedPipe interface connected to stdin. | |
| static UnnamedPipeRef | createStdout () |
| Create an instance of the concrete class that implements the UnnamedPipe interface connected to stdout. | |
| static UnnamedPipeRef | createStdinStdout () |
| Create an instance of the concrete class that implements the UnnamedPipe interface connected to stdin and stdout. | |
| static UnnamedPipeRef | createStderr () |
| Create an instance of the concrete class that implements the UnnamedPipe interface connected to stderr. | |
Static Public Attributes inherited from BLOCXX_NAMESPACE::UnnamedPipe | |
| static const int | INFINITE_TIMEOUT = -1 |
Protected Member Functions inherited from BLOCXX_NAMESPACE::UnnamedPipe | |
| UnnamedPipe () | |
Protected Member Functions inherited from BLOCXX_NAMESPACE::IntrusiveCountableBase | |
| IntrusiveCountableBase () | |
| IntrusiveCountableBase (const IntrusiveCountableBase &) | |
| IntrusiveCountableBase & | operator= (const IntrusiveCountableBase &) |
| virtual | ~IntrusiveCountableBase () |
Definition at line 50 of file PosixUnnamedPipe.hpp.
Definition at line 351 of file PosixUnnamedPipe.cpp.
References BLOCXX_INVALID_HANDLE, BLOCXX_NAMESPACE::UnnamedPipe::E_BLOCKING, m_fds, open(), BLOCXX_NAMESPACE::operator==(), BLOCXX_NAMESPACE::Timeout::relative(), setBlocking(), and BLOCXX_NAMESPACE::UnnamedPipe::setTimeouts().
| BLOCXX_NAMESPACE::PosixUnnamedPipe::PosixUnnamedPipe | ( | AutoDescriptor | inputfd, |
| AutoDescriptor | outputfd ) |
If fd_in == -1, then you cannot read from this object.
If fd_out == -1, then you cannot write to this object
Definition at line 363 of file PosixUnnamedPipe.cpp.
References BLOCXX_NAMESPACE::UnnamedPipe::E_BLOCKING, m_fds, BLOCXX_NAMESPACE::operator==(), BLOCXX_NAMESPACE::Timeout::relative(), setBlocking(), and BLOCXX_NAMESPACE::UnnamedPipe::setTimeouts().
|
virtual |
Definition at line 375 of file PosixUnnamedPipe.cpp.
References close().
|
private |
|
virtual |
Close the pipe.
Implements BLOCXX_NAMESPACE::UnnamedPipe.
Definition at line 462 of file PosixUnnamedPipe.cpp.
References BLOCXX_INVALID_HANDLE, m_fds, and BLOCXX_NAMESPACE::operator==().
Referenced by open(), and ~PosixUnnamedPipe().
|
virtual |
Implements BLOCXX_NAMESPACE::UnnamedPipe.
Definition at line 496 of file PosixUnnamedPipe.cpp.
References BLOCXX_INVALID_HANDLE, m_fds, and BLOCXX_NAMESPACE::operator==().
Referenced by read().
|
virtual |
Implements BLOCXX_NAMESPACE::UnnamedPipe.
Definition at line 511 of file PosixUnnamedPipe.cpp.
References BLOCXX_INVALID_HANDLE, m_fds, and BLOCXX_NAMESPACE::operator==().
|
virtual |
Get the underlying input descriptor.
The UnnamedPipe instance retains ownership of the descriptor.
Implements BLOCXX_NAMESPACE::UnnamedPipe.
Definition at line 738 of file PosixUnnamedPipe.cpp.
References m_fds.
|
inline |
Definition at line 61 of file PosixUnnamedPipe.hpp.
Referenced by BLOCXX_NAMESPACE::Exec::PreExec::setupStandardDescriptors().
|
virtual |
Get the underlying output descriptor.
The UnnamedPipe instance retains ownership of the descriptor.
Implements BLOCXX_NAMESPACE::UnnamedPipe.
Definition at line 745 of file PosixUnnamedPipe.cpp.
References m_fds.
|
inline |
Definition at line 62 of file PosixUnnamedPipe.hpp.
|
virtual |
Get the current blocking mode for reading from pipe.
Implements BLOCXX_NAMESPACE::UnnamedPipe.
Definition at line 752 of file PosixUnnamedPipe.cpp.
References m_blocking.
|
virtual |
Get the read select object.
Implements BLOCXX_NAMESPACE::UnnamedPipe.
Definition at line 614 of file PosixUnnamedPipe.cpp.
References m_fds.
|
virtual |
Get the current blocking mode for writing from pipe.
Implements BLOCXX_NAMESPACE::UnnamedPipe.
Definition at line 759 of file PosixUnnamedPipe.cpp.
References m_blocking.
|
virtual |
Get the write select object.
Implements BLOCXX_NAMESPACE::UnnamedPipe.
Definition at line 621 of file PosixUnnamedPipe.cpp.
References m_fds.
|
virtual |
Is the pipe open or closed?
Implements BLOCXX_NAMESPACE::UnnamedPipe.
Definition at line 489 of file PosixUnnamedPipe.cpp.
References BLOCXX_INVALID_HANDLE, and m_fds.
|
virtual |
Open the pipe.
Implements BLOCXX_NAMESPACE::UnnamedPipe.
Definition at line 436 of file PosixUnnamedPipe.cpp.
References BLOCXX_INVALID_HANDLE, BLOCXX_THROW_ERRNO_MSG, close(), m_fds, and BLOCXX_NAMESPACE::operator==().
Referenced by PosixUnnamedPipe().
|
private |
|
virtual |
Sends a Descriptor to the peer.
| h | The Descriptor to send. |
| IOException | on I/O error. |
Implements BLOCXX_NAMESPACE::UnnamedPipe.
Definition at line 628 of file PosixUnnamedPipe.cpp.
References BLOCXX_INVALID_HANDLE, BLOCXX_THROW, BLOCXX_THROW_ERRNO_MSG, BLOCXX_NAMESPACE::callOnce(), BLOCXX_NAMESPACE::UnnamedPipe::E_BLOCKING, BLOCXX_NAMESPACE::IOIFC::E_RETURN_ON_ERROR, BLOCXX_NAMESPACE::SocketFlags::E_WAIT_FOR_INPUT, BLOCXX_NAMESPACE::SocketFlags::E_WAIT_FOR_OUTPUT, ETIMEDOUT, BLOCXX_NAMESPACE::UnnamedPipe::getWriteTimeout(), BLOCXX_NAMESPACE::Timeout::infinite, m_blocking, m_fds, BLOCXX_NAMESPACE::operator==(), and BLOCXX_NAMESPACE::SocketUtils::waitForIO().
|
virtual |
Read a specified number of bytes from the device that is exposing the IOIFC interface.
| dataIn | A pointer to a location in memory to put the bytes that have been read. |
| dataInLen | The number of bytes being requested from the device. |
| errorAsException | If true and an error occurs durring the read operation, then throw an exception. |
| An | exception will be thrown upon an error condition if errorAsException is true. |
Implements BLOCXX_NAMESPACE::IOIFC.
Definition at line 567 of file PosixUnnamedPipe.cpp.
References BLOCXX_INVALID_HANDLE, BLOCXX_THROW, BLOCXX_THROW_ERRNO_MSG, closeInputHandle(), BLOCXX_NAMESPACE::UnnamedPipe::E_BLOCKING, BLOCXX_NAMESPACE::IOIFC::E_THROW_ON_ERROR, BLOCXX_NAMESPACE::SocketFlags::E_WAIT_FOR_INPUT, ETIMEDOUT, BLOCXX_NAMESPACE::UnnamedPipe::getReadTimeout(), m_blocking, m_fds, BLOCXX_NAMESPACE::operator==(), and BLOCXX_NAMESPACE::SocketUtils::waitForIO().
|
virtual |
Gets a Descriptor from the peer.
Descriptor sent by the peer.| IOException | on I/O error or if the peer does not send a Descriptor |
Implements BLOCXX_NAMESPACE::UnnamedPipe.
Definition at line 694 of file PosixUnnamedPipe.cpp.
References BLOCXX_INVALID_HANDLE, BLOCXX_THROW, BLOCXX_THROW_ERRNO_MSG, BLOCXX_NAMESPACE::callOnce(), BLOCXX_NAMESPACE::UnnamedPipe::E_BLOCKING, BLOCXX_NAMESPACE::IOIFC::E_THROW_ON_ERROR, BLOCXX_NAMESPACE::SocketFlags::E_WAIT_FOR_INPUT, BLOCXX_NAMESPACE::SocketFlags::E_WAIT_FOR_OUTPUT, ETIMEDOUT, BLOCXX_NAMESPACE::UnnamedPipe::getReadTimeout(), BLOCXX_NAMESPACE::Timeout::infinite, m_blocking, m_fds, BLOCXX_NAMESPACE::operator==(), and BLOCXX_NAMESPACE::SocketUtils::waitForIO().
|
virtual |
Set the pipe's blocking mode.
Precondition: The pipe is open.
| isBlocking | new blocking mode. |
Implements BLOCXX_NAMESPACE::UnnamedPipe.
Definition at line 410 of file PosixUnnamedPipe.cpp.
References BLOCXX_ASSERT, BLOCXX_INVALID_HANDLE, i, m_blocking, m_fds, and BLOCXX_NAMESPACE::operator==().
Referenced by PosixUnnamedPipe(), and PosixUnnamedPipe().
|
virtual |
Set blocking mode for reading from pipe.
Precondition: The pipe input is open.
| isBlocking | new read blocking mode. |
Implements BLOCXX_NAMESPACE::UnnamedPipe.
Definition at line 430 of file PosixUnnamedPipe.cpp.
References m_blocking, m_fds, and BLOCXX_NAMESPACE::operator==().
|
virtual |
Set blocking mode for writing to pipe.
Precondition: The pipe output is open.
| isBlocking | new write blocking mode. |
Implements BLOCXX_NAMESPACE::UnnamedPipe.
Definition at line 424 of file PosixUnnamedPipe.cpp.
References m_blocking, m_fds, and BLOCXX_NAMESPACE::operator==().
|
virtual |
Write a specified number of bytes to the device that is exposing the IOIFC interface.
| dataOut | A pointer to a location in memory that contains the bytes that will be written to the device. |
| dataOutLen | The length of the data pointed to by the dataOut param. |
| errorAsException | If true and an error occurs durring the write operation, then throw an exception. |
| An | exception will be thrown upon an error condition if errorAsException is true. |
Implements BLOCXX_NAMESPACE::IOIFC.
Definition at line 526 of file PosixUnnamedPipe.cpp.
References BLOCXX_INVALID_HANDLE, BLOCXX_THROW, BLOCXX_THROW_ERRNO_MSG, BLOCXX_NAMESPACE::UnnamedPipe::E_BLOCKING, BLOCXX_NAMESPACE::IOIFC::E_THROW_ON_ERROR, BLOCXX_NAMESPACE::SocketFlags::E_WAIT_FOR_OUTPUT, ETIMEDOUT, BLOCXX_NAMESPACE::UnnamedPipe::getWriteTimeout(), m_blocking, m_fds, BLOCXX_NAMESPACE::operator==(), and BLOCXX_NAMESPACE::SocketUtils::waitForIO().
|
private |
Definition at line 87 of file PosixUnnamedPipe.hpp.
Referenced by getReadBlocking(), getWriteBlocking(), passDescriptor(), read(), receiveDescriptor(), setBlocking(), setReadBlocking(), setWriteBlocking(), and write().
|
private |
Definition at line 86 of file PosixUnnamedPipe.hpp.
Referenced by close(), closeInputHandle(), closeOutputHandle(), getInputDescriptor(), getOutputDescriptor(), getReadSelectObj(), getWriteSelectObj(), isOpen(), open(), passDescriptor(), PosixUnnamedPipe(), PosixUnnamedPipe(), read(), receiveDescriptor(), setBlocking(), setReadBlocking(), setWriteBlocking(), and write().