morph
0.1.0
Asynchronous bridge between GUI thread and business models
Toggle main menu visibility
Loading...
Searching...
No Matches
change_types.hpp
Go to the documentation of this file.
1
// SPDX-License-Identifier: Apache-2.0
2
3
#pragma once
4
#include <cstddef>
5
#include <cstdint>
6
#include <glaze/glaze.hpp>
7
#include <optional>
8
#include <string>
9
#include <vector>
10
11
/// @file
12
/// The plain data a derived change is made of. This header includes nothing of the registry or the
13
/// forms layer, so the wire types can use it.
14
15
namespace
morph::effects {
16
17
/// @brief The most keys one `RecordChange` carries.
18
///
19
/// The wire readers refuse a record entry with more keys, so a producer never emits one: a change that
20
/// would name more rows is reported as a whole-type change (keys absent), which over-notifies but never
21
/// misses. The bound keeps one peer-supplied list from forcing an unbounded allocation.
22
inline
constexpr
std::size_t
kMaxChangeKeys
= 4096;
23
24
/// @brief A change to the rows of one record type.
25
struct
RecordChange
{
26
/// The record's wire name.
27
std::string
record
;
28
/// The keys of the rows that changed, each as raw JSON; absent when the whole type changed.
29
std::optional<std::vector<glz::raw_json>>
keys
;
30
};
31
32
/// @brief A change to the state of one model instance.
33
struct
InstanceChange
{
34
/// The model's registered type name.
35
std::string
modelType
;
36
/// The instance id.
37
std::uint64_t
instance
= 0;
38
/// The directory key's text for a keyed shared instance; empty for a private one.
39
std::string
primary
;
40
};
41
42
/// @brief What one successful execute changed.
43
struct
Changes
{
44
/// Record topics, one entry per record type.
45
std::vector<RecordChange>
records
;
46
/// Instance topics.
47
std::vector<InstanceChange>
instances
;
48
49
/// @brief Whether nothing changed.
50
/// @return True when there are no record and no instance changes.
51
[[nodiscard]]
bool
empty
()
const
{
return
records
.empty() &&
instances
.empty(); }
52
};
53
54
}
// namespace morph::effects
morph::effects::kMaxChangeKeys
constexpr std::size_t kMaxChangeKeys
The most keys one RecordChange carries.
Definition
change_types.hpp:22
morph::effects::Changes
What one successful execute changed.
Definition
change_types.hpp:43
morph::effects::Changes::records
std::vector< RecordChange > records
Record topics, one entry per record type.
Definition
change_types.hpp:45
morph::effects::Changes::empty
bool empty() const
Whether nothing changed.
Definition
change_types.hpp:51
morph::effects::Changes::instances
std::vector< InstanceChange > instances
Instance topics.
Definition
change_types.hpp:47
morph::effects::InstanceChange
A change to the state of one model instance.
Definition
change_types.hpp:33
morph::effects::InstanceChange::instance
std::uint64_t instance
The instance id.
Definition
change_types.hpp:37
morph::effects::InstanceChange::primary
std::string primary
The directory key's text for a keyed shared instance; empty for a private one.
Definition
change_types.hpp:39
morph::effects::InstanceChange::modelType
std::string modelType
The model's registered type name.
Definition
change_types.hpp:35
morph::effects::RecordChange
A change to the rows of one record type.
Definition
change_types.hpp:25
morph::effects::RecordChange::record
std::string record
The record's wire name.
Definition
change_types.hpp:27
morph::effects::RecordChange::keys
std::optional< std::vector< glz::raw_json > > keys
The keys of the rows that changed, each as raw JSON; absent when the whole type changed.
Definition
change_types.hpp:29
morph
core
change_types.hpp
Generated by
1.17.0