-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
51 lines (39 loc) · 1.11 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <iostream>
#include <tfc/ipc.hpp>
#include <tfc/confman.hpp>
#include <tfc/logger.hpp>
#include <tfc/progbase.hpp>
#include <boost/asio.hpp>
#include <glaze/glaze.hpp>
namespace asio = boost::asio;
struct storage {
int a{};
double b{};
struct glaze {
static auto constexpr value{glz::object("a_key", &storage::a, "b_key", &storage::b)};
static auto constexpr name{"app_storage"}; // used for json schema
};
};
class App {
public:
App(asio::io_context &ctx) :
bool_slot_{ctx, "slot_name", []([[maybe_unused]] bool new_state) {
fmt::print("{}\n", new_state);
}},
json_signal_{ctx, "signal_name"},
config_{ctx, "app"},
logger_{"app"} {}
private:
tfc::ipc::bool_slot bool_slot_;
tfc::ipc::json_signal json_signal_;
tfc::confman::config<storage> config_;
tfc::logger::logger logger_;
};
int main(int argc, char **argv) {
tfc::base::init(argc, argv);
asio::io_context ctx;
[[maybe_unused]] auto const app{ App(ctx) };
asio::co_spawn(ctx, tfc::base::exit_signals(ctx), asio::detached);
ctx.run();
return EXIT_SUCCESS;
}