Diag-Client-Lib
Public Member Functions | Private Attributes | List of all members
diag::client::DiagClient::DiagClientImpl Class Referencefinal

Class to provide implementation of diag client. More...

Public Member Functions

 DiagClientImpl (std::string_view diag_client_config_path) noexcept
 Constructs an instance of DiagClient. More...
 
 DiagClientImpl (const DiagClientImpl &other) noexcept=delete
 Deleted copy assignment and copy constructor. More...
 
DiagClientImploperator= (const DiagClientImpl &other) noexcept=delete
 
 DiagClientImpl (DiagClientImpl &&other) noexcept=delete
 Deleted move assignment and move constructor. More...
 
DiagClientImploperator= (DiagClientImpl &&other) noexcept=delete
 
 ~DiagClientImpl () noexcept=default
 Destruct an instance of DiagClient -Destruction. More...
 
Result< void > Initialize () noexcept
 Function to initialize the already created instance of DiagClient. More...
 
Result< void > DeInitialize () noexcept
 Function to de-initialize the already initialized instance of DiagClient. More...
 
conversation::DiagClientConversation GetDiagnosticClientConversation (std::string_view conversation_name) noexcept
 Function to get required diag client conversation object based on conversation name. More...
 
Result< vehicle_info::VehicleInfoMessageResponseUniquePtr, DiagClient::VehicleInfoResponseErrorSendVehicleIdentificationRequest (diag::client::vehicle_info::VehicleInfoListRequestType vehicle_info_request) noexcept
 Function to send vehicle identification request and get the Diagnostic Server list. More...
 

Private Attributes

std::unique_ptr< diag::client::common::DiagnosticManagerdcm_instance_
 Unique pointer to dcm client instance. More...
 
std::thread dcm_thread_
 Thread to handle dcm client lifecycle. More...
 
std::string diag_client_config_path_
 Store the diag client config path. More...
 

Detailed Description

Class to provide implementation of diag client.

Definition at line 29 of file diagnostic_client.cpp.

Constructor & Destructor Documentation

◆ DiagClientImpl() [1/3]

diag::client::DiagClient::DiagClientImpl::DiagClientImpl ( std::string_view  diag_client_config_path)
inlineexplicitnoexcept

Constructs an instance of DiagClient.

Parameters
[in]diag_client_config_pathThe path to diag client config file -Construction

Definition at line 37 of file diagnostic_client.cpp.

38  : dcm_instance_{},
39  dcm_thread_{},
40  diag_client_config_path_{diag_client_config_path} {}
std::thread dcm_thread_
Thread to handle dcm client lifecycle.
std::unique_ptr< diag::client::common::DiagnosticManager > dcm_instance_
Unique pointer to dcm client instance.
std::string diag_client_config_path_
Store the diag client config path.

◆ DiagClientImpl() [2/3]

diag::client::DiagClient::DiagClientImpl::DiagClientImpl ( const DiagClientImpl other)
deletenoexcept

Deleted copy assignment and copy constructor.

◆ DiagClientImpl() [3/3]

diag::client::DiagClient::DiagClientImpl::DiagClientImpl ( DiagClientImpl &&  other)
deletenoexcept

Deleted move assignment and move constructor.

◆ ~DiagClientImpl()

diag::client::DiagClient::DiagClientImpl::~DiagClientImpl ( )
defaultnoexcept

Destruct an instance of DiagClient -Destruction.

Member Function Documentation

◆ DeInitialize()

Result<void> diag::client::DiagClient::DiagClientImpl::DeInitialize ( )
inlinenoexcept

Function to de-initialize the already initialized instance of DiagClient.

Must be called during shutdown phase, no further processing of any function will be allowed after this call

Returns
Result with void in case of success, otherwise error is returned -DeInitialization

Definition at line 96 of file diagnostic_client.cpp.

96  {
98  __FILE__, __LINE__, __func__, [](std::stringstream &msg) { msg << "DiagClient De-Initialization started"; });
99  // shutdown DCM module here
100  return dcm_instance_->SignalShutdown()
101  .AndThen([this]() {
102  if (dcm_thread_.joinable()) { dcm_thread_.join(); }
103  logger::DiagClientLogger::GetDiagClientLogger().GetLogger().LogInfo(
104  __FILE__, __LINE__, "", [](std::stringstream &msg) { msg << "DiagClient De-Initialization completed"; });
105  })
106  .OrElse([](core_type::ErrorCode const &) {
108  });
109  }
Encapsulation of an error code. An ErrorCode contains a raw error code value and an error domain....
Definition: error_code.h:22
static auto GetDiagClientLogger() noexcept -> DiagClientLogger &
Get the diag client logger instance.
Definition: logger.h:32
core_type::ErrorCode MakeErrorCode(DmErrorErrc, core_type::ErrorDomain::SupportDataType data) noexcept
Create a new ErrorCode within DmErrorDomain.

References dcm_instance_, dcm_thread_, diag::client::logger::DiagClientLogger::GetDiagClientLogger(), diag::client::error_domain::kDeInitializationFailed, and diag::client::error_domain::MakeErrorCode().

Here is the call graph for this function:

◆ GetDiagnosticClientConversation()

conversation::DiagClientConversation diag::client::DiagClient::DiagClientImpl::GetDiagnosticClientConversation ( std::string_view  conversation_name)
inlinenoexcept

Function to get required diag client conversation object based on conversation name.

