HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
observable_cast_format10.hpp
1// Copyright 2020 Pokitec
2// All rights reserved.
3
4#pragma once
5
6#include "TTauri/Foundation/detail/observable_cast.hpp"
7#include "TTauri/Text/language.hpp"
8
9namespace tt::detail {
10
11template<>
12class observable_cast<std::string,tt::format10> final : public observable_unary<std::string,tt::format10> {
13private:
14 size_t language_list_cbid;
15 mutable int count = 0;
16public:
19 {
20 language_list_cbid = language::preferred_languages.add_callback([this](auto...) {
21 ++count;
22 notify({}, load());
23 });
24 }
25
27 language::preferred_languages.remove_callback(language_list_cbid);
28 }
29
30 virtual std::string load() const noexcept override {
31 ttlet lock = std::scoped_lock(observable_unary<std::string,tt::format10>::mutex);
32 return static_cast<std::string>(operand_cache);
33 }
34
35 virtual bool store(std::string const &new_value) noexcept override {
36 tt_no_default;
37 }
38};
39
40}
STL namespace.
Observable abstract base class.
Definition observable_base.hpp:29
size_t add_callback(callback_type callback) noexcept
Add a callback as a listener.
Definition observable_base.hpp:116
void remove_callback(size_t id) noexcept
Remove a callback.
Definition observable_base.hpp:123
Definition observable_cast.hpp:11
virtual T load() const noexcept override
Get the current value.
Definition observable_cast.hpp:16
virtual bool store(T const &new_value) noexcept override
Set the value.
Definition observable_cast.hpp:21
Definition observable_unary.hpp:11
virtual std::string load() const noexcept override
Get the current value.
Definition observable_cast_format10.hpp:30
Definition format10.hpp:98