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

Server that manages unsecured/ secured tcp connection. More...

#include <tcp_server.h>

Classes

class  TcpServerImpl
 

Public Types

using TcpSocket = socket::tcp::TcpSocket
 Type alias for tcp unsecured socket. More...
 
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

 TcpServer (std::string_view server_name, TcpSocket tcp_socket) noexcept
 Constructs an instance of TcpServer. More...
 
 TcpServer (const TcpServer &other) noexcept=delete
 Deleted copy assignment and copy constructor. More...
 
TcpServeroperator= (const TcpServer &other) noexcept=delete
 
 TcpServer (TcpServer &&other) noexcept
 Move assignment and move constructor. More...
 
TcpServeroperator= (TcpServer &&other) noexcept
 
 ~TcpServer () noexcept
 Destruct an instance of TcpServer. More...
 
void Initialize () noexcept
 Initialize the server. More...
 
void DeInitialize () noexcept
 De-initialize the server. 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 > Transmit (MessageConstPtr tcp_message)
 Function to transmit the provided tcp message. More...
 

Private Attributes

std::unique_ptr< TcpServerImpltcp_server_impl_
 Unique pointer to tcp server implementation. More...
 

Detailed Description

Server that manages unsecured/ secured tcp connection.

Definition at line 30 of file tcp_server.h.

Member Typedef Documentation

◆ HandlerRead

Tcp function template used for reception.

Definition at line 55 of file tcp_server.h.

◆ Message

Type alias for Tcp message.

Definition at line 40 of file tcp_server.h.

◆ MessageConstPtr

Type alias for Tcp message const pointer.

Definition at line 50 of file tcp_server.h.

◆ MessagePtr

Type alias for Tcp message pointer.

Definition at line 45 of file tcp_server.h.

◆ TcpSocket

Type alias for tcp unsecured socket.

Definition at line 35 of file tcp_server.h.

Constructor & Destructor Documentation

◆ TcpServer() [1/3]

boost_support::server::tcp::TcpServer::TcpServer ( std::string_view  server_name,
TcpServer::TcpSocket  tcp_socket 
)
explicitnoexcept

Constructs an instance of TcpServer.

Parameters
[in]server_nameThe name of the server
[in]tcp_socketThe underlying tcp socket required for communication

Definition at line 88 of file tcp_server.cpp.

89  : tcp_server_impl_{std::make_unique<TcpServerImpl>(server_name, std::move(tcp_socket))} {}
std::unique_ptr< TcpServerImpl > tcp_server_impl_
Unique pointer to tcp server implementation.
Definition: tcp_server.h:114

◆ TcpServer() [2/3]

boost_support::server::tcp::TcpServer::TcpServer ( const TcpServer other)
deletenoexcept

Deleted copy assignment and copy constructor.

◆ TcpServer() [3/3]

boost_support::server::tcp::TcpServer::TcpServer ( TcpServer &&  other)
defaultnoexcept

Move assignment and move constructor.

◆ ~TcpServer()

boost_support::server::tcp::TcpServer::~TcpServer ( )
defaultnoexcept

Destruct an instance of TcpServer.

Member Function Documentation

◆ DeInitialize()

void boost_support::server::tcp::TcpServer::DeInitialize ( )
noexcept

De-initialize the server.

Definition at line 99 of file tcp_server.cpp.

99 { tcp_server_impl_->DeInitialize(); }

References tcp_server_impl_.

◆ Initialize()

void boost_support::server::tcp::TcpServer::Initialize ( )
noexcept

Initialize the server.

Definition at line 97 of file tcp_server.cpp.

97 { tcp_server_impl_->Initialize(); }

References Initialize().

Referenced by Initialize().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator=() [1/2]

TcpServer& boost_support::server::tcp::TcpServer::operator= ( const TcpServer other)
deletenoexcept

◆ operator=() [2/2]

TcpServer & boost_support::server::tcp::TcpServer::operator= ( TcpServer &&  other)
defaultnoexcept

◆ SetReadHandler()

void boost_support::server::tcp::TcpServer::SetReadHandler ( TcpServer::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 101 of file tcp_server.cpp.

101  {
102  tcp_server_impl_->SetReadHandler(std::move(read_handler));
103 }

◆ Transmit()

core_type::Result< void > boost_support::server::tcp::TcpServer::Transmit ( TcpServer::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 105 of file tcp_server.cpp.

105  {
106  return tcp_server_impl_->Transmit(std::move(tcp_message));
107 }

References tcp_server_impl_.

Member Data Documentation

◆ tcp_server_impl_

std::unique_ptr<TcpServerImpl> boost_support::server::tcp::TcpServer::tcp_server_impl_
private

Unique pointer to tcp server implementation.

Definition at line 119 of file tcp_server.h.

Referenced by DeInitialize(), and Transmit().


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