blob: 90547723755c0314c1452e775acf51878b172d0b (
plain)
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
|
#pragma once
#include "statusline_subscriber_adapter.hpp"
#include <utility>
template <typename Context>
StatusLineSubscriberAdapter<Context>::StatusLineSubscriberAdapter(
std::shared_ptr<IStatusManager> status_manager,
std::string (*format_func)(std::size_t section_index, const Context &context),
const std::vector<StatusLineSection> §ions
) noexcept
: _status_manager(std::move(status_manager)),
_format_func(format_func),
_sections(sections)
{
}
template <typename Context>
void StatusLineSubscriberAdapter<Context>::update(const Context &context) noexcept
{
for (std::size_t index = 0; const auto §ion : _sections)
{
auto status = _format_func(index, context);
_status_manager->set_section_body(_sections[index], status);
index++;
}
}
|