VSM C++ SDK
Vehicle Specific Modules SDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
ugcs::vsm::Socket_processor::Stream Class Reference

Socket specific stream. More...

#include <socket_processor.h>

Inheritance diagram for ugcs::vsm::Socket_processor::Stream:
ugcs::vsm::Io_stream

Public Types

typedef std::shared_ptr< StreamPtr
 Pointer type.
 
typedef std::weak_ptr< StreamWeak_ptr
 Pointer type.
 
typedef Reference_guard
< Stream::Ptr
Ref
 
typedef Callback_proxy< void,
Io_buffer::Ptr, Io_result,
Socket_address::Ptr > 
Read_from_handler
 Default prototype for read operation completion handler. More...
 
typedef std::unique_ptr
< std::vector< uint8_t > > 
Buf_ptr
 
- Public Types inherited from ugcs::vsm::Io_stream
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_streamWeak_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...
 

Public Member Functions

template<typename... Args>
 Stream (Socket_processor::Ptr processor, Args &&...args)
 
void Set_state (Io_stream::State state)
 
void Set_connect_request (Io_request::Ptr request)
 
void Close_socket ()
 
Io_request::Ptr Get_connect_request ()
 
void Abort_pending_requests (Io_result result=Io_result::CLOSED)
 
virtual Operation_waiter Read_from (size_t max_to_read, Read_from_handler completion_handler, Request_completion_context::Ptr comp_ctx=Request_temp_completion_context::Create())
 Used to read from udp socket. More...
 
virtual Operation_waiter Write_to (Io_buffer::Ptr, Socket_address::Ptr dest_addr, Write_handler completion_handler, Request_completion_context::Ptr comp_ctx=Request_temp_completion_context::Create())
 Used to write to udp socket. More...
 
Socket_address::Ptr Get_peer_address ()
 
void Set_peer_address (Socket_address::Ptr)
 
Socket_address::Ptr Get_local_address ()
 
bool Add_multicast_group (Socket_address::Ptr interface, Socket_address::Ptr multicast)
 
bool Remove_multicast_group (Socket_address::Ptr interface, Socket_address::Ptr multicast)
 
bool Enable_broadcast (bool enable)
 
- Public Member Functions inherited from ugcs::vsm::Io_stream
void Add_ref ()
 Add reference to the stream. More...
 
void Release_ref ()
 Release reference for the stream. More...
 
Operation_waiter Write (Io_buffer::Ptr buffer, Offset offset, Write_handler completion_handler=Make_dummy_callback< void, Io_result >(), Request_completion_context::Ptr comp_ctx=Request_temp_completion_context::Create())
 Initiate write operation. More...
 
Operation_waiter Write (Io_buffer::Ptr buffer, Write_handler completion_handler=Make_dummy_callback< void, Io_result >(), Request_completion_context::Ptr comp_ctx=Request_temp_completion_context::Create())
 Initiate write operation. More...
 
Operation_waiter Read (size_t max_to_read, size_t min_to_read, Offset offset, Read_handler completion_handler=Make_dummy_callback< void, Io_buffer::Ptr, Io_result >(), Request_completion_context::Ptr comp_ctx=Request_temp_completion_context::Create())
 Initiate read operation. More...
 
Operation_waiter Read (size_t max_to_read, size_t min_to_read=1, Read_handler completion_handler=Make_dummy_callback< void, Io_buffer::Ptr, Io_result >(), Request_completion_context::Ptr comp_ctx=Request_temp_completion_context::Create())
 Initiate read operation. More...
 
Operation_waiter Close (Close_handler completion_handler=Make_dummy_callback< void >(), Request_completion_context::Ptr comp_ctx=Request_temp_completion_context::Create())
 Initiate stream close operation. More...
 
 Io_stream (const Io_stream &)=delete
 There is no sense in copying the stream. More...
 
 Io_stream (Type type)
 Constructor.
 
State Get_state () const
 Get current state of the stream. More...
 
bool Is_closed () const
 Checks if stream is closed or not. More...
 
std::string Get_name () const
 Get human readable stream name. More...
 
Type Get_type () const
 

Static Public Member Functions

template<typename... Args>
static Ptr Create (Args &&...args)
 Create an instance. More...
 
- Static Public Member Functions inherited from ugcs::vsm::Io_stream
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...
 

Friends

class Socket_processor
 

Additional Inherited Members

- Static Public Attributes inherited from ugcs::vsm::Io_stream
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 inherited from ugcs::vsm::Io_stream
void Set_name (const std::string &)
 Set the stream name. More...
 
- Protected Attributes inherited from ugcs::vsm::Io_stream
Type stream_type
 
State state = State::CLOSED
 Current state of the stream. More...
 
std::atomic_int ref_count = { 0 }
 Reference counter. More...
 

Detailed Description

Socket specific stream.

Member Typedef Documentation

Default prototype for read operation completion handler.

Member Function Documentation

template<typename... Args>
static Ptr ugcs::vsm::Socket_processor::Stream::Create ( Args &&...  args)
inlinestatic

Create an instance.

virtual Operation_waiter ugcs::vsm::Socket_processor::Stream::Read_from ( size_t  max_to_read,
Read_from_handler  completion_handler,
Request_completion_context::Ptr  comp_ctx = Request_temp_completion_context::Create() 
)
virtual

Used to read from udp socket.

Wrapper for recvfrom() call completion handler has source address as parameters. It can be used to subsequent Write_to() calls.

virtual Operation_waiter ugcs::vsm::Socket_processor::Stream::Write_to ( Io_buffer::Ptr  ,
Socket_address::Ptr  dest_addr,
Write_handler  completion_handler,
Request_completion_context::Ptr  comp_ctx = Request_temp_completion_context::Create() 
)
virtual

Used to write to udp socket.

Wrapper for sendto() call.


The documentation for this class was generated from the following file: