Skip to content

Commit

Permalink
Linting after changing columnlimit to 100
Browse files Browse the repository at this point in the history
  • Loading branch information
Iandiehard committed Aug 8, 2024
1 parent 68eed82 commit d0cb170
Show file tree
Hide file tree
Showing 97 changed files with 1,782 additions and 1,180 deletions.
3 changes: 1 addition & 2 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# Generated from CLion C/C++ Code Style settings
BasedOnStyle: Google
Standard: c++17
AccessModifierOffset: -1
Expand Down Expand Up @@ -35,7 +34,7 @@ BreakBeforeBinaryOperators: None
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakInheritanceList: BeforeColon
ColumnLimit: 120
ColumnLimit: 100
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
CommentPragmas: '^[^ ]'
Expand Down
6 changes: 4 additions & 2 deletions diag-client-lib/appl/include/diag-client/diagnostic_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ class DiagClient final {
* @return Result containing available vehicle information response on success, VehicleResponseErrorCode on error
* @implements DiagClientLib-VehicleDiscovery
*/
Result<vehicle_info::VehicleInfoMessageResponseUniquePtr, VehicleInfoResponseError> SendVehicleIdentificationRequest(
Result<vehicle_info::VehicleInfoMessageResponseUniquePtr, VehicleInfoResponseError>
SendVehicleIdentificationRequest(
diag::client::vehicle_info::VehicleInfoListRequestType vehicle_info_request) noexcept;

/**
Expand All @@ -94,7 +95,8 @@ class DiagClient final {
* @return Diag client conversation object
* @implements DiagClientLib-MultipleTester-Connection, DiagClientLib-Conversation-Construction
*/
conversation::DiagClientConversation GetDiagnosticClientConversation(std::string_view conversation_name) noexcept;
conversation::DiagClientConversation GetDiagnosticClientConversation(
std::string_view conversation_name) noexcept;

private:
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,20 @@ class DiagClientConversation final {
*/
enum class ConnectResult : std::uint8_t {
kConnectSuccess = 0U, /**< Successfully connected to the Diagnostic Server */
kConnectFailed = 1U, /**< Connection failure to the Diagnostic Server, check logs for more failure information */
kConnectFailed =
1U, /**< Connection failure to the Diagnostic Server, check logs for more failure information */
kConnectTimeout = 2U, /**< No Connection response received from the Diagnostic Server */
kTlsRequired = 3U /**< The Diagnostic Server only accepts secured connections, open TLS connection */
kTlsRequired =
3U /**< The Diagnostic Server only accepts secured connections, open TLS connection */
};

/**
* @brief Definitions of Disconnection results
*/
enum class DisconnectResult : std::uint8_t {
kDisconnectSuccess = 0U, /**< Successfully disconnected from Diagnostic Server */
kDisconnectFailed = 1U, /**< Disconnection failure with Diagnostic Server, check logs for more information */
kDisconnectSuccess = 0U, /**< Successfully disconnected from Diagnostic Server */
kDisconnectFailed =
1U, /**< Disconnection failure with Diagnostic Server, check logs for more information */
kAlreadyDisconnected = 2U /**< Not connected to Diagnostic Server */
};

Expand All @@ -54,11 +57,11 @@ class DiagClientConversation final {
enum class DiagError : std::uint8_t {
kDiagGenericFailure = 1U, /**< Generic Diagnostic Error, see logs for more information */
kDiagRequestSendFailed = 2U, /**< Diagnostic request message transmission failure */
kDiagAckTimeout = 3U, /**< No diagnostic acknowledgement response received within 2 seconds */
kDiagNegAckReceived = 4U, /**< Diagnostic negative acknowledgement received */
kDiagResponseTimeout = 5U, /**< No diagnostic response message received within P2/P2Star time */
kDiagInvalidParameter = 6U, /**< Passed parameter value is not valid */
kDiagBusyProcessing = 7U /**< Conversation is already busy processing previous request */
kDiagAckTimeout = 3U, /**< No diagnostic acknowledgement response received within 2 seconds */
kDiagNegAckReceived = 4U, /**< Diagnostic negative acknowledgement received */
kDiagResponseTimeout = 5U, /**< No diagnostic response message received within P2/P2Star time */
kDiagInvalidParameter = 6U, /**< Passed parameter value is not valid */
kDiagBusyProcessing = 7U /**< Conversation is already busy processing previous request */
};

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ namespace diag {
namespace client {
namespace config_parser {

diag::client::config_parser::DcmClientConfig ReadDcmClientConfig(boost_support::parser::boost_tree &config_tree) {
diag::client::config_parser::DcmClientConfig ReadDcmClientConfig(
boost_support::parser::boost_tree &config_tree) {
diag::client::config_parser::DcmClientConfig config{};
// get the udp info for vehicle discovery
config.udp_ip_address = config_tree.get<std::string>("UdpIpAddress");
Expand All @@ -28,7 +29,8 @@ diag::client::config_parser::DcmClientConfig ReadDcmClientConfig(boost_support::
conversation.p2_star_client_max = conversation_ptr.second.get<std::uint16_t>("P2StarClientMax");
conversation.rx_buffer_size = conversation_ptr.second.get<std::uint16_t>("RxBufferSize");
conversation.source_address = conversation_ptr.second.get<std::uint16_t>("SourceAddress");
conversation.network.tcp_ip_address = conversation_ptr.second.get<std::string>("Network.TcpIpAddress");
conversation.network.tcp_ip_address =
conversation_ptr.second.get<std::string>("Network.TcpIpAddress");
conversation.network.tls_handling = conversation_ptr.second.get<bool>("Network.TlsHandling");
config.conversations.emplace_back(conversation);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ struct DcmClientConfig {
* The reference to config tree containing the configuration
* @return The Dcm client configuration
*/
diag::client::config_parser::DcmClientConfig ReadDcmClientConfig(boost_support::parser::boost_tree &config_tree);
diag::client::config_parser::DcmClientConfig ReadDcmClientConfig(
boost_support::parser::boost_tree &config_tree);

} // namespace config_parser
} // namespace client
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ namespace uds_transport {
//ctor
UdsTransportProtocolManager::UdsTransportProtocolManager(
/* pass the protocol kind */)
: doip_transport_handler{std::make_unique<doip_client::transport_protocol_handler::DoipTransportProtocolHandler>(
handler_id_count, *this)} {}
: doip_transport_handler{
std::make_unique<doip_client::transport_protocol_handler::DoipTransportProtocolHandler>(
handler_id_count, *this)} {}

// initialize all the transport protocol handler
void UdsTransportProtocolManager::Startup() {
Expand All @@ -37,7 +38,8 @@ void UdsTransportProtocolManager::Shutdown() {
doip_transport_handler->Stop();
}

::uds_transport::UdsTransportProtocolHandler& UdsTransportProtocolManager::GetTransportProtocolHandler() {
::uds_transport::UdsTransportProtocolHandler&
UdsTransportProtocolManager::GetTransportProtocolHandler() {
return *doip_transport_handler;
}
} // namespace uds_transport
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ class Conversation {
* @param[in] connection
* The conversation connection object
*/
virtual void RegisterConnection(std::unique_ptr<::uds_transport::Connection> connection) noexcept = 0;
virtual void RegisterConnection(
std::unique_ptr<::uds_transport::Connection> connection) noexcept = 0;

/**
* @brief Function to get the conversation handler from conversation object
Expand All @@ -104,14 +105,18 @@ class Conversation {
* @return ConnectResult
* Connection result returned
*/
virtual ConnectResult ConnectToDiagServer(std::uint16_t, IpAddress) noexcept { return ConnectResult::kConnectFailed; }
virtual ConnectResult ConnectToDiagServer(std::uint16_t, IpAddress) noexcept {
return ConnectResult::kConnectFailed;
}

/**
* @brief Function to disconnect from Diagnostic Server
* @return DisconnectResult
* Disconnection result returned
*/
virtual DisconnectResult DisconnectFromDiagServer() noexcept { return DisconnectResult::kDisconnectFailed; }
virtual DisconnectResult DisconnectFromDiagServer() noexcept {
return DisconnectResult::kDisconnectFailed;
}

/**
* @brief Function to indicate a start of reception of message
Expand All @@ -138,10 +143,13 @@ class Conversation {
* The pair of IndicationResult and a pointer to UdsMessage owned/created by DM core and returned
* to the handler to get filled
*/
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,
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 const> payload_info) noexcept = 0;

/**
Expand All @@ -163,7 +171,8 @@ class Conversation {
*/
virtual Result<uds_message::UdsResponseMessagePtr, DiagError> SendDiagnosticRequest(
uds_message::UdsRequestMessageConstPtr) noexcept {
return Result<uds_message::UdsResponseMessagePtr, DiagError>::FromError(DiagError::kDiagRequestSendFailed);
return Result<uds_message::UdsResponseMessagePtr, DiagError>::FromError(
DiagError::kDiagRequestSendFailed);
}

/**
Expand All @@ -175,9 +184,9 @@ class Conversation {
virtual core_type::Result<diag::client::vehicle_info::VehicleInfoMessageResponseUniquePtr,
DiagClient::VehicleInfoResponseError>
SendVehicleIdentificationRequest(vehicle_info::VehicleInfoListRequestType) noexcept {
return core_type::Result<
diag::client::vehicle_info::VehicleInfoMessageResponseUniquePtr,
DiagClient::VehicleInfoResponseError>::FromError(DiagClient::VehicleInfoResponseError::kTransmitFailed);
return core_type::Result<diag::client::vehicle_info::VehicleInfoMessageResponseUniquePtr,
DiagClient::VehicleInfoResponseError>::
FromError(DiagClient::VehicleInfoResponseError::kTransmitFailed);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ void ConversationManager::Startup() noexcept {}

void ConversationManager::Shutdown() noexcept {
// Loop through available conversation and check if already in shutdown state
for (std::unordered_map<std::string, ConversationStorage>::value_type const &conversation: conversation_map_) {
for (std::unordered_map<std::string, ConversationStorage>::value_type const &conversation:
conversation_map_) {
if (conversation.second.conversation != nullptr) {
if (conversation.second.conversation->GetActivityStatus() !=
conversation::Conversation::ActivityStatusType::kInactive) {
Expand All @@ -63,53 +64,63 @@ diag::client::conversation::Conversation &ConversationManager::GetDiagnosticClie
auto it = conversation_map_.find(std::string{conversation_name});
if (it != conversation_map_.end()) {
std::string const conversation_name_in_map{it->first};
it->second.conversation = std::visit(
core_type::visit::overloaded{
[this, &conversation_name_in_map](conversation::DMConversationType conversation_type) noexcept {
// Create the conversation
std::unique_ptr<diag::client::conversation::Conversation> conversation{
std::make_unique<diag::client::conversation::DmConversation>(conversation_name_in_map,
conversation_type)};
// Register the connection
conversation->RegisterConnection(uds_transport_mgr_.GetTransportProtocolHandler().CreateTcpConnection(
conversation->GetConversationHandler(), conversation_type.tcp_address, conversation_type.port_num));
return conversation;
},
[this, &conversation_name_in_map](conversation::VDConversationType conversation_type) noexcept {
// Create the conversation
std::unique_ptr<diag::client::conversation::Conversation> conversation{
std::make_unique<diag::client::conversation::VdConversation>(conversation_name_in_map,
conversation_type)};
// Register the connection
conversation->RegisterConnection(uds_transport_mgr_.GetTransportProtocolHandler().CreateUdpConnection(
conversation->GetConversationHandler(), conversation_type.udp_address, conversation_type.port_num));
return conversation;
}},
it->second.conversation_type);
it->second.conversation =
std::visit(core_type::visit::overloaded{
[this, &conversation_name_in_map](
conversation::DMConversationType conversation_type) noexcept {
// Create the conversation
std::unique_ptr<diag::client::conversation::Conversation> conversation{
std::make_unique<diag::client::conversation::DmConversation>(
conversation_name_in_map, conversation_type)};
// Register the connection
conversation->RegisterConnection(
uds_transport_mgr_.GetTransportProtocolHandler().CreateTcpConnection(
conversation->GetConversationHandler(),
conversation_type.tcp_address, conversation_type.port_num));
return conversation;
},
[this, &conversation_name_in_map](
conversation::VDConversationType conversation_type) noexcept {
// Create the conversation
std::unique_ptr<diag::client::conversation::Conversation> conversation{
std::make_unique<diag::client::conversation::VdConversation>(
conversation_name_in_map, conversation_type)};
// Register the connection
conversation->RegisterConnection(
uds_transport_mgr_.GetTransportProtocolHandler().CreateUdpConnection(
conversation->GetConversationHandler(),
conversation_type.udp_address, conversation_type.port_num));
return conversation;
}},
it->second.conversation_type);
} else {
logger::DiagClientLogger::GetDiagClientLogger().GetLogger().LogFatal(
__FILE__, __LINE__, __func__, [conversation_name](std::stringstream &msg) {
msg << "Invalid conversation name: '" << conversation_name << "', provide correct name as per config file";
msg << "Invalid conversation name: '" << conversation_name
<< "', provide correct name as per config file";
});
}
return *(it->second.conversation);
}

void ConversationManager::StoreConversationConfig(diag::client::config_parser::DcmClientConfig &config) noexcept {
void ConversationManager::StoreConversationConfig(
diag::client::config_parser::DcmClientConfig &config) noexcept {
{ // Create Vehicle discovery config
conversation::VDConversationType conversion_identifier{};
conversion_identifier.udp_address = config.udp_ip_address;
conversion_identifier.udp_broadcast_address = config.udp_broadcast_address;
conversion_identifier.port_num = kRandomPortNumber; // random selection of port number
conversation_map_.emplace(kVdConversationName, ConversationStorage{conversion_identifier, nullptr});
conversation_map_.emplace(kVdConversationName,
ConversationStorage{conversion_identifier, nullptr});
}

{ // Create Conversation config
for (std::uint8_t conv_count{0U}; conv_count < config.num_of_conversation; conv_count++) {
conversation::DMConversationType conversion_identifier{};
conversion_identifier.rx_buffer_size = config.conversations[conv_count].rx_buffer_size;
conversion_identifier.p2_client_max = config.conversations[conv_count].p2_client_max;
conversion_identifier.p2_star_client_max = config.conversations[conv_count].p2_star_client_max;
conversion_identifier.p2_star_client_max =
config.conversations[conv_count].p2_star_client_max;
conversion_identifier.source_address = config.conversations[conv_count].source_address;
conversion_identifier.tcp_address = config.conversations[conv_count].network.tcp_ip_address;
conversion_identifier.port_num = kRandomPortNumber; // random selection of port number
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ class ConversationManager final {
* @param[in] uds_transport_mgr
* The reference to Uds transport manger
*/
ConversationManager(diag::client::config_parser::DcmClientConfig config,
diag::client::uds_transport::UdsTransportProtocolManager &uds_transport_mgr) noexcept;
ConversationManager(
diag::client::config_parser::DcmClientConfig config,
diag::client::uds_transport::UdsTransportProtocolManager &uds_transport_mgr) noexcept;

/**
* @brief Destructs an instance of ConversationManager
Expand Down Expand Up @@ -70,7 +71,8 @@ class ConversationManager final {
/**
* @brief Store conversation type
*/
std::variant<conversation::DMConversationType, conversation::VDConversationType> conversation_type{};
std::variant<conversation::DMConversationType, conversation::VDConversationType>
conversation_type{};

/**
* @brief Store pointer to conversation object
Expand Down
Loading

0 comments on commit d0cb170

Please sign in to comment.