Patrick Williams | bf0283a | 2023-08-19 07:18:04 -0500 | [diff] [blame] | 1 | #include <net/poettering/Calculator/aserver.hpp> |
| 2 | #include <sdbusplus/async.hpp> |
| 3 | |
| 4 | class 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 Williams | f84f111 | 2023-08-20 19:03:08 -0500 | [diff] [blame] | 16 | auto get_property(last_result_t) const |
| 17 | { |
| 18 | return 42; |
| 19 | } |
| 20 | |
Patrick Williams | 72f7116 | 2023-08-20 21:36:14 -0500 | [diff] [blame^] | 21 | bool set_property(last_result_t, auto) |
| 22 | { |
| 23 | return false; |
| 24 | } |
| 25 | |
Patrick Williams | bf0283a | 2023-08-19 07:18:04 -0500 | [diff] [blame] | 26 | private: |
| 27 | auto startup() -> sdbusplus::async::task<> |
| 28 | { |
| 29 | ctx.get_bus().request_name("net.poettering.Calculator"); |
| 30 | |
Patrick Williams | 72f7116 | 2023-08-20 21:36:14 -0500 | [diff] [blame^] | 31 | status(State::Error); |
| 32 | |
Patrick Williams | bf0283a | 2023-08-19 07:18:04 -0500 | [diff] [blame] | 33 | 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 | |
| 46 | int main() |
| 47 | { |
| 48 | sdbusplus::async::context ctx; |
| 49 | [[maybe_unused]] Calculator c(ctx); |
| 50 | |
| 51 | ctx.run(); |
| 52 | |
| 53 | return 0; |
| 54 | } |