Diag-Client-Lib
diagnostic_client_uds_message_type.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_INCLUDE_DIAGNOSTIC_CLIENT_UDS_MESSAGE_TYPE_H
9 #define DIAGNOSTIC_CLIENT_LIB_APPL_INCLUDE_DIAGNOSTIC_CLIENT_UDS_MESSAGE_TYPE_H
10 
11 #include <cstdint>
12 #include <memory>
13 #include <string>
14 #include <string_view>
15 #include <vector>
16 
17 namespace diag {
18 namespace client {
19 namespace uds_message {
20 
26 class UdsMessage {
27  public:
31  using IpAddress = std::string_view;
32 
36  using ByteVector = std::vector<std::uint8_t>;
37 
38  public:
42  UdsMessage() = default;
43 
47  UdsMessage(const UdsMessage &other) = default;
48 
52  UdsMessage(UdsMessage &&other) noexcept = default;
53 
57  UdsMessage &operator=(const UdsMessage &other) = default;
58 
62  UdsMessage &operator=(UdsMessage &&other) noexcept = default;
63 
67  virtual ~UdsMessage() = default;
68 
74  virtual const ByteVector &GetPayload() const = 0;
75 
81  virtual ByteVector &GetPayload() = 0;
82 
88  virtual IpAddress GetHostIpAddress() const noexcept = 0;
89 };
90 
94 using UdsRequestMessageConstPtr = std::unique_ptr<const UdsMessage>;
95 
99 using UdsRequestMessagePtr = std::unique_ptr<UdsMessage>;
100 
104 using UdsResponseMessagePtr = std::unique_ptr<UdsMessage>;
105 } // namespace uds_message
106 } // namespace client
107 } // namespace diag
108 
109 #endif // DIAGNOSTIC_CLIENT_LIB_APPL_INCLUDE_DIAGNOSTIC_CLIENT_UDS_MESSAGE_TYPE_H
Class represents an UDS message exchanged between User of diag-client-lib and implementation of diag-...
UdsMessage(const UdsMessage &other)=default
Copy constructs an instance of UdsMessage.
UdsMessage & operator=(UdsMessage &&other) noexcept=default
Move assignment of UdsMessage.
std::vector< std::uint8_t > ByteVector
Type alias of byte vector type.
UdsMessage(UdsMessage &&other) noexcept=default
Move constructs an instance of UdsMessage.
UdsMessage & operator=(const UdsMessage &other)=default
Copy assignment of UdsMessage.
UdsMessage()=default
Default constructs an instance of UdsMessage.
virtual const ByteVector & GetPayload() const =0
Get the UDS message data starting with the SID (A_Data as per ISO)
std::string_view IpAddress
Type alias of ip address type.
virtual ByteVector & GetPayload()=0
Return the underlying buffer for write access.
virtual IpAddress GetHostIpAddress() const noexcept=0
Get the remote ip address present.
virtual ~UdsMessage()=default
Destructs an instance of UdsMessage.
std::unique_ptr< UdsMessage > UdsRequestMessagePtr
Type alias of unique_ptr for Request Message.
std::unique_ptr< UdsMessage > UdsResponseMessagePtr
Type alias of unique_ptr for Response Message.
std::unique_ptr< const UdsMessage > UdsRequestMessageConstPtr
Type alias of unique_ptr for constant UdsRequestMessage.