Diag-Client-Lib
Classes | Public Types | Public Member Functions | Private Attributes | List of all members
boost_support::client::tls::TlsClient< TlsVersion > Class Template Reference

Client that manages secured tcp connection. More...

#include <tls_client.h>

Classes

class  TlsClientImpl
 Class to provide implementation of tls client. More...
 

Public Types

using Message = boost_support::message::tcp::TcpMessage
 Type alias for Tcp message. More...
 
using MessagePtr = boost_support::message::tcp::TcpMessagePtr
 Type alias for Tcp message pointer. More...
 
using MessageConstPtr = boost_support::message::tcp::TcpMessageConstPtr
 Type alias for Tcp message const pointer. More...
 
using HandlerRead = std::function< void(MessagePtr)>
 Tcp function template used for reception. More...
 

Public Member Functions

 TlsClient (std::string_view client_name, std::string_view local_ip_address, std::uint16_t local_port_num, std::string_view ca_certification_path, TlsVersion tls_version) noexcept
 Constructs an instance of TlsClient. More...
 
 TlsClient (const TlsClient &other) noexcept=delete
 Deleted copy assignment and copy constructor. More...
 
TlsClientoperator= (const TlsClient &other) noexcept=delete
 
 TlsClient (TlsClient &&other) noexcept
 Move assignment and move constructor. More...
 
TlsClientoperator= (TlsClient &&other) noexcept
 
 ~TlsClient () noexcept
 Destruct an instance of TlsClient. More...
 
void Initialize () noexcept
 Initialize the client. More...
 
void DeInitialize () noexcept
 De-initialize the client. More...
 
void SetReadHandler (HandlerRead read_handler) noexcept
 Function to set the read handler that is invoked when message is received. More...
 
core_type::Result< void > ConnectToHost (std::string_view host_ip_address, std::uint16_t host_port_num)
 Function to connect to remote ip address and port number. More...
 
core_type::Result< void > DisconnectFromHost ()
 Function to disconnect from remote host if already connected. More...
 
auto IsConnectedToHost () const noexcept -> bool
 Function to get the connection status. More...
 
core_type::Result< void > Transmit (MessageConstPtr tcp_message)
 Function to transmit the provided tcp message. More...
 

Private Attributes

std::unique_ptr< TlsClientImpltls_client_impl_
 Unique pointer to tls client implementation. More...
 

Detailed Description

template<typename TlsVersion>
class boost_support::client::tls::TlsClient< TlsVersion >

Client that manages secured tcp connection.

Template Parameters
TlsVersionThe tls version to be used by client for communication

Definition at line 42 of file tls_client.h.

Member Typedef Documentation

◆ HandlerRead

template<typename TlsVersion >
using boost_support::client::tls::TlsClient< TlsVersion >::HandlerRead = std::function<void(MessagePtr)>

Tcp function template used for reception.

Definition at line 62 of file tls_client.h.

◆ Message

Type alias for Tcp message.

Definition at line 47 of file tls_client.h.

◆ MessageConstPtr

Type alias for Tcp message const pointer.

Definition at line 57 of file tls_client.h.

◆ MessagePtr

Type alias for Tcp message pointer.

Definition at line 52 of file tls_client.h.

Constructor & Destructor Documentation

◆ TlsClient() [1/3]

template<typename TlsVersion >
boost_support::client::tls::TlsClient< TlsVersion >::TlsClient ( std::string_view  client_name,
std::string_view  local_ip_address,
std::uint16_t  local_port_num,
std::string_view  ca_certification_path,
TlsVersion  tls_version 
)
noexcept

Constructs an instance of TlsClient.

Parameters
[in]local_ip_addressThe local ip address
[in]local_port_numThe local port number
[in]ca_certification_pathThe path to root ca certificate

Definition at line 230 of file tls_client.cpp.

234  : tls_client_impl_{std::make_unique<TlsClientImpl>(client_name, local_ip_address,
235  local_port_num, ca_certification_path,
236  std::move(tls_version))} {}
std::unique_ptr< TlsClientImpl > tls_client_impl_
Unique pointer to tls client implementation.
Definition: tls_client.h:148

◆ TlsClient() [2/3]

