diff options
author | Conlain Kelly <conlain.k@gmail.com> | 2018-06-18 13:08:41 -0400 |
---|---|---|
committer | Conlain Kelly <conlain.k@gmail.com> | 2018-06-18 13:08:41 -0400 |
commit | a767768447c9e7c7898b5b2847e54aa985fc5041 (patch) | |
tree | df8ef162e679d11de8e7115f495eedc3f87dbac3 /src/components/application_manager/src/app_launch | |
parent | 0dec6ef21fdfd752e33b0364c9e50d27c736371e (diff) | |
download | sdl_core-a767768447c9e7c7898b5b2847e54aa985fc5041.tar.gz |
replace auto_ptr with unique_ptr, refactor device_apps_launcher.cc/.h
Diffstat (limited to 'src/components/application_manager/src/app_launch')
-rw-r--r-- | src/components/application_manager/src/app_launch/app_launch_data_db.cc | 2 | ||||
-rw-r--r-- | src/components/application_manager/src/app_launch/device_apps_launcher.cc | 116 |
2 files changed, 53 insertions, 65 deletions
diff --git a/src/components/application_manager/src/app_launch/app_launch_data_db.cc b/src/components/application_manager/src/app_launch/app_launch_data_db.cc index f3adfc749b..64f9102d90 100644 --- a/src/components/application_manager/src/app_launch/app_launch_data_db.cc +++ b/src/components/application_manager/src/app_launch/app_launch_data_db.cc @@ -384,7 +384,7 @@ bool AppLaunchDataDB::WriteDb() { utils::dbms::SQLDatabase* AppLaunchDataDB::db() const { #ifdef __QNX__ - std::auto_ptr<utils::dbms::SQLDatabase> db_qnx( + std::unique_ptr<utils::dbms::SQLDatabase> db_qnx( new utils::dbms::SQLDatabase(kDatabaseName)); db_qnx.get()->Open(); return db_qnx.get(); diff --git a/src/components/application_manager/src/app_launch/device_apps_launcher.cc b/src/components/application_manager/src/app_launch/device_apps_launcher.cc index 0eb9245cf8..53ab04effd 100644 --- a/src/components/application_manager/src/app_launch/device_apps_launcher.cc +++ b/src/components/application_manager/src/app_launch/device_apps_launcher.cc @@ -59,9 +59,9 @@ class Launcher { device_launcher_.settings().wait_time_between_apps(), timer::kSingleShot); } else { - LOG4CXX_DEBUG(logger_, - "All Apps on " << apps_on_device_->first - << " posponed launched"); + LOG4CXX_DEBUG( + logger_, + "All Apps on " << apps_on_device_->first << " posponed launched"); device_launcher_.StopLaunchingAppsOnDevice(apps_on_device_->first); } } @@ -116,71 +116,59 @@ struct LauncherGenerator { AppsLauncher& apps_launcher_; }; -class DeviceAppsLauncherImpl { - public: - DeviceAppsLauncherImpl(DeviceAppsLauncher& interface, - AppsLauncher& apps_launcher) - : interface_(interface) { - sync_primitives::AutoLock lock(launchers_lock_); - LauncherGenerator generate( - interface.app_mngr_.resume_controller(), interface, apps_launcher); - free_launchers_.reserve(interface.settings_.max_number_of_ios_device()); - std::generate_n(std::back_inserter(free_launchers_), - interface.settings_.max_number_of_ios_device(), - generate); - } - - bool LaunchAppsOnDevice( - const std::string& device_mac, - const std::vector<ApplicationDataPtr>& applications_to_launch) { - LOG4CXX_AUTO_TRACE(logger_); - LOG4CXX_DEBUG(logger_, - "On Device " << device_mac << " will be launched " - << applications_to_launch.size() << " apps"); - AppsOnDevicePtr apps_on_device = - utils::MakeShared<AppsOnDevice>(device_mac, applications_to_launch); - sync_primitives::AutoLock lock(launchers_lock_); - DCHECK_OR_RETURN(!free_launchers_.empty(), false) - const Launchers::iterator it = free_launchers_.begin(); - LauncherPtr launcher = *it; - works_launchers_.push_back(launcher); - free_launchers_.erase(it); - launcher->Start(apps_on_device); - return true; - } +// DeviceAppsLauncherImpl member function definitions +DeviceAppsLauncherImpl::DeviceAppsLauncherImpl(DeviceAppsLauncher& interface, + AppsLauncher& apps_launcher) + : interface_(interface) { + sync_primitives::AutoLock lock(launchers_lock_); + LauncherGenerator generate( + interface.app_mngr_.resume_controller(), interface, apps_launcher); + free_launchers_.reserve(interface.settings_.max_number_of_ios_device()); + std::generate_n(std::back_inserter(free_launchers_), + interface.settings_.max_number_of_ios_device(), + generate); +} - struct LauncherFinder { - LauncherFinder(const std::string& device_mac) : device_mac_(device_mac) {} +bool DeviceAppsLauncherImpl::LauncherFinder::operator()( + const utils::SharedPtr<Launcher>& launcher) const { + return device_mac_ == launcher->apps_on_device_->first; +} - bool operator()(const LauncherPtr& launcher) const { - return device_mac_ == launcher->apps_on_device_->first; - } +bool DeviceAppsLauncherImpl::LaunchAppsOnDevice( + const std::string& device_mac, + const std::vector<ApplicationDataPtr>& applications_to_launch) { + LOG4CXX_AUTO_TRACE(logger_); + LOG4CXX_DEBUG(logger_, + "On Device " << device_mac << " will be launched " + << applications_to_launch.size() << " apps"); + AppsOnDevicePtr apps_on_device = + utils::MakeShared<AppsOnDevice>(device_mac, applications_to_launch); + sync_primitives::AutoLock lock(launchers_lock_); + DCHECK_OR_RETURN(!free_launchers_.empty(), false) + const Launchers::iterator it = free_launchers_.begin(); + LauncherPtr launcher = *it; + works_launchers_.push_back(launcher); + free_launchers_.erase(it); + launcher->Start(apps_on_device); + return true; +} - std::string device_mac_; - }; - - bool StopLaunchingAppsOnDevice(const std::string& device_mac) { - LOG4CXX_AUTO_TRACE(logger_); - sync_primitives::AutoLock lock(launchers_lock_); - const Launchers::iterator it = std::find_if(works_launchers_.begin(), - works_launchers_.end(), - LauncherFinder(device_mac)); - if (it == works_launchers_.end()) { - return false; - } - LauncherPtr launcher = *it; - launcher->Clear(); - free_launchers_.push_back(launcher); - works_launchers_.erase(it); - return true; +bool DeviceAppsLauncherImpl::StopLaunchingAppsOnDevice( + const std::string& device_mac) { + LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock lock(launchers_lock_); + const Launchers::iterator it = std::find_if(works_launchers_.begin(), + works_launchers_.end(), + LauncherFinder(device_mac)); + if (it == works_launchers_.end()) { + return false; } - - private: - sync_primitives::Lock launchers_lock_; - Launchers free_launchers_; - Launchers works_launchers_; - DeviceAppsLauncher& interface_; -}; + LauncherPtr launcher = *it; + launcher->Clear(); + free_launchers_.push_back(launcher); + works_launchers_.erase(it); + return true; +} bool DeviceAppsLauncher::LaunchAppsOnDevice( const std::string& device_mac, |