#include <IOChannel.h>
Public Member Functions | |
virtual void | close (void) |
virtual void | fd (IOFD value) |
virtual IOFD | fd (void) const |
IOChannel (IOFD fd=-1) | |
virtual bool | isBlocking (void) const |
IOSize | read (IOBuffer into) |
IOSize | read (void *into, IOSize n) override |
virtual IOSize | read (void *into, IOSize n)=0 |
int | read (void) |
IOSize | readv (IOBuffer *into, IOSize buffers) override |
virtual void | setBlocking (bool value) |
IOSize | write (const void *from, IOSize n) override |
virtual IOSize | write (const void *from, IOSize n)=0 |
IOSize | write (IOBuffer from) |
IOSize | write (unsigned char byte) |
IOSize | writev (const IOBuffer *from, IOSize buffers) override |
~IOChannel (void) override | |
Public Member Functions inherited from IOInput | |
IOSize | read (IOBuffer into) |
int | read (void) |
IOSize | xread (IOBuffer into) |
IOSize | xread (void *into, IOSize n) |
IOSize | xreadv (IOBuffer *into, IOSize buffers) |
virtual | ~IOInput (void) |
Destruct the stream. A no-op. More... | |
Public Member Functions inherited from IOOutput | |
IOSize | write (IOBuffer from) |
IOSize | write (unsigned char byte) |
IOSize | xwrite (const void *from, IOSize n) |
IOSize | xwrite (IOBuffer from) |
IOSize | xwritev (const IOBuffer *from, IOSize buffers) |
virtual | ~IOOutput (void) |
Destruct the stream. A no-op. More... | |
Protected Member Functions | |
bool | sysclose (IOFD fd, int *error=nullptr) |
Private Attributes | |
IOFD | m_fd |
Base class for stream-oriented I/O sources and targets, based on the operating system file descriptor.
Definition at line 9 of file IOChannel.h.
IOChannel::IOChannel | ( | IOFD | fd = -1 | ) |
Definition at line 61 of file IOChannel.cc.
|
override |
Definition at line 63 of file IOChannel.cc.
|
virtual |
Close the channel. By default closes the underlying operating system file descriptor.
Reimplemented in File, and RemoteFile.
Definition at line 84 of file IOChannel.cc.
References EDM_IOFD_INVALID, relativeConstraints::error, fd(), sysclose(), and throwStorageError().
Referenced by esMonitoring.AsyncLineReaderMixin::handle_close(), esMonitoring.FDJsonServer::handle_close(), and sysclose().
|
virtual |
Set the system file descriptor of the channel. (FIXME: This is dangerous. How to deal with WIN32 flags and state object?)
Definition at line 73 of file IOChannel.cc.
References m_fd, and relativeConstraints::value.
|
virtual |
Get the system file descriptor of the channel.
Definition at line 69 of file IOChannel.cc.
References m_fd.
Referenced by close(), isBlocking(), RemoteFile::local(), read(), readv(), setBlocking(), sysclose(), write(), and writev().
|
virtual |
Definition at line 112 of file UnixIOChannel.cc.
References fd(), ALCARECOPromptCalibProdSiPixelAli0T_cff::mode, O_NONBLOCK, and throwStorageError().
IOSize IOInput::read |
Read from the input stream into the buffer starting at into and of size n.
If this is a blocking stream, the call will block until some data can be read, end of input is reached, or an exception is thrown. For a non-blocking stream the available input is returned. If none is available, an exception is thrown.
The base class implementation simply forwards the call to read(void *, IOSize) method.
In | case of error, a #IOError exception is thrown. This includes the situation where the input stream is in non-blocking mode and no input is currently available (FIXME: make this simpler; clarify which exception). |
Definition at line 80 of file IOInput.cc.
Read at most n bytes from the channel into the buffer into.
Implements IOInput.
Definition at line 9 of file UnixIOChannel.cc.
References fd(), edm::errors::FileReadError, dqmiodumpmetadata::n, IOInput::read(), alignCSCRings::s, and throwStorageError().
IOSize IOInput::read |
Read into into at most n number of bytes.
If this is a blocking stream, the call will block until some data can be read, end of input is reached, or an exception is thrown. For a non-blocking stream the available input is returned. If none is available, an exception is thrown.
In | case of error, a #IOError exception is thrown. This includes the situation where the input stream is in non-blocking mode and no input is currently available (FIXME: make this simpler; clarify which exception). |
int IOInput::read |
Read the next single byte from the input stream and return it as an unsigned
char
cast to an int
, -1 to indicate end of intput data.
If this is a blocking stream, the call will block until the byte can be read, end of data is reached, or an exception is thrown. For a non-blocking input a character is returned if one is available, otherwise an exception is thrown.
The base class implementation simply forwards the call to read(void *, IOSize) method.
unsigned char
to an int
(in range 0...255, inclusive) if one could be read, or -1
to indicate end of input data.In | case of error, a #IOError exception is thrown. This includes the situation where the input stream is in non-blocking mode and no input is currently available (FIXME: make this simpler; clarify which exception). |
Definition at line 52 of file IOInput.cc.
Read into scattered buffers.
This operation may ignore errors. If some data are already read and an error occurs, the call returns the number of bytes read up to that point, hiding the error. It is assumed that a subsequent read will discover persistent errors and that sporadic errors such as indication that the read would block can be ignored.
The operation always fills a buffer completely before proceeding to the next one. The call is handled by the operating system if possible; the fall back is to use the single read() repeatedly.
Reimplemented from IOInput.
Definition at line 21 of file UnixIOChannel.cc.
References cms::cuda::assert(), data, fd(), edm::errors::FileReadError, mps_fire::i, dqmiodumpmetadata::n, IOBuffer::size(), and throwStorageError().
Referenced by File::readv().
|
virtual |
Definition at line 97 of file UnixIOChannel.cc.
References fd(), ALCARECOPromptCalibProdSiPixelAli0T_cff::mode, O_NONBLOCK, throwStorageError(), and relativeConstraints::value.
|
protected |
Definition at line 127 of file UnixIOChannel.cc.
References close(), relativeConstraints::error, fd(), and runTheMatrix::ret.
Referenced by close().
Write n bytes from the buffer at from.
Implements IOOutput.
Definition at line 53 of file UnixIOChannel.cc.
References fd(), edm::errors::FileWriteError, dqmiodumpmetadata::n, alignCSCRings::s, and throwStorageError().
Referenced by File::write().
IOSize IOOutput::write |
Write n bytes of data starting at address from.
In | case of error, an exception is thrown. However if the stream is in non-blocking mode and cannot accept output, it will not throw an exception – the return value will be less than requested. |
IOSize IOOutput::write |
Write to the output stream the buffer from. This method is simply redirected to write(const void *, IOSize).
Note that derived classes should not normally call this method, as it simply routes the call back to derived class through the other virtual functions. Use this method only at the "outside edge" when transferring calls from one object to another, not in up/down calls in the inheritance tree.
In | case of error, an exception is thrown. However if the stream is in non-blocking mode and cannot accept output, it will not throw an exception – the return value will be less than requested. |
Definition at line 59 of file IOOutput.cc.
IOSize IOOutput::write |
Write a single byte to the output stream. This method is simply redirected to write(const void *, IOSize).
Note that derived classes should not normally call this method, as it simply routes the call back to derived class through the other virtual functions. Use this method only at the "outside edge" when transferring calls from one object to another, not in up/down calls in the inheritance tree.
In | case of error, an exception is thrown. However if the stream is in non-blocking mode and cannot accept output, it will not throw an exception – zero will be returned. |
Definition at line 39 of file IOOutput.cc.
Write from a scattered buffer.
This operation may ignore errors. If some data is already written and an error occurs, the call returns the number of bytes written up to that point, hiding the error. It is assumed that a subsequent write will discover persistent errors.
Always writes a complete buffer before proceeding to the next one. The call is delegated to the operating system if possible. If the system does not support this, falls back on multiple calls to single-buffer write().
Reimplemented from IOOutput.
Definition at line 65 of file UnixIOChannel.cc.
References cms::cuda::assert(), data, fd(), edm::errors::FileWriteError, mps_fire::i, dqmiodumpmetadata::n, IOBuffer::size(), and throwStorageError().
Referenced by File::writev().
|
private |
Definition at line 38 of file IOChannel.h.
Referenced by fd().