template<typename TlsVersion >
boost_support::client::tls::TlsClient< TlsVersion >::TlsClient ( const TlsClient< TlsVersion > &  other)
deletenoexcept

Deleted copy assignment and copy constructor.

◆ TlsClient() [3/3]

template<typename TlsVersion >
boost_support::client::tls::TlsClient< TlsVersion >::TlsClient ( TlsClient< TlsVersion > &&  other)
defaultnoexcept

Move assignment and move constructor.

◆ ~TlsClient()

template<typename TlsVersion >
boost_support::client::tls::TlsClient< TlsVersion >::~TlsClient ( )
defaultnoexcept

Destruct an instance of TlsClient.

Member Function Documentation

◆ ConnectToHost()

template<typename TlsVersion >
core_type::Result< void > boost_support::client::tls::TlsClient< TlsVersion >::ConnectToHost ( std::string_view  host_ip_address,
std::uint16_t  host_port_num 
)

Function to connect to remote ip address and port number.

Parameters
[in]host_ip_addressThe host ip address
[in]host_port_numThe host port number
Returns
Empty void on success, otherwise error is returned

Definition at line 263 of file tls_client.cpp.

264  {
265  return tls_client_impl_->ConnectToHost(host_ip_address, host_port_num);
266 }

◆ DeInitialize()

template<typename TlsVersion >
void boost_support::client::tls::TlsClient< TlsVersion >::DeInitialize
noexcept

De-initialize the client.

Definition at line 253 of file tls_client.cpp.

253  {
254  tls_client_impl_->DeInitialize();
255 }

◆ DisconnectFromHost()

template<typename TlsVersion >
core_type::Result< void > boost_support::client::tls::TlsClient< TlsVersion >::DisconnectFromHost

Function to disconnect from remote host if already connected.

Returns
Empty void on success, otherwise error is returned

Definition at line 269 of file tls_client.cpp.

269  {
270  return tls_client_impl_->DisconnectFromHost();
271 }

◆ Initialize()

template<typename TlsVersion >
void boost_support::client::tls::TlsClient< TlsVersion >::Initialize
noexcept

Initialize the client.

Definition at line 248 of file tls_client.cpp.

248  {
249  tls_client_impl_->Initialize();
250 }

◆ IsConnectedToHost()

template<typename TlsVersion >
auto boost_support::client::tls::TlsClient< TlsVersion >::IsConnectedToHost
noexcept

Function to get the connection status.

Returns
True if connected, False otherwise

Definition at line 274 of file tls_client.cpp.

274  {
275  return tls_client_impl_->IsConnectedToHost();
276 }

◆ operator=() [1/2]

template<typename TlsVersion >
TlsClient& boost_support::client::tls::TlsClient< TlsVersion >::operator= ( const TlsClient< TlsVersion > &  other)
deletenoexcept

◆ operator=() [2/2]

template<typename TlsVersion >
TlsClient< TlsVersion > & boost_support::client::tls::TlsClient< TlsVersion >::operator= ( TlsClient< TlsVersion > &&  other)
defaultnoexcept

◆ SetReadHandler()

template<typename TlsVersion >
void boost_support::client::tls::TlsClient< TlsVersion >::SetReadHandler ( TlsClient< TlsVersion >::HandlerRead  read_handler)
noexcept

Function to set the read handler that is invoked when message is received.

The ownership of provided read handler is moved

Parameters
[in]read_handlerThe handler to be set

Definition at line 258 of file tls_client.cpp.

258  {
259  tls_client_impl_->SetReadHandler(std::move(read_handler));
260 }

◆ Transmit()

template<typename TlsVersion >
core_type::Result< void > boost_support::client::tls::TlsClient< TlsVersion >::Transmit ( MessageConstPtr  tcp_message)

Function to transmit the provided tcp message.

Parameters
[in]tcp_messageThe tcp message
Returns
Empty void on success, otherwise error is returned

Definition at line 279 of file tls_client.cpp.

279  {
280  return tls_client_impl_->Transmit(std::move(tcp_message));
281 }

Member Data Documentation

◆ tls_client_impl_

template<typename TlsVersion >
std::unique_ptr<TlsClientImpl> boost_support::client::tls::TlsClient< TlsVersion >::tls_client_impl_
private

Unique pointer to tls client implementation.

Definition at line 153 of file tls_client.h.


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