xref: /openbmc/phosphor-buttons/inc/common.hpp (revision 94afa4bacfda2c86fdccdd2c1a8cbeae3f2129ed)
1a9d39e30SKuiying Wang /*
2a9d39e30SKuiying Wang // Copyright (c) 2018 Intel Corporation
3a9d39e30SKuiying Wang //
4a9d39e30SKuiying Wang // Licensed under the Apache License, Version 2.0 (the "License");
5a9d39e30SKuiying Wang // you may not use this file except in compliance with the License.
6a9d39e30SKuiying Wang // You may obtain a copy of the License at
7a9d39e30SKuiying Wang //
8a9d39e30SKuiying Wang //      http://www.apache.org/licenses/LICENSE-2.0
9a9d39e30SKuiying Wang //
10a9d39e30SKuiying Wang // Unless required by applicable law or agreed to in writing, software
11a9d39e30SKuiying Wang // distributed under the License is distributed on an "AS IS" BASIS,
12a9d39e30SKuiying Wang // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13a9d39e30SKuiying Wang // See the License for the specific language governing permissions and
14a9d39e30SKuiying Wang // limitations under the License.
15a9d39e30SKuiying Wang */
16a9d39e30SKuiying Wang 
17a9d39e30SKuiying Wang #pragma once
180d9377d2SPatrick Venture 
190d9377d2SPatrick Venture #include <systemd/sd-event.h>
200d9377d2SPatrick Venture 
210d9377d2SPatrick Venture #include <memory>
220d9377d2SPatrick Venture 
23a9d39e30SKuiying Wang struct EventDeleter
24a9d39e30SKuiying Wang {
operator ()EventDeleter25a9d39e30SKuiying Wang     void operator()(sd_event* event) const
26a9d39e30SKuiying Wang     {
27*94afa4baSGeorge Liu         sd_event_unref(event);
28a9d39e30SKuiying Wang     }
29a9d39e30SKuiying Wang };
30a9d39e30SKuiying Wang using EventPtr = std::unique_ptr<sd_event, EventDeleter>;
31