![]() |
VSM C++ SDK
Vehicle Specific Modules SDK
|
Abstract I/O stream interface. More...
#include <io_stream.h>
Public Types | |
enum | State { State::CLOSED, State::OPENING, State::OPENING_PASSIVE, State::OPENED } |
Stream states. More... | |
enum | Type { FILE, SERIAL, ANDROID_SERIAL, TCP, UDP, UDP_MULTICAST, CAN, UNDEFINED } |
Stream types. More... | |
typedef std::shared_ptr < Io_stream > | Ptr |
Pointer type. | |
typedef std::weak_ptr< Io_stream > | Weak_ptr |
Pointer type. | |
typedef Reference_guard < Io_stream::Ptr > | Ref |
Guard object. More... | |
typedef int64_t | Offset |
Offset for read/write operations. More... | |
typedef Callback_proxy< void, Io_result > | Write_handler |
Default prototype for write operation completion handler. More... | |
typedef Callback_proxy< void, Io_buffer::Ptr, Io_result > | Read_handler |
Default prototype for read operation completion handler. More... | |
typedef Callback_proxy< void > | Close_handler |
Default prototype for close operation completion handler. More... | |
Static Public Member Functions | |
template<typename... Args> | |
static Ptr | Create (Args &&...args) |
Create an instance. More... | |
static const char * | Io_result_as_char (const Io_result res) |
Convert Io_result value to character string. More... | |
Static Public Attributes | |
static const Offset | OFFSET_NONE |
Offset special value which indicates that the offset value is not specified. | |
static const Offset | OFFSET_END |
Offset special value which indicates that the offset value corresponds to the stream end (e.g. More... | |
Protected Member Functions | |
virtual Operation_waiter | Write_impl (Io_buffer::Ptr buffer, Offset offset, Write_handler completion_handler, Request_completion_context::Ptr comp_ctx)=0 |
Write call implementation. More... | |
virtual Operation_waiter | Read_impl (size_t max_to_read, size_t min_to_read, Offset offset, Read_handler completion_handler, Request_completion_context::Ptr comp_ctx)=0 |
Read call implementation. More... | |
virtual Operation_waiter | Close_impl (Close_handler completion_handler, Request_completion_context::Ptr comp_ctx)=0 |
Close call implementation. More... | |
void | Set_name (const std::string &) |
Set the stream name. More... | |
Protected Attributes | |
Type | stream_type |
State | state = State::CLOSED |
Current state of the stream. More... | |
std::atomic_int | ref_count = { 0 } |
Reference counter. More... | |
Abstract I/O stream interface.
All SDK objects which supports reading and/or writing raw bytes (like network connections, files, serial connections) implement this interface.
typedef Callback_proxy<void> ugcs::vsm::Io_stream::Close_handler |
Default prototype for close operation completion handler.
typedef int64_t ugcs::vsm::Io_stream::Offset |
Offset for read/write operations.
Used by streams which support offsets (like files).
typedef Callback_proxy<void, Io_buffer::Ptr, Io_result> ugcs::vsm::Io_stream::Read_handler |
Default prototype for read operation completion handler.
Guard object.
typedef Callback_proxy<void, Io_result> ugcs::vsm::Io_stream::Write_handler |
Default prototype for write operation completion handler.
|
strong |
Stream states.
|
strong |
Stream types.
|
delete |
There is no sense in copying the stream.
Multiple users of the same stream should copy the shared pointer Ptr.
void ugcs::vsm::Io_stream::Add_ref | ( | ) |
Add reference to the stream.
|
inline |
Initiate stream close operation.
completion_handler | Completion handler for the operation. |
comp_ctx | Completion context for the operation. |
Invalid_param_exception | If handler is set without completion context or vice versa. |
|
protectedpure virtual |
Close call implementation.
completion_handler | Completion handler. |
comp_ctx | Completion context. |
|
inlinestatic |
Create an instance.
std::string ugcs::vsm::Io_stream::Get_name | ( | ) | const |
Get human readable stream name.
|
inline |
Get current state of the stream.
|
static |
Convert Io_result value to character string.
|
inline |
Checks if stream is closed or not.
|
inline |
Initiate read operation.
max_to_read | Maximal number of bytes to read from the stream. Less bytes can be read in fact. |
min_to_read | Minimal number of bytes to read from the stream. The operation is not completed until the specified minimal number of bytes is read. |
offset | Read offset in the stream if supported. Value OFFSET_NONE indicates that stream-maintained offset should be used. |
completion_handler | Handler to invoke when the operation is completed. |
comp_ctx | Completion context for the operation. |
Invalid_param_exception | If handler is set without completion context or vice versa. |
Invalid_param_exception | If Max to read is less then Min to read. |
|
inline |
Initiate read operation.
max_to_read | Maximal number of bytes to read from the stream. Less bytes can be read in fact. If max_to_read is set to 0, then it is determined automatically based on stream type: TCP: max_to_read = MAX_TCP_PAYLOAD_SIZE_TO_READ UDP: max_to_read = MIN_UDP_PAYLOAD_SIZE_TO_READ serial and other stream types: max_to_read = min_to_read |
min_to_read | Minimal number of bytes to read from the stream. The operation is not completed until the specified minimal number of bytes is read. |
completion_handler | Handler to invoke when the operation is completed. |
comp_ctx | Completion context for the operation. |
Invalid_param_exception | If handler is set without completion context or vice versa. |
Invalid_param_exception | If Max to read is less then Min to read. |
|
protectedpure virtual |
Read call implementation.
max_to_read | Maximal number of bytes to read. |
min_to_read | Minimal number of bytes to read. |
offset | Operation offset. |
completion_handler | Completion handler. |
comp_ctx | Completion context. |
void ugcs::vsm::Io_stream::Release_ref | ( | ) |
Release reference for the stream.
The stream is closed when last reference is released.
|
protected |
Set the stream name.
|
inline |
Initiate write operation.
buffer | Buffer with data to write. |
offset | Write offset in the stream if supported. Value OFFSET_NONE indicates that stream-maintained offset should be used. |
completion_handler | Handler to invoke when the operation is completed. |
comp_ctx | Completion context for the operation. |
Invalid_param_exception | If handler is set without completion context or vice versa. |
|
inline |
Initiate write operation.
buffer | Buffer with data to write. |
completion_handler | Handler to invoke when the operation is completed. |
comp_ctx | Completion context for the operation. |
Invalid_param_exception | If handler is set without completion context or vice versa. |
|
protectedpure virtual |
Write call implementation.
buffer | Buffer with data to write. |
offset | Write offset in the stream if supported. Value OFFSET_NONE indicates that stream-maintained offset should be used. |
completion_handler | Handler to invoke when the operation is completed. |
comp_ctx | Completion context for the operation. |
|
static |
Offset special value which indicates that the offset value corresponds to the stream end (e.g.
append operation).
|
protected |
Reference counter.
|
protected |
Current state of the stream.