BeeeOn Gateway  v2020.3.1-2-g6f737dc
Platform to interconnect the IoT world
UDevMonitor.h
1 #pragma once
2 
3 #include <list>
4 #include <set>
5 #include <string>
6 
7 #include <Poco/AtomicCounter.h>
8 #include <Poco/Timespan.h>
9 
10 #include "hotplug/AbstractHotplugMonitor.h"
11 #include "loop/StoppableRunnable.h"
12 
13 struct udev;
14 struct udev_device;
15 struct udev_monitor;
16 
17 namespace BeeeOn {
18 
20 public:
21  UDevMonitor();
22  ~UDevMonitor();
23 
24  void run() override;
25  void stop() override;
26 
27  void setMatches(const std::list<std::string> &matches);
28  void setPollTimeout(const Poco::Timespan &timeout);
29  void setIncludeParents(bool enable);
30 
31  void initialScan();
32 
33 private:
34  struct udev_monitor *createMonitor();
35  struct udev_monitor *doCreateMonitor();
36  void collectProperties(
37  HotplugEvent::Properties &event, struct udev_device *dev) const;
38  HotplugEvent createEvent(struct udev_device *dev) const;
39  void scanDevice(struct udev_monitor *mon);
40  void throwFromErrno(const std::string &name);
41 
42 private:
43  std::set<std::string> m_matches;
44  Poco::AtomicCounter m_stop;
45  Poco::Timespan m_pollTimeout;
46  bool m_includeParents;
47  struct udev *m_udev;
48 };
49 
50 }
Definition: UDevMonitor.h:19
Definition: AbstractHotplugMonitor.h:13
Definition: HotplugEvent.h:10
void stop() override
Definition: UDevMonitor.cpp:292
Definition: StoppableRunnable.h:8