diff options
author | Oleksandr Lohvinenko (GitHub) <OLohvinenko@luxoft.com> | 2018-06-05 19:14:29 +0300 |
---|---|---|
committer | Ira Lytvynenko (GitHub) <ILytvynenko@luxoft.com> | 2018-06-26 12:01:47 +0300 |
commit | d1062cd76a0aefb8b80569680605cf5e27237387 (patch) | |
tree | 905d6b67aa459d0360f203b6b068ab389d2a3620 | |
parent | 8300400118aaab59114d953a59ab54bd04231311 (diff) | |
download | sdl_core-d1062cd76a0aefb8b80569680605cf5e27237387.tar.gz |
Fixed command creator logic.
2 files changed, 16 insertions, 38 deletions
diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_hmi_command_factory.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_hmi_command_factory.cc index 5f380826c1..6f40a48679 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_hmi_command_factory.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_hmi_command_factory.cc @@ -104,52 +104,40 @@ bool VehicleInfoHmiCommandFactory::IsAbleToProcess( app_mngr::CommandCreator& VehicleInfoHmiCommandFactory::buildCommandCreator( const int32_t function_id, const int32_t message_type) const { - UNUSED(message_type); - auto factory = app_mngr::CommandCreatorFactory(application_manager_, rpc_service_, hmi_capabilities_, policy_handler_); - auto &creator = factory.GetCreator<app_mngr::InvalidCommand>(); switch (function_id) { case hmi_apis::FunctionID::VehicleInfo_IsReady: - creator = hmi_apis::messageType::request == message_type + return hmi_apis::messageType::request == message_type ? factory.GetCreator<commands::VIIsReadyRequest>() : factory.GetCreator<commands::VIIsReadyResponse>(); - break; case hmi_apis::FunctionID::VehicleInfo_SubscribeVehicleData: - creator = hmi_apis::messageType::request == message_type + return hmi_apis::messageType::request == message_type ? factory.GetCreator<commands::VISubscribeVehicleDataRequest>() : factory.GetCreator<commands::VISubscribeVehicleDataResponse>(); - break; case hmi_apis::FunctionID::VehicleInfo_UnsubscribeVehicleData: - creator = hmi_apis::messageType::request == message_type + return hmi_apis::messageType::request == message_type ? factory.GetCreator<commands::VIUnsubscribeVehicleDataRequest>() : factory.GetCreator<commands::VIUnsubscribeVehicleDataResponse>(); - break; case hmi_apis::FunctionID::VehicleInfo_OnVehicleData: - creator = factory.GetCreator<commands::OnVIVehicleDataNotification>(); - break; + return factory.GetCreator<commands::OnVIVehicleDataNotification>(); case hmi_apis::FunctionID::VehicleInfo_ReadDID: - creator = hmi_apis::messageType::request == message_type + return hmi_apis::messageType::request == message_type ? factory.GetCreator<commands::VIReadDIDRequest>() : factory.GetCreator<commands::VIReadDIDResponse>(); - break; case hmi_apis::FunctionID::VehicleInfo_GetDTCs: - creator = hmi_apis::messageType::request == message_type + return hmi_apis::messageType::request == message_type ? factory.GetCreator<commands::VIGetDTCsRequest>() : factory.GetCreator<commands::VIGetDTCsResponse>(); - break; case hmi_apis::FunctionID::VehicleInfo_DiagnosticMessage: - creator = hmi_apis::messageType::request == message_type + return hmi_apis::messageType::request == message_type ? factory.GetCreator<commands::VIDiagnosticMessageRequest>() : factory.GetCreator<commands::VIDiagnosticMessageResponse>(); - break; default: LOG4CXX_WARN(logger_, "Unsupported function_id: " << function_id); - break; + return factory.GetCreator<app_mngr::InvalidCommand>(); } - - return creator; } } diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_mobile_command_factory.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_mobile_command_factory.cc index e93e4bf208..d98e229d88 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_mobile_command_factory.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_mobile_command_factory.cc @@ -105,48 +105,38 @@ app_mngr::CommandCreator& VehicleInfoMobileCommandFactory::buildCommandCreator( const int32_t function_id, const int32_t message_type) const { auto factory = app_mngr::CommandCreatorFactory(application_manager_, rpc_service_, hmi_capabilities_, policy_handler_); - auto &creator = factory.GetCreator<app_mngr::InvalidCommand>(); switch (function_id) { case mobile_apis::FunctionID::GetVehicleDataID: - creator = mobile_apis::messageType::request == message_type + return mobile_apis::messageType::request == message_type ? factory.GetCreator<commands::GetVehicleDataRequest>() : factory.GetCreator<commands::GetVehicleDataResponse>(); - break; case mobile_apis::FunctionID::SubscribeVehicleDataID: - creator = mobile_apis::messageType::request == message_type + return mobile_apis::messageType::request == message_type ? factory.GetCreator<commands::SubscribeVehicleDataRequest>() : factory.GetCreator<commands::SubscribeVehicleDataResponse>(); - break; case mobile_apis::FunctionID::UnsubscribeVehicleDataID: - creator = mobile_apis::messageType::request == message_type + return mobile_apis::messageType::request == message_type ? factory.GetCreator<commands::UnsubscribeVehicleDataRequest>() : factory.GetCreator<commands::UnsubscribeVehicleDataResponse>(); - break; case mobile_apis::FunctionID::OnVehicleDataID: - creator = factory.GetCreator<commands::OnVehicleDataNotification>(); - break; + return factory.GetCreator<commands::OnVehicleDataNotification>(); case mobile_apis::FunctionID::ReadDIDID: - creator = mobile_apis::messageType::request == message_type + return mobile_apis::messageType::request == message_type ? factory.GetCreator<commands::ReadDIDRequest>() : factory.GetCreator<commands::ReadDIDResponse>(); - break; case mobile_apis::FunctionID::GetDTCsID: - creator = mobile_apis::messageType::request == message_type + return mobile_apis::messageType::request == message_type ? factory.GetCreator<commands::GetDTCsRequest>() : factory.GetCreator<commands::GetDTCsResponse>(); - break; case mobile_apis::FunctionID::DiagnosticMessageID: - creator = mobile_apis::messageType::request == message_type + return mobile_apis::messageType::request == message_type ? factory.GetCreator<commands::DiagnosticMessageRequest>() : factory.GetCreator<commands::DiagnosticMessageResponse>(); - break; default: LOG4CXX_WARN(logger_, "Unsupported function_id: " << function_id); - break; + return factory.GetCreator<app_mngr::InvalidCommand>(); } - - return creator; } } |