blob: 4bacfc7c25d2d6238bd46cc90773be08bbe0b7a5 [file] [log] [blame]
Alexander Hansen8c4b1d92024-11-04 14:06:24 +01001/*
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
10namespace gpio_presence
11{
12
13using AddedCallback =
14 std::function<void(const sdbusplus::message::object_path&)>;
15
16using RemovedCallback =
17 std::function<void(const sdbusplus::message::object_path&)>;
18
19class 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