Diag-Client-Lib
Public Types | Public Member Functions | Private Attributes | List of all members
boost_support::socket::tcp::TcpMessage Class Referencefinal

Immutable class to store received tcp message. More...

#include <tcp_message.h>

Public Types

enum class  SocketState : std::uint8_t {
  kIdle = 0x00 , kSocketOnline , kSocketOffline , kSocketRxMessageReceived ,
  kSocketTxMessageSend , kSocketTxMessageConf , kSocketError
}
 Definition of different socket state. More...
 
enum class  SocketError : std::uint8_t { kNone = 0x00 }
 Definition of different socket error that could occur. More...
 
using BufferType = std::vector< uint8_t >
 Type alias for underlying buffer. More...
 
using IpAddressType = std::string_view
 Type alias of IP address type. More...
 

Public Member Functions

 TcpMessage ()
 Default constructor. More...
 
 TcpMessage (IpAddressType host_ip_address, std::uint16_t host_port_number, BufferType &&payload)
 Constructs an instance of TcpMessage. More...
 
 TcpMessage (TcpMessage &&other) noexcept=default
 
TcpMessageoperator= (TcpMessage &&other) noexcept=default
 
 TcpMessage (const TcpMessage &other)=delete
 
TcpMessageoperator= (const TcpMessage &other)=delete
 
 ~TcpMessage ()=default
 Destructs an instance of TcpMessage. More...
 
IpAddressType GetHostIpAddress () const
 Get the host ip address. More...
 
std::uint16_t GetHostPortNumber () const
 Get the host port number. More...
 
core_type::Span< std::uint8_t > GetRxBuffer ()
 Get the view to the rx buffer. More...
 
BufferTypeGetTxBuffer ()
 Get the reference to tx buffer. More...
 
BufferType const & GetTxBuffer () const
 Get the reference to tx buffer. More...
 
SocketState GetSocketState () const
 Get the state of underlying socket. More...
 
SocketError GetSocketError () const
 Get the error of underlying socket. More...
 

Private Attributes

SocketState socket_state_
 Store the socket state. More...
 
SocketError socket_error_
 Store the socket error. More...
 
BufferType rx_buffer_
 The reception buffer. More...
 
BufferType tx_buffer_
 The transmission buffer. More...
 
std::string host_ip_address_
 Store remote ip address. More...
 
std::uint16_t host_port_number_
 Store remote port number. More...
 

Detailed Description

Immutable class to store received tcp message.

Definition at line 25 of file tcp_message.h.

Member Typedef Documentation

◆ BufferType

Type alias for underlying buffer.

Definition at line 48 of file tcp_message.h.

◆ IpAddressType

Type alias of IP address type.

Definition at line 53 of file tcp_message.h.

Member Enumeration Documentation

◆ SocketError

Definition of different socket error that could occur.

Enumerator
kNone 

Definition at line 43 of file tcp_message.h.

43 : std::uint8_t { kNone = 0x00 };

◆ SocketState

Definition of different socket state.

Enumerator
kIdle 
kSocketOnline 
kSocketOffline 
kSocketRxMessageReceived 
kSocketTxMessageSend 
kSocketTxMessageConf 
kSocketError 

Definition at line 30 of file tcp_message.h.

30  : std::uint8_t {
31  kIdle = 0x00,
32  kSocketOnline,
33  kSocketOffline,
34  kSocketRxMessageReceived,
35  kSocketTxMessageSend,
36  kSocketTxMessageConf,
38  };

Constructor & Destructor Documentation

◆ TcpMessage() [1/4]

boost_support::socket::tcp::TcpMessage::TcpMessage ( )
inline

Default constructor.

Definition at line 59 of file tcp_message.h.

62  rx_buffer_{},
63  tx_buffer_{},
std::string host_ip_address_
Store remote ip address.
Definition: tcp_message.h:161
BufferType rx_buffer_
The reception buffer.
Definition: tcp_message.h:151
std::uint16_t host_port_number_
Store remote port number.
Definition: tcp_message.h:166
SocketError socket_error_
Store the socket error.
Definition: tcp_message.h:146
SocketState socket_state_
Store the socket state.
Definition: tcp_message.h:141
BufferType tx_buffer_
The transmission buffer.
Definition: tcp_message.h:156

◆ TcpMessage() [2/4]

boost_support::socket::tcp::TcpMessage::TcpMessage ( IpAddressType  host_ip_address,
std::uint16_t  host_port_number,
BufferType &&  payload 
)
inline

Constructs an instance of TcpMessage.

