Diag-Client-Lib
Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
diag::client::conversation_manager::ConversationManager Class Reference

Class to manage all the conversation created from usr request. More...

#include <conversation_manager.h>

Collaboration diagram for diag::client::conversation_manager::ConversationManager:
Collaboration graph
[legend]

Classes

struct  ConversationStorage
 Store Dm conversation. More...
 

Public Member Functions

 ConversationManager (diag::client::config_parser::DcmClientConfig config, diag::client::uds_transport::UdsTransportProtocolManager &uds_transport_mgr) noexcept
 Constructs an instance of ConversationManager. More...
 
 ~ConversationManager () noexcept=default
 Destructs an instance of ConversationManager. More...
 
void Startup () noexcept
 Function to start the ConversationManager. More...
 
void Shutdown () noexcept
 Function to shutdown the ConversationManager. More...
 
diag::client::conversation::ConversationGetDiagnosticClientConversation (std::string_view conversation_name) noexcept
 Function to get DM conversation object based on conversation name. More...
 

Private Member Functions

void StoreConversationConfig (diag::client::config_parser::DcmClientConfig &config) noexcept
 Function to store the dcm client configuration internally. More...
 

Private Attributes

uds_transport::UdsTransportProtocolManageruds_transport_mgr_
 Store the reference to uds transport manager. More...
 
std::unordered_map< std::string, ConversationStorageconversation_map_
 Map to store conversation object(dm) along with conversation name. More...
 

Detailed Description

Class to manage all the conversation created from usr request.

Definition at line 29 of file conversation_manager.h.

Constructor & Destructor Documentation

◆ ConversationManager()

diag::client::conversation_manager::ConversationManager::ConversationManager ( diag::client::config_parser::DcmClientConfig  config,
diag::client::uds_transport::UdsTransportProtocolManager uds_transport_mgr 
)
noexcept

Constructs an instance of ConversationManager.

Parameters
[in]configThe configuration of dcm client
[in]uds_transport_mgrThe reference to Uds transport manger

Definition at line 19 of file conversation_manager.cpp.

22  : uds_transport_mgr_{uds_transport_mgr} {
23  // store the conversation config (vd & dm) out of passed config
25 }
void StoreConversationConfig(diag::client::config_parser::DcmClientConfig &config) noexcept
Function to store the dcm client configuration internally.
uds_transport::UdsTransportProtocolManager & uds_transport_mgr_
Store the reference to uds transport manager.

◆ ~ConversationManager()

diag::client::conversation_manager::ConversationManager::~ConversationManager ( )
defaultnoexcept

Destructs an instance of ConversationManager.

Member Function Documentation

◆ GetDiagnosticClientConversation()

diag::client::conversation::Conversation & diag::client::conversation_manager::ConversationManager::GetDiagnosticClientConversation ( std::string_view  conversation_name)
noexcept

Function to get DM conversation object based on conversation name.

Parameters
[in]conversation_nameThe passed conversation name
Returns
The reference to diag client conversation as per passed conversation name

Definition at line 31 of file conversation_manager.cpp.

