diff options
author | Andrii Kalinich <AKalinich@luxoft.com> | 2018-07-11 23:59:38 +0300 |
---|---|---|
committer | Andrii Kalinich <AKalinich@luxoft.com> | 2018-07-11 23:59:38 +0300 |
commit | ab214008bfeb92248cce1812421b62dc125cfbb7 (patch) | |
tree | d85539a5e64f1ec9ff1238b0f6efdcdb7129fdb3 /src | |
parent | 6ca86cb8ad83b9b75148e067829b9972ea742bb5 (diff) | |
download | sdl_core-ab214008bfeb92248cce1812421b62dc125cfbb7.tar.gz |
Renamed counter and simplified limits logic
Diffstat (limited to 'src')
-rw-r--r-- | src/components/application_manager/include/application_manager/help_prompt_manager_impl.h | 2 | ||||
-rw-r--r-- | src/components/application_manager/src/help_prompt_manager_impl.cc | 26 |
2 files changed, 13 insertions, 15 deletions
diff --git a/src/components/application_manager/include/application_manager/help_prompt_manager_impl.h b/src/components/application_manager/include/application_manager/help_prompt_manager_impl.h index 4af4f82062..176adb6fac 100644 --- a/src/components/application_manager/include/application_manager/help_prompt_manager_impl.h +++ b/src/components/application_manager/include/application_manager/help_prompt_manager_impl.h @@ -164,7 +164,7 @@ class HelpPromptManagerImpl : public HelpPromptManager { VRCommandsMap vr_commands_; sync_primitives::Lock vr_commands_lock_; SendingType sending_type_; - std::size_t count_requests_commands_; + std::size_t count_vr_commands_; bool is_tts_send_; bool is_ui_send_; }; diff --git a/src/components/application_manager/src/help_prompt_manager_impl.cc b/src/components/application_manager/src/help_prompt_manager_impl.cc index e0ee481c17..6581c7edd1 100644 --- a/src/components/application_manager/src/help_prompt_manager_impl.cc +++ b/src/components/application_manager/src/help_prompt_manager_impl.cc @@ -53,7 +53,7 @@ HelpPromptManagerImpl::HelpPromptManagerImpl(Application& app, : app_(app) , app_manager_(app_manager) , sending_type_(SendingType::kSendBoth) - , count_requests_commands_(0) + , count_vr_commands_(0) , is_tts_send_(false) , is_ui_send_(false) {} @@ -75,34 +75,32 @@ bool HelpPromptManagerImpl::AddCommand( return false; } const smart_objects::SmartObject& commands = command[strings::vr_commands]; - - const std::size_t limit = kLimitCommand - count_requests_commands_; const std::size_t count_new_commands = commands.length(); - LOG4CXX_DEBUG(logger_, - "Remaining number of commands: " - << limit << "; commands to add: " << count_new_commands); - if (0 == limit || limit > kLimitCommand) { + LOG4CXX_DEBUG(logger_, "Commands to add: " << count_new_commands); + if (count_vr_commands_ >= kLimitCommand) { LOG4CXX_DEBUG(logger_, "Commands limit is exceeded"); return false; } - const std::size_t count_to_add = - limit > count_new_commands ? count_new_commands : limit; - LOG4CXX_DEBUG(logger_, "Adding " << count_to_add << " commands"); + const std::size_t available_count = kLimitCommand - count_vr_commands_; + const std::size_t count_to_add = available_count > count_new_commands + ? count_new_commands + : available_count; + LOG4CXX_DEBUG(logger_, "Will be added " << count_to_add << " commands"); vr_commands_[cmd_id] = utils::MakeShared<smart_objects::SmartObject>( smart_objects::SmartType_Array); smart_objects::SmartArray& ar_vr_cmd = *(vr_commands_[cmd_id]->asArray()); smart_objects::SmartArray& ar_cmd = *(commands.asArray()); - ar_vr_cmd.reserve(count_requests_commands_ + count_to_add); + ar_vr_cmd.reserve(count_vr_commands_ + count_to_add); ar_vr_cmd.insert( ar_vr_cmd.end(), ar_cmd.begin(), ar_cmd.begin() + count_to_add); LOG4CXX_DEBUG(logger_, "VR commands with id: " << cmd_id << " added for appID: " << app_.app_id()); - count_requests_commands_ += count_to_add; + count_vr_commands_ += count_to_add; return true; } @@ -116,14 +114,14 @@ bool HelpPromptManagerImpl::DeleteCommand(const uint32_t cmd_id) { return false; } - count_requests_commands_ -= it->second->length(); + count_vr_commands_ -= it->second->length(); vr_commands_.erase(it); LOG4CXX_DEBUG( logger_, "VR command with id: " << cmd_id << " deleted for appID: " << app_.app_id() - << ". Remaining number of commands: " << count_requests_commands_); + << ". Remaining number of commands: " << count_vr_commands_); return true; } |