Public Member Functions |
void | fail (DashelException::Source s, int se, const char *reason) |
| Set stream to failed state.
|
bool | failed () const |
| Query failed state of stream.
|
virtual void | flush ()=0 |
| Flushes stream.
|
const std::string & | getFailReason () const |
| Returns the reason the stream has failed.
|
const std::string & | getProtocolName () const |
| Returns the protocol name of the stream.
|
std::string | getTargetName () const |
| Returns the name of the target.
|
const std::string & | getTargetParameter (const char *param) const |
| Returns the value of a parameter extracted from the target.
|
virtual void | read (void *data, size_t size)=0 |
| Reads data from the stream.
|
template<typename T > |
T | read () |
| Read a variable of basic type from the stream.
|
virtual void | write (const void *data, const size_t size)=0 |
| Write data to the stream.
|
template<typename T > |
void | write (T v) |
| Write a variable of basic type to the stream.
|
Protected Member Functions |
| Stream (const std::string &protocolName) |
| Constructor.
|
virtual | ~Stream () |
| Virtual destructor, to ensure calls to destructors of sub-classes.
|
Protected Attributes |
std::string | protocolName |
| The protocol name.
|
ParameterSet | target |
| The target description.
|
Private Attributes |
bool | failedFlag |
| A flag indicating that the stream has failed.
|
std::string | failReason |
| The human readable reason describing why the stream has failed.
|
Friends |
class | Hub |
A data stream, with low-level (not-endian safe) read/write functions.
Definition at line 262 of file dashel.h.
Reads data from the stream.
Reads all requested data from the stream, blocking until all the data has been read, or some error occurs. Errors are signaled by throwing a DashelException exception, which may be caused either by device errors or reaching the end of file.
- Parameters:
-
data | Pointer to the memory where the read data should be stored. |
size | Amount of data to read in bytes. |
Implemented in Dashel::SocketStream, Dashel::FileDescriptorStream, Dashel::FileStream, Dashel::SocketServerStream, Dashel::StdoutStream, Dashel::SocketStream, Dashel::StdinStream, Dashel::SocketServerStream, and Dashel::MemoryPacketStream.
Write data to the stream.
Writes all requested data to the stream, blocking until all the data has been written, or some error occurs. Errors are signaled by throwing a DashelException exception. This function does not flush devices, therefore the data may not really have been written on return, but only been buffered. In order to flush the stream, call flush().
- Parameters:
-
data | Pointer to the data to write. |
size | Amount of data to write in bytes. |
Implemented in Dashel::SocketStream, Dashel::FileDescriptorStream, Dashel::FileStream, Dashel::SocketServerStream, Dashel::StdoutStream, Dashel::StdinStream, Dashel::SocketStream, Dashel::SocketServerStream, and Dashel::MemoryPacketStream.