Diag-Client-Lib
diagnostic_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 DIAGNOSTIC_CLIENT_LIB_APPL_SRC_COMMON_DIAGNOSTIC_MANAGER_H
9 #define DIAGNOSTIC_CLIENT_LIB_APPL_SRC_COMMON_DIAGNOSTIC_MANAGER_H
10 /* includes */
11 #include <condition_variable>
12 #include <mutex>
13 
14 #include "core/include/result.h"
18 
19 namespace diag {
20 namespace client {
21 // forward declaration
22 namespace conversation {
23 class DiagClientConversation;
24 }
25 
26 namespace common {
27 
32  public:
36  DiagnosticManager() noexcept;
37 
41  DiagnosticManager(const DiagnosticManager &other) noexcept = delete;
42  DiagnosticManager &operator=(const DiagnosticManager &other) noexcept = delete;
43 
47  DiagnosticManager(DiagnosticManager &&other) noexcept = delete;
48  DiagnosticManager &operator=(DiagnosticManager &&other) noexcept = delete;
49 
53  virtual ~DiagnosticManager() noexcept;
54 
58  virtual void Main() noexcept;
59 
63  virtual Result<void> SignalShutdown() noexcept;
64 
68  virtual void Initialize() noexcept = 0;
69 
73  virtual void Run() noexcept = 0;
74 
78  virtual void Shutdown() noexcept = 0;
79 
87  virtual conversation::DiagClientConversation GetDiagnosticClientConversation(
88  std::string_view conversation_name) noexcept = 0;
89 
97  virtual core_type::Result<diag::client::vehicle_info::VehicleInfoMessageResponseUniquePtr,
98  DiagClient::VehicleInfoResponseError>
100  diag::client::vehicle_info::VehicleInfoListRequestType vehicle_info_request) noexcept = 0;
101 
102  private:
107 
111  std::condition_variable cond_var_;
112 
116  std::mutex mutex_;
117 };
118 } // namespace common
119 } // namespace client
120 } // namespace diag
121 #endif // DIAGNOSTIC_CLIENT_LIB_APPL_SRC_COMMON_DIAGNOSTIC_MANAGER_H
Class type to contains a value (of type ValueType), or an error (of type ErrorType)
Definition: result.h:29
Class to manage Diagnostic Client.
Parent class to create Diagnostic Manager.
virtual void Initialize() noexcept=0
Function to initialize the DiagnosticManager.
virtual void Main() noexcept
Function to manage the whole lifecycle of DiagnosticManager.
virtual void Run() noexcept=0
Function to run DiagnosticManager.
virtual void Shutdown() noexcept=0
Function to shutdown the DiagnosticManager.
DiagnosticManager(const DiagnosticManager &other) noexcept=delete
Deleted copy assignment and copy constructor.
DiagnosticManager() noexcept
Constructs an instance of DiagnosticManager.
virtual conversation::DiagClientConversation GetDiagnosticClientConversation(std::string_view conversation_name) noexcept=0
Function to get required diag client conversation object based on conversation name.
bool exit_requested_
Flag to terminate the main thread.
DiagnosticManager & operator=(const DiagnosticManager &other) noexcept=delete
virtual core_type::Result< diag::client::vehicle_info::VehicleInfoMessageResponseUniquePtr, DiagClient::VehicleInfoResponseError > SendVehicleIdentificationRequest(diag::client::vehicle_info::VehicleInfoListRequestType vehicle_info_request) noexcept=0
Function to send vehicle identification request and get the Diagnostic Server list.
std::condition_variable cond_var_
Conditional variable to block the thread.
DiagnosticManager & operator=(DiagnosticManager &&other) noexcept=delete
DiagnosticManager(DiagnosticManager &&other) noexcept=delete
Deleted move assignment and move constructor.
std::mutex mutex_
For locking critical section of code.
virtual ~DiagnosticManager() noexcept
Destructs an instance of DiagnosticManager.
virtual Result< void > SignalShutdown() noexcept
Function to initiate shutdown of DiagnosticManager.
VehicleAddrInfoRequest VehicleInfoListRequestType
Type alias of request storage type used while sending vehicle identification request.
std::unique_ptr< VehicleInfoMessage > VehicleInfoMessageResponseUniquePtr
The unique_ptr for Vehicle Identification Response Message.