OGLplus  (0.59.0) a C++ wrapper for rendering APIs

remote_node.hpp
Go to the documentation of this file.
1 
9 #ifndef EAGINE_LOGGING_TYPE_REMOTE_NODE_HPP
10 #define EAGINE_LOGGING_TYPE_REMOTE_NODE_HPP
11 
12 #include "../../message_bus/remote_node.hpp"
13 #include "build_info.hpp"
14 #include "yes_no_maybe.hpp"
15 
16 namespace eagine {
17 //------------------------------------------------------------------------------
18 static inline auto
19 adapt_log_entry_arg(identifier name, const msgbus::remote_node& value) {
20  return [name, value](logger_backend& backend) {
21  backend.add_unsigned(
22  name, EAGINE_ID(uint64), extract_or(value.id(), 0U));
23 
24  if(auto opt_id{value.instance_id()}) {
25  backend.add_unsigned(
26  EAGINE_ID(instanceId), EAGINE_ID(uint32), extract(opt_id));
27  }
28 
29  backend.add_string(
30  EAGINE_ID(nodeKind), EAGINE_ID(enum), enumerator_name(value.kind()));
31 
32  backend.add_adapted(
33  EAGINE_ID(isRutrNode), yes_no_maybe(value.is_router_node()));
34  backend.add_adapted(
35  EAGINE_ID(isBrdgNode), yes_no_maybe(value.is_bridge_node()));
36  backend.add_adapted(
37  EAGINE_ID(isPingable), yes_no_maybe(value.is_pingable()));
38  backend.add_adapted(
39  EAGINE_ID(isRespnsve), yes_no_maybe(value.is_responsive()));
40 
41  if(const auto opt_rate{value.ping_success_rate()}) {
42  backend.add_float(
43  EAGINE_ID(pingSucces), EAGINE_ID(Ratio), extract(opt_rate));
44  }
45  if(const auto opt_bld{value.instance().build()}) {
46  backend.add_adapted(EAGINE_ID(buildInfo), extract(opt_bld));
47  }
48 
49  if(const auto opt_name{value.app_name()}) {
50  backend.add_string(
51  EAGINE_ID(applName), EAGINE_ID(string), extract(opt_name));
52  }
53 
54  if(const auto opt_name{value.display_name()}) {
55  backend.add_string(
56  EAGINE_ID(dispName), EAGINE_ID(string), extract(opt_name));
57  }
58 
59  if(const auto opt_desc{value.description()}) {
60  backend.add_string(
61  EAGINE_ID(descrption), EAGINE_ID(string), extract(opt_desc));
62  }
63  };
64 }
65 //------------------------------------------------------------------------------
66 static inline auto
67 adapt_log_entry_arg(identifier name, const msgbus::remote_host& value) {
68  return [name, value](logger_backend& backend) {
69  backend.add_unsigned(
70  name, EAGINE_ID(uint64), extract_or(value.id(), 0U));
71 
72  if(const auto opt_name{value.name()}) {
73  backend.add_string(
74  EAGINE_ID(hostname), EAGINE_ID(string), extract(opt_name));
75  }
76 
77  if(const auto opt_val{value.cpu_concurrent_threads()}) {
78  backend.add_integer(
79  EAGINE_ID(cpuThreads), EAGINE_ID(int64), extract(opt_val));
80  }
81  if(const auto opt_val{value.total_ram_size()}) {
82  backend.add_integer(
83  EAGINE_ID(totalRAM), EAGINE_ID(ByteSize), extract(opt_val));
84  }
85  if(const auto opt_val{value.free_ram_size()}) {
86  backend.add_integer(
87  EAGINE_ID(freeRAM), EAGINE_ID(ByteSize), extract(opt_val));
88  }
89  if(const auto opt_val{value.free_swap_size()}) {
90  backend.add_integer(
91  EAGINE_ID(freeSwap), EAGINE_ID(ByteSize), extract(opt_val));
92  }
93  if(const auto opt_val{value.total_swap_size()}) {
94  backend.add_integer(
95  EAGINE_ID(totalSwap), EAGINE_ID(ByteSize), extract(opt_val));
96  }
97  if(const auto opt_val{value.ram_usage()}) {
98  backend.add_float(
99  EAGINE_ID(ramUsage), EAGINE_ID(Ratio), extract(opt_val));
100  }
101  if(const auto opt_val{value.swap_usage()}) {
102  backend.add_float(
103  EAGINE_ID(swapUsage), EAGINE_ID(Ratio), extract(opt_val));
104  }
105  if(const auto opt_val{value.short_average_load()}) {
106  backend.add_float(
107  EAGINE_ID(shortLoad), EAGINE_ID(Ratio), extract(opt_val));
108  }
109  if(const auto opt_val{value.long_average_load()}) {
110  backend.add_float(
111  EAGINE_ID(longLoad), EAGINE_ID(Ratio), extract(opt_val));
112  }
113  };
114 }
115 //------------------------------------------------------------------------------
116 } // namespace eagine
117 
118 #endif // EAGINE_LOGGING_TYPE_REMOTE_NODE_HPP
#define EAGINE_ID(NAME)
Macro for constructing instances of eagine::identifier.
Definition: identifier.hpp:353
Common code is placed in this namespace.
Definition: eagine.hpp:21
static constexpr auto extract(api_result_value< Result, api_result_validity::never > &) noexcept -> Result &
Overload of extract for api_result_value.
Definition: c_api_wrap.hpp:270
basic_identifier< 10, 6, default_identifier_char_set, identifier_t > identifier
Default identifier type used throughout the project.
Definition: identifier.hpp:346

Copyright © 2015-2021 Matúš Chochlík.
<chochlik -at -gmail.com>
Documentation generated on Tue Apr 13 2021 by Doxygen (version 1.8.17).