| 1 | // SPDX-License-Identifier: GPL-3.0-or-latercxx . . $ `<file>/src/helper/pmon/appregistry.cpp`/ |
| 2 | // Copyright 2019 Juan Palacios <[email protected]> |
| 3 | |
| 4 | #include "appregistry.h"cxx . . $ `<file>/src/helper/pmon/appregistry.h`/ |
| 5 | |
| 6 | #include <algorithm> |
| 7 | #include <utility> |
| 8 | |
| 9 | void AppRegistrycxx . . $ AppRegistry#::addcxx . . $ AppRegistry#add(9c546c94e5fcce4e).(stdcxx . . $ std/::stringcxx . . $ std/string# const &app) |
| 10 | { |
| 11 | stdcxx . . $ std/::lock_guardcxx . . $ std/lock_guard#<stdcxx . . $ std/::mutexcxx . . $ std/mutex#> lockcxx . . $ std/lock_guard#lock_guard(8e935d9c2e576e3a).(regMutex_cxx . . $ AppRegistry#regMutex_.); |
| 12 | registry_cxx . . $ AppRegistry#registry_..insertcxx . . $ std/unordered_set#insert(5b290ec90abd2511).(app); |
| 13 | notifyRegisteredAppcxx . . $ AppRegistry#notifyRegisteredApp(9c546c94e5fcce4e).(app); |
| 14 | } |
| 15 | |
| 16 | void AppRegistrycxx . . $ AppRegistry#::removecxx . . $ AppRegistry#remove(9c546c94e5fcce4e).(stdcxx . . $ std/::stringcxx . . $ std/string# const &app) |
| 17 | { |
| 18 | stdcxx . . $ std/::lock_guardcxx . . $ std/lock_guard#<stdcxx . . $ std/::mutexcxx . . $ std/mutex#> lockcxx . . $ std/lock_guard#lock_guard(8e935d9c2e576e3a).(regMutex_cxx . . $ AppRegistry#regMutex_.); |
| 19 | if (registry_cxx . . $ AppRegistry#registry_..erasecxx . . $ std/unordered_set#erase(f66b949186d0ad34).(app) > 0) |
| 20 | notifyUnregisteredAppcxx . . $ AppRegistry#notifyUnregisteredApp(9c546c94e5fcce4e).(app); |
| 21 | } |
| 22 | |
| 23 | bool AppRegistrycxx . . $ AppRegistry#::registeredcxx . . $ AppRegistry#registered(7c222eea44a24d43).(stdcxx . . $ std/::stringcxx . . $ std/string# const &app) |
| 24 | { |
| 25 | stdcxx . . $ std/::lock_guardcxx . . $ std/lock_guard#<stdcxx . . $ std/::mutexcxx . . $ std/mutex#> lockcxx . . $ std/lock_guard#lock_guard(8e935d9c2e576e3a).(regMutex_cxx . . $ AppRegistry#regMutex_.); |
| 26 | return registry_cxx . . $ AppRegistry#registry_..findcxx . . $ std/unordered_set#find(2e5c193be73a443f).(app) != registry_cxx . . $ AppRegistry#registry_..endcxx . . $ std/unordered_set#end(2c0786e257a8dc8e).(); |
| 27 | } |
| 28 | |
| 29 | void AppRegistrycxx . . $ AppRegistry#::addObservercxx . . $ AppRegistry#addObserver(2fb1f0ad00763439).(stdcxx . . $ std/::shared_ptrcxx . . $ std/shared_ptr#<IAppRegistrycxx . . $ IAppRegistry#::Observercxx . . $ IAppRegistry#Observer#> observer) |
| 30 | { |
| 31 | stdcxx . . $ std/::lock_guardcxx . . $ std/lock_guard#<stdcxx . . $ std/::mutexcxx . . $ std/mutex#> lockcxx . . $ std/lock_guard#lock_guard(8e935d9c2e576e3a).(obMutex_cxx . . $ AppRegistry#obMutex_.); |
| 32 | |
| 33 | auto const it = stdcxx . . $ std/::findcxx . . $ std/find(a92da12e15934614).(observers_cxx . . $ AppRegistry#observers_..begincxx . . $ std/vector#begin(55a6de06420d4903).(), observers_cxx . . $ AppRegistry#observers_..endcxx . . $ std/vector#end(55a6de06420d4903).(), observer); |
| 34 | if (it ==cxx . . $ __gnu_cxx/`operator==`(d2eded1addd76ab7). observers_cxx . . $ AppRegistry#observers_..endcxx . . $ std/vector#end(55a6de06420d4903).()) |
| 35 | observers_cxx . . $ AppRegistry#observers_..emplace_backcxx . . $ std/vector#emplace_back(a1bcdfdabc3a37df).(stdcxx . . $ std/::movecxx . . $ std/move(e35c19a1ba7baa26).(observer)); |
| 36 | } |
| 37 | |
| 38 | void AppRegistrycxx . . $ AppRegistry#::removeObservercxx . . $ AppRegistry#removeObserver(2dd1568741c60743).( |
| 39 | stdcxx . . $ std/::shared_ptrcxx . . $ std/shared_ptr#<IAppRegistrycxx . . $ IAppRegistry#::Observercxx . . $ IAppRegistry#Observer#> const &observer) |
| 40 | { |
| 41 | stdcxx . . $ std/::lock_guardcxx . . $ std/lock_guard#<stdcxx . . $ std/::mutexcxx . . $ std/mutex#> lockcxx . . $ std/lock_guard#lock_guard(8e935d9c2e576e3a).(obMutex_cxx . . $ AppRegistry#obMutex_.); |
| 42 | stdcxx . . $ std/::erasecxx . . $ std/erase(d1155fb03f0860d).(observers_cxx . . $ AppRegistry#observers_., observer); |
| 43 | } |
| 44 | |
| 45 | void AppRegistrycxx . . $ AppRegistry#::notifyRegisteredAppcxx . . $ AppRegistry#notifyRegisteredApp(9c546c94e5fcce4e).(stdcxx . . $ std/::stringcxx . . $ std/string# const &app) |
| 46 | { |
| 47 | stdcxx . . $ std/::lock_guardcxx . . $ std/lock_guard#<stdcxx . . $ std/::mutexcxx . . $ std/mutex#> lockcxx . . $ std/lock_guard#lock_guard(8e935d9c2e576e3a).(obMutex_cxx . . $ AppRegistry#obMutex_.); |
| 48 | for (auto &o : observers_cxx . . $ AppRegistry#observers_.) |
| 49 | o->cxx . . $ std/__shared_ptr_access#`operator->`(34d6acfd341ba7ab).registeredAppcxx . . $ IAppRegistry#Observer#registeredApp(9c546c94e5fcce4e).(app); |
| 50 | } |
| 51 | |
| 52 | void AppRegistrycxx . . $ AppRegistry#::notifyUnregisteredAppcxx . . $ AppRegistry#notifyUnregisteredApp(9c546c94e5fcce4e).(stdcxx . . $ std/::stringcxx . . $ std/string# const &app) |
| 53 | { |
| 54 | stdcxx . . $ std/::lock_guardcxx . . $ std/lock_guard#<stdcxx . . $ std/::mutexcxx . . $ std/mutex#> lockcxx . . $ std/lock_guard#lock_guard(8e935d9c2e576e3a).(obMutex_cxx . . $ AppRegistry#obMutex_.); |
| 55 | for (auto &o : observers_cxx . . $ AppRegistry#observers_.) |
| 56 | o->cxx . . $ std/__shared_ptr_access#`operator->`(34d6acfd341ba7ab).unregisteredAppcxx . . $ IAppRegistry#Observer#unregisteredApp(9c546c94e5fcce4e).(app); |
| 57 | } |