HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
observable.hpp
1// Copyright Take Vos 2022.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
4
5#pragma once
6
7#include "group_ptr.hpp"
8#include "../coroutine/module.hpp"
9#include "../macros.hpp"
10#include <memory>
11#include <vector>
12#include <string>
13
14namespace hi::inline v1 {
15
20
21 void const * const ptr;
22 path_type const& path;
23};
24
29class observable : public enable_group_ptr<observable, void(observable_msg)> {
30public:
31 constexpr virtual ~observable() = default;
32 observable(observable const&) = delete;
33 observable(observable&&) = delete;
34 observable& operator=(observable const&) = delete;
35 observable& operator=(observable&&) = delete;
36 constexpr observable() noexcept = default;
37
43 [[nodiscard]] virtual void const *read() const noexcept = 0;
44
51 [[nodiscard]] virtual void *copy(void const *ptr) const noexcept = 0;
52
58 virtual void commit(void *ptr) noexcept = 0;
59
65 virtual void abort(void *ptr) const noexcept = 0;
66
69 virtual void read_lock() const noexcept = 0;
70
73 virtual void read_unlock() const noexcept = 0;
74
77 virtual void write_lock() const noexcept = 0;
78
81 virtual void write_unlock() const noexcept = 0;
82};
83
84} // namespace hi::inline v1
DOXYGEN BUG.
Definition algorithm.hpp:16
constexpr Out narrow_cast(In const &rhs) noexcept
Cast numeric values without loss of precision.
Definition cast.hpp:377
Enable a class to be used in a group_ptr.
Definition group_ptr.hpp:37
Definition observable.hpp:16
An abstract observable object.
Definition observable.hpp:29
virtual void const * read() const noexcept=0
Get a pointer to the current value.