FreeRDP
Loading...
Searching...
No Matches
sdl_overlay_model.hpp
1
19
20#pragma once
21
22#include <cstdint>
23#include <optional>
24#include <string>
25#include <unordered_map>
26#include <vector>
27
28/* Turns readings of the client's runtime statistics into the overlay's rows. Nothing here
29 * counts or touches a session, so it is tested without one. */
30namespace sdl::overlay
31{
33 struct Reading
34 {
35 uint64_t ns = 0;
36 std::vector<uint64_t> values;
37 uint32_t desktopWidth = 0;
38 uint32_t desktopHeight = 0;
39 };
40
43 class Names
44 {
45 public:
46 explicit Names(const std::vector<std::string>& names);
47
49 [[nodiscard]] std::optional<uint64_t> get(const Reading& r, const std::string& name) const;
50 [[nodiscard]] bool has(const std::string& name) const;
51
52 private:
53 std::unordered_map<std::string, size_t> _index;
54 };
55
56 struct Row
57 {
58 std::string label;
59 std::string value;
60 };
61
63 struct View
64 {
65 int windowWidth = 0;
66 int windowHeight = 0;
67 uint64_t sessionSeconds = 0;
68 };
69
72 [[nodiscard]] std::vector<Row> realtimeRows(const Names& names, const Reading& now,
73 const Reading* prev, const View& view);
74
75 struct Box
76 {
77 float x = 0;
78 float y = 0;
79 float w = 0;
80 float h = 0;
81 };
82
83 struct Layout
84 {
85 Box left;
86 Box right;
87 };
88
93 [[nodiscard]] Layout layout(float leftWidth, float leftHeight, float rightWidth,
94 float rightHeight, float width, float margin);
95
97 [[nodiscard]] std::string buildSummary(const char* config);
98} // namespace sdl::overlay
std::optional< uint64_t > get(const Reading &r, const std::string &name) const
Layout layout(float leftWidth, float leftHeight, float rightWidth, float rightHeight, float width, float margin)
std::vector< Row > realtimeRows(const Names &names, const Reading &now, const Reading *prev, const View &view)
std::string buildSummary(const char *config)
std::vector< uint64_t > values