Parameters
[in]conversation_nameName of conversation configured as json parameter "ConversationName"
Returns
Diag client conversation object as per passed conversation name -MultipleTester-Connection, DiagClientLib-Conversation-Construction

Definition at line 118 of file diagnostic_client.cpp.

118  {
119  if (!dcm_instance_) {
120  logger::DiagClientLogger::GetDiagClientLogger().GetLogger().LogFatal(
121  __FILE__, __LINE__, "", [](std::stringstream &msg) { msg << "DiagClient is not Initialized"; });
122  }
123  return dcm_instance_->GetDiagnosticClientConversation(conversation_name);
124  }

References dcm_instance_, and diag::client::logger::DiagClientLogger::GetDiagClientLogger().

Here is the call graph for this function:

◆ Initialize()

Result<void> diag::client::DiagClient::DiagClientImpl::Initialize ( )
inlinenoexcept

Function to initialize the already created instance of DiagClient.

Must be called once and before using any other functions of DiagClient

Returns
Result with void in case of success, otherwise error is returned -Initialization

Definition at line 66 of file diagnostic_client.cpp.

66  {
68  __FILE__, __LINE__, __func__, [](std::stringstream &msg) { msg << "DiagClient Initialization started"; });
69 
70  // read configuration
73  .MapError([](boost_support::parser::ParsingErrorCode const &) noexcept {
74  logger::DiagClientLogger::GetDiagClientLogger().GetLogger().LogError(
75  __FILE__, __LINE__, "", [](std::stringstream &msg) { msg << "DiagClient Initialization failed"; });
77  })
78  .AndThen([this, &config]() {
79  // create single dcm instance and pass the configuration
80  dcm_instance_ = std::make_unique<diag::client::dcm::DCMClient>(config_parser::ReadDcmClientConfig(config));
81  // start dcm client thread
82  dcm_thread_ = std::thread([this]() noexcept { this->dcm_instance_->Main(); });
83  pthread_setname_np(dcm_thread_.native_handle(), "dcm_client");
85  __FILE__, __LINE__, "", [](std::stringstream &msg) { msg << "DiagClient Initialization completed"; });
86  });
87  }
ParsingErrorCode
Definitions of Parsing failure error codes.
Definition: json_parser.h:28
core_type::Result< void, ParsingErrorCode > Read(std::string_view config_path, boost_tree &json_tree)
Parser to get the configuration from json file.
Definition: json_parser.cpp:16
boost::property_tree::ptree boost_tree
Type alias for boost property tree.
Definition: json_parser.h:23
diag::client::config_parser::DcmClientConfig ReadDcmClientConfig(boost_support::parser::boost_tree &config_tree)
Function to read from config tree and get the DcmClient configuration.

References dcm_instance_, dcm_thread_, diag_client_config_path_, diag::client::logger::DiagClientLogger::GetDiagClientLogger(), diag::client::error_domain::kInitializationFailed, diag::client::error_domain::MakeErrorCode(), boost_support::parser::Read(), and diag::client::config_parser::ReadDcmClientConfig().

Here is the call graph for this function:

◆ operator=() [1/2]

DiagClientImpl& diag::client::DiagClient::DiagClientImpl::operator= ( const DiagClientImpl other)
deletenoexcept

◆ operator=() [2/2]

DiagClientImpl& diag::client::DiagClient::DiagClientImpl::operator= ( DiagClientImpl &&  other)
deletenoexcept

◆ SendVehicleIdentificationRequest()

Result<vehicle_info::VehicleInfoMessageResponseUniquePtr, DiagClient::VehicleInfoResponseError> diag::client::DiagClient::DiagClientImpl::SendVehicleIdentificationRequest ( diag::client::vehicle_info::VehicleInfoListRequestType  vehicle_info_request)
inlinenoexcept

Function to send vehicle identification request and get the Diagnostic Server list.

Parameters
[in]vehicle_info_requestVehicle information sent along with request
Returns
Result containing available vehicle information response on success, VehicleResponseErrorCode on error -VehicleDiscovery

Definition at line 134 of file diagnostic_client.cpp.

135  {
136  if (!dcm_instance_) {
137  logger::DiagClientLogger::GetDiagClientLogger().GetLogger().LogFatal(
138  __FILE__, __LINE__, "", [](std::stringstream &msg) { msg << "DiagClient is not Initialized"; });
139  }
140  return dcm_instance_->SendVehicleIdentificationRequest(std::move(vehicle_info_request));
141  }

References dcm_instance_, and diag::client::logger::DiagClientLogger::GetDiagClientLogger().

Here is the call graph for this function:

Member Data Documentation

◆ dcm_instance_

std::unique_ptr<diag::client::common::DiagnosticManager> diag::client::DiagClient::DiagClientImpl::dcm_instance_
private

Unique pointer to dcm client instance.

Definition at line 147 of file diagnostic_client.cpp.

Referenced by DeInitialize(), GetDiagnosticClientConversation(), Initialize(), and SendVehicleIdentificationRequest().

◆ dcm_thread_

std::thread diag::client::DiagClient::DiagClientImpl::dcm_thread_
private

Thread to handle dcm client lifecycle.

Definition at line 152 of file diagnostic_client.cpp.

Referenced by DeInitialize(), and Initialize().

◆ diag_client_config_path_

std::string diag::client::DiagClient::DiagClientImpl::diag_client_config_path_
private

Store the diag client config path.

Definition at line 157 of file diagnostic_client.cpp.

Referenced by Initialize().


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