diff options
author | jacobkeeler <jacob.keeler@livioradio.com> | 2019-02-08 16:42:22 -0500 |
---|---|---|
committer | jacobkeeler <jacob.keeler@livioradio.com> | 2019-02-08 16:42:22 -0500 |
commit | 592d4e335c97332fd49678be804970f93d92a985 (patch) | |
tree | bd4786bee366634395f3f3eb720f651f568051ea /src/components/application_manager | |
parent | 35db01e868d559fe4395f2e6c6709d22a862b8a1 (diff) | |
download | sdl_core-592d4e335c97332fd49678be804970f93d92a985.tar.gz |
Add functions for finding services.
Diffstat (limited to 'src/components/application_manager')
-rw-r--r-- | src/components/application_manager/include/application_manager/app_service_manager.h | 7 | ||||
-rw-r--r-- | src/components/application_manager/src/app_service_manager.cc | 27 |
2 files changed, 33 insertions, 1 deletions
diff --git a/src/components/application_manager/include/application_manager/app_service_manager.h b/src/components/application_manager/include/application_manager/app_service_manager.h index a6cd0efcf8..736302dbc2 100644 --- a/src/components/application_manager/include/application_manager/app_service_manager.h +++ b/src/components/application_manager/include/application_manager/app_service_manager.h @@ -72,7 +72,7 @@ class AppServiceManager { /** * @brief TODO - * @param manifest + * @param service_id */ bool UnpublishAppService(const std::string service_id); @@ -82,6 +82,11 @@ class AppServiceManager { */ std::vector<smart_objects::SmartObject> GetAllServices(); + std::pair<std::string, AppService> ActiveServiceByType( + std::string service_type); + + std::pair<std::string, AppService> FindServiceByName(std::string name); + private: ApplicationManager& app_manager_; std::map<std::string, AppService> published_services_; diff --git a/src/components/application_manager/src/app_service_manager.cc b/src/components/application_manager/src/app_service_manager.cc index 7d91a3cbe5..c52e6a12f1 100644 --- a/src/components/application_manager/src/app_service_manager.cc +++ b/src/components/application_manager/src/app_service_manager.cc @@ -106,4 +106,31 @@ std::vector<smart_objects::SmartObject> AppServiceManager::GetAllServices() { return services; } + +std::pair<std::string, AppService> AppServiceManager::ActiveServiceByType( + std::string service_type) { + for (auto it = published_services_.begin(); it != published_services_.end(); + ++it) { + if (it->second.record[strings::app_service_manifest][strings::service_type] + .asString() == service_type && + it->second.record[strings::service_active].asBool()) { + return *it; + } + } + AppService empty; + return std::make_pair(std::string(), empty); +} + +std::pair<std::string, AppService> AppServiceManager::FindServiceByName( + std::string name) { + for (auto it = published_services_.begin(); it != published_services_.end(); + ++it) { + if (it->second.record[strings::app_service_manifest][strings::service_name] + .asString() == name) { + return *it; + } + } + AppService empty; + return std::make_pair(std::string(), empty); +} } // namespace application_manager |