32  {
33  // find the conversation from config stored
34  auto it = conversation_map_.find(std::string{conversation_name});
35  if (it != conversation_map_.end()) {
36  std::string const conversation_name_in_map{it->first};
37  it->second.conversation = std::visit(
39  [this, &conversation_name_in_map](conversation::DMConversationType conversation_type) noexcept {
40  // Create the conversation
41  std::unique_ptr<diag::client::conversation::Conversation> conversation{
42  std::make_unique<diag::client::conversation::DmConversation>(conversation_name_in_map,
43  conversation_type)};
44  // Register the connection
45  conversation->RegisterConnection(uds_transport_mgr_.GetTransportProtocolHandler().CreateTcpConnection(
46  conversation->GetConversationHandler(), conversation_type.tcp_address, conversation_type.port_num));
47  return conversation;
48  },
49  [this, &conversation_name_in_map](conversation::VDConversationType conversation_type) noexcept {
50  // Create the conversation
51  std::unique_ptr<diag::client::conversation::Conversation> conversation{
52  std::make_unique<diag::client::conversation::VdConversation>(conversation_name_in_map,
53  conversation_type)};
54  // Register the connection
55  conversation->RegisterConnection(uds_transport_mgr_.GetTransportProtocolHandler().CreateUdpConnection(
56  conversation->GetConversationHandler(), conversation_type.udp_address, conversation_type.port_num));
57  return conversation;
58  }},
59  it->second.conversation_type);
60  } else {
61  logger::DiagClientLogger::GetDiagClientLogger().GetLogger().LogFatal(
62  __FILE__, __LINE__, __func__, [conversation_name](std::stringstream &msg) {
63  msg << "Invalid conversation name: '" << conversation_name << "', provide correct name as per config file";
64  });
65  }
66  return *(it->second.conversation);
67 }
std::unordered_map< std::string, ConversationStorage > conversation_map_
Map to store conversation object(dm) along with conversation name.
static auto GetDiagClientLogger() noexcept -> DiagClientLogger &
Get the diag client logger instance.
Definition: logger.h:32
::uds_transport::UdsTransportProtocolHandler & GetTransportProtocolHandler()
virtual std::unique_ptr< Connection > CreateUdpConnection(ConversionHandler &conversion_handler, std::string_view udpIpaddress, uint16_t portNum)=0
Function to create a new Udp connection.
virtual std::unique_ptr< Connection > CreateTcpConnection(ConversionHandler &conversion_handler, std::string_view tcpIpaddress, uint16_t portNum)=0
Function to create a new Tcp connection.

References diag::client::logger::DiagClientLogger::GetDiagClientLogger().

Here is the call graph for this function:

◆ Shutdown()

void diag::client::conversation_manager::ConversationManager::Shutdown ( )
noexcept

Function to shutdown the ConversationManager.

Definition at line 29 of file conversation_manager.cpp.

29 {}

Referenced by diag::client::dcm::DCMClient::Shutdown().

Here is the caller graph for this function:

◆ Startup()

void diag::client::conversation_manager::ConversationManager::Startup ( )
noexcept

Function to start the ConversationManager.

Definition at line 27 of file conversation_manager.cpp.

27 {}

◆ StoreConversationConfig()

void diag::client::conversation_manager::ConversationManager::StoreConversationConfig ( diag::client::config_parser::DcmClientConfig config)
privatenoexcept

Function to store the dcm client configuration internally.

Parameters
[in]configThe Dcm client configuration

Definition at line 69 of file conversation_manager.cpp.

69  {
70  { // Create Vehicle discovery config
71  conversation::VDConversationType conversion_identifier{};
72  conversion_identifier.udp_address = config.udp_ip_address;
73  conversion_identifier.udp_broadcast_address = config.udp_broadcast_address;
74  conversion_identifier.port_num = 0U; // random selection of port number
75  (void) conversation_map_.emplace("VehicleDiscovery", ConversationStorage{conversion_identifier, nullptr});
76  }
77 
78  { // Create Conversation config
79  for (std::uint8_t conv_count{0U}; conv_count < config.num_of_conversation; conv_count++) {
80  conversation::DMConversationType conversion_identifier{};
81  conversion_identifier.rx_buffer_size = config.conversations[conv_count].rx_buffer_size;
82  conversion_identifier.p2_client_max = config.conversations[conv_count].p2_client_max;
83  conversion_identifier.p2_star_client_max = config.conversations[conv_count].p2_star_client_max;
84  conversion_identifier.source_address = config.conversations[conv_count].source_address;
85  conversion_identifier.tcp_address = config.conversations[conv_count].network.tcp_ip_address;
86  conversion_identifier.port_num = 0U; // random selection of port number
87  // push to config map
88  (void) conversation_map_.emplace(config.conversations[conv_count].conversation_name,
89  ConversationStorage{conversion_identifier, nullptr});
90  }
91  }
92 }
std::vector< ConversationType > conversations

References diag::client::conversation::VDConversationType::udp_address.

Member Data Documentation

◆ conversation_map_

std::unordered_map<std::string, ConversationStorage> diag::client::conversation_manager::ConversationManager::conversation_map_
private

Map to store conversation object(dm) along with conversation name.

Definition at line 89 of file conversation_manager.h.

◆ uds_transport_mgr_

uds_transport::UdsTransportProtocolManager& diag::client::conversation_manager::ConversationManager::uds_transport_mgr_
private

Store the reference to uds transport manager.

Definition at line 84 of file conversation_manager.h.


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