summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOleksandr Lohvinenko (GitHub) <OLohvinenko@luxoft.com>2018-06-05 19:14:29 +0300
committerIra Lytvynenko (GitHub) <ILytvynenko@luxoft.com>2018-06-27 18:20:29 +0300
commit937823889d09052b9afbfd0a196564fad24d7055 (patch)
treefca9de5c5a5dfdc06bc70c766240ef13e93d4a57
parentcf13a811ea4062409cebb08fd5989dc0943765d8 (diff)
downloadsdl_core-937823889d09052b9afbfd0a196564fad24d7055.tar.gz
Fixed command creator logic.
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_hmi_command_factory.cc28
-rw-r--r--src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_mobile_command_factory.cc26
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;
}
}