24 #include "PlatformBase.hpp"
26 #include <logger/Logger.hpp>
28 #include "Exception.hpp"
29 #include "device/DeviceStore.hpp"
33 static const std::string s_loggerCat{
"smc:platform"};
35 void PlatformBase::setNotificationWorker(
const NotificationWorker::Shared &worker)
37 m_notificationWorker = worker;
40 void PlatformBase::stop() {}
42 void PlatformBase::notify(
const DeviceId &
id)
44 NotificationWorker::Shared notificationWorker{m_notificationWorker.lock()};
45 if (notificationWorker)
49 notificationWorker->post([
id](
const DeviceStore::Shared &store) {
52 DeviceBase::Shared device = store->getDevice(
id);
54 logger::warning(s_loggerCat) <<
"no such device: " <<
id;
56 device->updateSignal(device);
59 catch (std::exception &ex)
61 logger::warning(s_loggerCat)
62 <<
"failed to post notification: " << ex.what();
67 void PlatformBase::notify(std::set<DeviceId> &¬ifications)
69 NotificationWorker::Shared notificationWorker{m_notificationWorker.lock()};
70 if (notificationWorker && !notifications.empty())
72 std::shared_ptr<std::set<DeviceId>> list{
73 std::make_shared<std::set<DeviceId>>(std::move(notifications))};
77 notificationWorker->post([list](
const DeviceStore::Shared &store) {
80 for (DeviceId
id : *list)
84 DeviceBase::Shared device = store->getDevice(
id);
85 device->updateSignal(device);
89 logger::warning(s_loggerCat) << ex.what();
94 catch (std::exception &ex)
96 logger::warning(s_loggerCat)
97 <<
"failed to post notification: " << ex.what();
main motion-lib namespace