blob: 290e0aa0b8aa81c1057d2627d9ce590e0d570e51 [file] [log] [blame]
Patrick Williamsbf0283a2023-08-19 07:18:04 -05001#include <net/poettering/Calculator/aserver.hpp>
2#include <sdbusplus/async.hpp>
3
4class Calculator :
5 public sdbusplus::aserver::net::poettering::Calculator<Calculator>
6{
7 public:
8 explicit Calculator(sdbusplus::async::context& ctx) :
9 sdbusplus::aserver::net::poettering::Calculator<Calculator>(
10 ctx, "/net/poettering/calculator"),
11 manager(ctx, "/")
12 {
13 ctx.spawn(startup());
14 }
15
Patrick Williamsf84f1112023-08-20 19:03:08 -050016 auto get_property(last_result_t) const
17 {
18 return 42;
19 }
20
Patrick Williams72f71162023-08-20 21:36:14 -050021 bool set_property(last_result_t, auto)
22 {
23 return false;
24 }
25
Patrick Williamsbf0283a2023-08-19 07:18:04 -050026 private:
27 auto startup() -> sdbusplus::async::task<>
28 {
29 ctx.get_bus().request_name("net.poettering.Calculator");
30
Patrick Williams72f71162023-08-20 21:36:14 -050031 status(State::Error);
32
Patrick Williamsbf0283a2023-08-19 07:18:04 -050033 while (1)
34 {
35 using namespace std::literals;
36 co_await sdbusplus::async::sleep_for(ctx, 10s);
37
38 cleared(42);
39 }
40 co_return;
41 }
42
43 sdbusplus::server::manager_t manager;
44};
45
46int main()
47{
48 sdbusplus::async::context ctx;
49 [[maybe_unused]] Calculator c(ctx);
50
51 ctx.run();
52
53 return 0;
54}