BeeeOn Gateway  v2020.3.1-2-g6f737dc
Platform to interconnect the IoT world
PollingKeeper.h
1 #pragma once
2 
3 #include <map>
4 
5 #include <Poco/Mutex.h>
6 
7 #include "core/DevicePoller.h"
8 #include "core/PollableDevice.h"
9 
10 namespace BeeeOn {
11 
18 public:
19  PollingKeeper();
20 
25 
29  void setDevicePoller(DevicePoller::Ptr poller);
30 
35  void schedule(PollableDevice::Ptr device);
36 
41  void cancel(const DeviceID &id);
42 
46  void cancelAll();
47 
51  PollableDevice::Ptr lookup(const DeviceID &id) const;
52 
53 private:
54  std::map<DeviceID, PollableDevice::Ptr> m_polled;
55  DevicePoller::Ptr m_devicePoller;
56  mutable Poco::FastMutex m_lock;
57 };
58 
59 }
void setDevicePoller(DevicePoller::Ptr poller)
Configure DevicePoller to use.
Definition: PollingKeeper.cpp:16
PollingKeeper takes care of devices that are being polled. It cancels all polled devices it manages u...
Definition: PollingKeeper.h:17
void cancelAll()
Cancel all registered pollable devices.
Definition: PollingKeeper.cpp:37
void cancel(const DeviceID &id)
Cancel polling of the device represented by the given ID and unregister it.
Definition: PollingKeeper.cpp:29
PollableDevice::Ptr lookup(const DeviceID &id) const
Lookup a device the PollingKeeper takes care of.
Definition: PollingKeeper.cpp:47
void schedule(PollableDevice::Ptr device)
Register the given device and schedule it into the underlying poller.
Definition: PollingKeeper.cpp:21
~PollingKeeper()
Cancel all registered pollable devices.
Definition: PollingKeeper.cpp:11
Definition: DeviceID.h:17