Parameters
[in]host_ip_addressThe host ip address
[in]host_port_numberThe host port number
[in]payloadThe received data payload

Definition at line 76 of file tcp_message.h.

79  rx_buffer_{std::move(payload)},
80  tx_buffer_{},
81  host_ip_address_{host_ip_address},
82  host_port_number_{host_port_number} {}

◆ TcpMessage() [3/4]

boost_support::socket::tcp::TcpMessage::TcpMessage ( TcpMessage &&  other)
defaultnoexcept

◆ TcpMessage() [4/4]

boost_support::socket::tcp::TcpMessage::TcpMessage ( const TcpMessage other)
delete

◆ ~TcpMessage()

boost_support::socket::tcp::TcpMessage::~TcpMessage ( )
default

Destructs an instance of TcpMessage.

Member Function Documentation

◆ GetHostIpAddress()

IpAddressType boost_support::socket::tcp::TcpMessage::GetHostIpAddress ( ) const
inline

Get the host ip address.

Returns
The IP address

Definition at line 99 of file tcp_message.h.

99 { return host_ip_address_; }

References host_ip_address_.

◆ GetHostPortNumber()

std::uint16_t boost_support::socket::tcp::TcpMessage::GetHostPortNumber ( ) const
inline

Get the host port number.

Returns
The port number

Definition at line 105 of file tcp_message.h.

105 { return host_port_number_; }

References host_port_number_.

◆ GetRxBuffer()

core_type::Span<std::uint8_t> boost_support::socket::tcp::TcpMessage::GetRxBuffer ( )
inline

Get the view to the rx buffer.

Returns
The rx buffer

Definition at line 111 of file tcp_message.h.

References rx_buffer_.

◆ GetSocketError()

SocketError boost_support::socket::tcp::TcpMessage::GetSocketError ( ) const
inline

Get the error of underlying socket.

Returns
The socket error

Definition at line 135 of file tcp_message.h.

135 { return socket_error_; }

References socket_error_.

◆ GetSocketState()

SocketState boost_support::socket::tcp::TcpMessage::GetSocketState ( ) const
inline

Get the state of underlying socket.

Returns
The socket state

Definition at line 129 of file tcp_message.h.

129 { return socket_state_; }

References socket_state_.

◆ GetTxBuffer() [1/2]

BufferType& boost_support::socket::tcp::TcpMessage::GetTxBuffer ( )
inline

Get the reference to tx buffer.

Returns
The reference to buffer

Definition at line 117 of file tcp_message.h.

117 { return tx_buffer_; }

References tx_buffer_.

◆ GetTxBuffer() [2/2]

BufferType const& boost_support::socket::tcp::TcpMessage::GetTxBuffer ( ) const
inline

Get the reference to tx buffer.

Returns
The reference to buffer

Definition at line 123 of file tcp_message.h.

123 { return tx_buffer_; }

References tx_buffer_.

◆ operator=() [1/2]

TcpMessage& boost_support::socket::tcp::TcpMessage::operator= ( const TcpMessage other)
delete

◆ operator=() [2/2]

TcpMessage& boost_support::socket::tcp::TcpMessage::operator= ( TcpMessage &&  other)
defaultnoexcept

Member Data Documentation

◆ host_ip_address_

std::string boost_support::socket::tcp::TcpMessage::host_ip_address_
private

Store remote ip address.

Definition at line 161 of file tcp_message.h.

Referenced by GetHostIpAddress().

◆ host_port_number_

std::uint16_t boost_support::socket::tcp::TcpMessage::host_port_number_
private

Store remote port number.

Definition at line 166 of file tcp_message.h.

Referenced by GetHostPortNumber().

◆ rx_buffer_

BufferType boost_support::socket::tcp::TcpMessage::rx_buffer_
private

The reception buffer.

Definition at line 151 of file tcp_message.h.

Referenced by GetRxBuffer().

◆ socket_error_

SocketError boost_support::socket::tcp::TcpMessage::socket_error_
private

Store the socket error.

Definition at line 146 of file tcp_message.h.

Referenced by GetSocketError().

◆ socket_state_

SocketState boost_support::socket::tcp::TcpMessage::socket_state_
private

Store the socket state.

Definition at line 141 of file tcp_message.h.

Referenced by GetSocketState().

◆ tx_buffer_

BufferType boost_support::socket::tcp::TcpMessage::tx_buffer_
private

The transmission buffer.

Definition at line 156 of file tcp_message.h.

Referenced by GetTxBuffer().


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