Diag-Client-Lib
connection_manager.h
Go to the documentation of this file.
1 /* Diagnostic Client library
2  * Copyright (C) 2024 Avijit Dey
3  *
4  * This Source Code Form is subject to the terms of the Mozilla Public
5  * License, v. 2.0. If a copy of the MPL was not distributed with this
6  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7  */
8 #ifndef DIAG_CLIENT_LIB_LIB_DOIP_CLIENT_CONNECTION_CONNECTION_MANAGER_H_
9 #define DIAG_CLIENT_LIB_LIB_DOIP_CLIENT_CONNECTION_CONNECTION_MANAGER_H_
10 
11 #include <memory>
12 #include <string_view>
13 #include <utility>
14 
16 
17 namespace doip_client {
18 namespace connection {
19 
23 class ConnectionManager final {
24  public:
28  struct IoContext {};
29 
30  public:
34  ConnectionManager() noexcept;
35 
39  ~ConnectionManager() noexcept = default;
40 
51  std::unique_ptr<uds_transport::Connection> CreateTcpConnection(
52  uds_transport::ConversionHandler const &conversation, std::string_view tcp_ip_address,
53  std::uint16_t port_num);
54 
65  std::unique_ptr<uds_transport::Connection> CreateUdpConnection(
66  uds_transport::ConversionHandler const &conversation, std::string_view udp_ip_address,
67  std::uint16_t port_num);
68 
69  private:
74 };
75 } // namespace connection
76 } // namespace doip_client
77 
78 #endif // DIAG_CLIENT_LIB_LIB_DOIP_CLIENT_CONNECTION_CONNECTION_MANAGER_H_
Manages Doip tcp and udp connections.
ConnectionManager() noexcept
Constructs an instance of DoipConnectionManager.
std::unique_ptr< uds_transport::Connection > CreateTcpConnection(uds_transport::ConversionHandler const &conversation, std::string_view tcp_ip_address, std::uint16_t port_num)
Function to find or create a new Tcp connection.
IoContext io_context_
Stores the io context.
std::unique_ptr< uds_transport::Connection > CreateUdpConnection(uds_transport::ConversionHandler const &conversation, std::string_view udp_ip_address, std::uint16_t port_num)
Function to find or create a new Udp connection.