|
RADLib
RADical C++ application framework
|
Abstract byte-oriented IO device similar to QIODevice. More...
#include <RADCore.h>
Inheritance diagram for RADCore::RADIODevice:
Collaboration diagram for RADCore::RADIODevice:Public Member Functions | |
| virtual | ~RADIODevice ()=default |
| Destroys the IO device. More... | |
| virtual bool | open (OpenMode mode)=0 |
| Opens the device with mode. More... | |
| virtual void | close ()=0 |
| Closes the device. More... | |
| virtual bool | isOpen () const =0 |
| Returns true when open. More... | |
| virtual ssize_t | readData (void *buffer, size_t maxBytes)=0 |
| Reads raw bytes into buffer. More... | |
| virtual ssize_t | writeData (const void *data, size_t size)=0 |
| Writes raw bytes from data. More... | |
| std::vector< uint8_t > | read (size_t maxBytes) |
| Reads up to maxBytes into a byte vector. More... | |
| std::vector< uint8_t > | readAll (size_t chunkSize=8192) |
| Reads all available data in chunks. More... | |
| ssize_t | write (const std::vector< uint8_t > &data) |
| Writes a byte vector. More... | |
| ssize_t | write (const std::string &text) |
| Writes string bytes. More... | |
Public Member Functions inherited from RADCore::RADObject | |
| RADObject () | |
| Creates a RADObject bound to the current thread. More... | |
| virtual | ~RADObject () |
| Disconnects tracked event links and releases lifetime token. More... | |
| void | registerLink (const ConnectionRecord &record) |
| Registers a connection for cleanup when this object is destroyed. More... | |
| std::thread::id | threadId () const |
| Returns the thread id this object is currently associated with. More... | |
| EventLoop * | associatedEventLoop () const |
| Returns the associated event loop, if any. More... | |
| ThreadAffinity | threadAffinity () const |
| Returns both thread id and associated loop atomically. More... | |
| std::weak_ptr< void > | lifetimeToken () const |
| Returns a weak token used to drop queued callbacks after destruction. More... | |
| void | moveToThread (std::thread::id tId, EventLoop *loop=nullptr) |
| Moves the object's affinity to tId and optional loop. More... | |
Public Attributes | |
| RADCore::Event< void() > | readyRead |
| Raised when data is available to read. More... | |
| RADCore::Event< void(size_t) > | bytesWritten |
| Raised after bytes are written. More... | |
| RADCore::Event< void(std::string) > | errorOccurred |
| Raised when an IO error occurs. More... | |
Abstract byte-oriented IO device similar to QIODevice.
|
virtualdefault |
Destroys the IO device.
|
pure virtual |
Closes the device.
Implemented in RADSerial::RADSerialPort, RADNet::RADTcpSocket, RADMedia::RADAudioDevice, RADCore::RADFile, and RADCore::RADBuffer.
|
pure virtual |
Returns true when open.
Implemented in RADSerial::RADSerialPort, RADNet::RADTcpSocket, RADMedia::RADAudioDevice, RADCore::RADFile, and RADCore::RADBuffer.
|
pure virtual |
Opens the device with mode.
Implemented in RADSerial::RADSerialPort, RADNet::RADTcpSocket, RADMedia::RADAudioDevice, RADCore::RADFile, and RADCore::RADBuffer.
| std::vector<uint8_t> RADCore::RADIODevice::read | ( | size_t | maxBytes | ) |
Reads up to maxBytes into a byte vector.
| std::vector<uint8_t> RADCore::RADIODevice::readAll | ( | size_t | chunkSize = 8192 | ) |
Reads all available data in chunks.
|
pure virtual |
Reads raw bytes into buffer.
Implemented in RADSerial::RADSerialPort, RADNet::RADTcpSocket, RADMedia::RADAudioDevice, RADCore::RADFile, and RADCore::RADBuffer.
| ssize_t RADCore::RADIODevice::write | ( | const std::string & | text | ) |
Writes string bytes.
| ssize_t RADCore::RADIODevice::write | ( | const std::vector< uint8_t > & | data | ) |
Writes a byte vector.
|
pure virtual |
Writes raw bytes from data.
Implemented in RADSerial::RADSerialPort, RADNet::RADTcpSocket, RADMedia::RADAudioDevice, RADCore::RADFile, and RADCore::RADBuffer.
| RADCore::Event<void (size_t) > RADCore::RADIODevice::bytesWritten |
Raised after bytes are written.
| RADCore::Event<void (std::string) > RADCore::RADIODevice::errorOccurred |
Raised when an IO error occurs.
| RADCore::Event<void () > RADCore::RADIODevice::readyRead |
Raised when data is available to read.