Matt Spinler | d82a5f4 | 2017-07-24 13:40:37 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <memory> |
| 4 | #include <systemd/sd-event.h> |
| 5 | |
| 6 | namespace witherspoon |
| 7 | { |
| 8 | namespace power |
| 9 | { |
| 10 | namespace event |
| 11 | { |
| 12 | |
| 13 | /** |
| 14 | * Custom deleter for sd_event_source |
| 15 | */ |
| 16 | struct EventSourceDeleter |
| 17 | { |
| 18 | void operator()(sd_event_source* eventSource) const |
| 19 | { |
| 20 | sd_event_source_unref(eventSource); |
| 21 | } |
| 22 | }; |
| 23 | |
| 24 | using EventSource = std::unique_ptr<sd_event_source, EventSourceDeleter>; |
| 25 | |
| 26 | /** |
| 27 | * Customer deleter for sd_event |
| 28 | */ |
| 29 | struct EventDeleter |
| 30 | { |
| 31 | void operator()(sd_event* event) const |
| 32 | { |
| 33 | sd_event_unref(event); |
| 34 | } |
| 35 | }; |
| 36 | |
| 37 | using Event = std::unique_ptr<sd_event, EventDeleter>; |
| 38 | |
| 39 | } |
| 40 | } |
| 41 | } |