blob: 536ee2588dc2012a623d0a21c2cd26c3b5eaaa7d [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(owner_t) const
17 {
18 return "asdf";
19 }
20
21 auto get_property(last_result_t) const
22 {
23 return 42;
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
31 while (1)
32 {
33 using namespace std::literals;
34 co_await sdbusplus::async::sleep_for(ctx, 10s);
35
36 cleared(42);
37 }
38 co_return;
39 }
40
41 sdbusplus::server::manager_t manager;
42};
43
44int main()
45{
46 sdbusplus::async::context ctx;
47 [[maybe_unused]] Calculator c(ctx);
48
49 ctx.run();
50
51 return 0;
52}