| Alexander Hansen | 8c4b1d9 | 2024-11-04 14:06:24 +0100 | [diff] [blame] | 1 | /* | 
|  | 2 | * SPDX-FileCopyrightText: Copyright (c) 2022-2024. All rights | 
|  | 3 | * reserved. SPDX-License-Identifier: Apache-2.0 | 
|  | 4 | */ | 
|  | 5 | #pragma once | 
|  | 6 |  | 
|  | 7 | #include <sdbusplus/async/context.hpp> | 
|  | 8 | #include <sdbusplus/async/task.hpp> | 
|  | 9 |  | 
|  | 10 | namespace gpio_presence | 
|  | 11 | { | 
|  | 12 |  | 
|  | 13 | using AddedCallback = | 
|  | 14 | std::function<void(const sdbusplus::message::object_path&)>; | 
|  | 15 |  | 
|  | 16 | using RemovedCallback = | 
|  | 17 | std::function<void(const sdbusplus::message::object_path&)>; | 
|  | 18 |  | 
|  | 19 | class ConfigProvider | 
|  | 20 | { | 
|  | 21 | public: | 
|  | 22 | explicit ConfigProvider(sdbusplus::async::context& ctx, | 
|  | 23 | const std::string& interface); | 
|  | 24 |  | 
|  | 25 | auto initialize(AddedCallback addConfig, RemovedCallback removeConfig) | 
|  | 26 | -> sdbusplus::async::task<void>; | 
|  | 27 |  | 
|  | 28 | private: | 
|  | 29 | auto getConfig(AddedCallback addConfig) -> sdbusplus::async::task<void>; | 
|  | 30 |  | 
|  | 31 | auto handleInterfacesAdded(AddedCallback addConfig) | 
|  | 32 | -> sdbusplus::async::task<void>; | 
|  | 33 |  | 
|  | 34 | auto handleInterfacesRemoved(RemovedCallback removeConfig) | 
|  | 35 | -> sdbusplus::async::task<void>; | 
|  | 36 |  | 
|  | 37 | // name of the dbus configuration interface | 
|  | 38 | std::string interface; | 
|  | 39 |  | 
|  | 40 | sdbusplus::async::context& ctx; | 
|  | 41 | }; | 
|  | 42 |  | 
|  | 43 | } // namespace gpio_presence |