Diag-Client-Lib
conversation.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_DCM_CONVERSATION_CONVERSATION_H
9 #define DIAGNOSTIC_CLIENT_LIB_APPL_SRC_DCM_CONVERSATION_CONVERSATION_H
10 
11 #include "core/include/result.h"
16 
17 namespace diag {
18 namespace client {
19 namespace conversation {
20 
24 class Conversation {
25  public:
30 
35 
40 
45 
49  Conversation() noexcept = default;
50 
54  Conversation(const Conversation &other) noexcept = delete;
55  Conversation &operator=(const Conversation &other) noexcept = delete;
56 
60  Conversation(Conversation &&other) noexcept = delete;
61  Conversation &operator=(Conversation &&other) noexcept = delete;
62 
66  virtual ~Conversation() noexcept = default;
67 
71  virtual void Startup() noexcept = 0;
72 
76  virtual void Shutdown() noexcept = 0;
77 
83  virtual void RegisterConnection(std::unique_ptr<::uds_transport::Connection> connection) noexcept = 0;
84 
90  virtual ::uds_transport::ConversionHandler &GetConversationHandler() noexcept = 0;
91 
101  virtual ConnectResult ConnectToDiagServer(std::uint16_t, IpAddress) noexcept { return ConnectResult::kConnectFailed; }
102 
109 
135  virtual std::pair<::uds_transport::UdsTransportProtocolMgr::IndicationResult, ::uds_transport::UdsMessagePtr>
138  std::size_t size, ::uds_transport::Priority priority, ::uds_transport::ProtocolKind protocol_kind,
139  core_type::Span<std::uint8_t> payload_info) noexcept = 0;
140 
147  virtual void HandleMessage(::uds_transport::UdsMessagePtr message) noexcept = 0;
148 
161  }
162 
172  return core_type::Result<
175  }
176 };
177 
178 } // namespace conversation
179 } // namespace client
180 } // namespace diag
181 
182 #endif // DIAGNOSTIC_CLIENT_LIB_APPL_SRC_DCM_CONVERSATION_CONVERSATION_H
Class type to contains a value (of type ValueType), or an error (of type ErrorType)
Definition: result.h:29
static Result FromError(const E &e) noexcept
Build a new Result from the specified error (given as lvalue)
Definition: result.h:83
VehicleInfoResponseError
Definitions of Vehicle Identification response error code.
Interface for diag client conversation.
Definition: conversation.h:24
DiagClientConversation::IpAddress IpAddress
Type alias for Ip address.
Definition: conversation.h:29
virtual void HandleMessage(::uds_transport::UdsMessagePtr message) noexcept=0
Function to Hands over a valid received Uds message.
virtual ConnectResult ConnectToDiagServer(std::uint16_t, IpAddress) noexcept
Function to connect to Diagnostic Server.
Definition: conversation.h:101
virtual void RegisterConnection(std::unique_ptr<::uds_transport::Connection > connection) noexcept=0
Function to register the conversation to underlying transport protocol handler.
virtual void Shutdown() noexcept=0
Function to shutdown the Conversation.
virtual DisconnectResult DisconnectFromDiagServer() noexcept
Function to disconnect from Diagnostic Server.
Definition: conversation.h:108
virtual std::pair<::uds_transport::UdsTransportProtocolMgr::IndicationResult, ::uds_transport::UdsMessagePtr > IndicateMessage(::uds_transport::UdsMessage::Address source_addr, ::uds_transport::UdsMessage::Address target_addr, ::uds_transport::UdsMessage::TargetAddressType type, ::uds_transport::ChannelID channel_id, std::size_t size, ::uds_transport::Priority priority, ::uds_transport::ProtocolKind protocol_kind, core_type::Span< std::uint8_t > payload_info) noexcept=0
Function to indicate a start of reception of message.
virtual Result< uds_message::UdsResponseMessagePtr, DiagError > SendDiagnosticRequest(uds_message::UdsRequestMessageConstPtr) noexcept
Function to send Diagnostic Request and get Diagnostic Response.
Definition: conversation.h:158
virtual core_type::Result< diag::client::vehicle_info::VehicleInfoMessageResponseUniquePtr, DiagClient::VehicleInfoResponseError > SendVehicleIdentificationRequest(vehicle_info::VehicleInfoListRequestType) noexcept
Function to send vehicle identification request and get the Diagnostic Server list.
Definition: conversation.h:171
virtual ::uds_transport::ConversionHandler & GetConversationHandler() noexcept=0
Function to get the conversation handler from conversation object.
Conversation() noexcept=default
Constructs an instance of Conversation.
virtual void Startup() noexcept=0
Function to start the Conversation.
DiagError
Definitions of Diagnostics Request Response results.
uds_message::UdsMessage::IpAddress IpAddress
Type alias of ip address type.
std::unique_ptr< const UdsMessage > UdsRequestMessageConstPtr
Type alias of unique_ptr for constant UdsRequestMessage.
std::unique_ptr< VehicleInfoMessage > VehicleInfoMessageResponseUniquePtr
The unique_ptr for Vehicle Identification Response Message.
std::string_view ProtocolKind
std::unique_ptr< UdsMessage > UdsMessagePtr
Definition: uds_message.h:71
uint32_t ChannelID
std::uint8_t Priority