载入中...
搜索中...
未找到
StateAccess.h
浏览该文件的文档.
1#pragma once
2
8#include "common/Export.h"
9#include "common/Result.h"
10#include "common/Value.h"
11
12#include <cstddef>
13#include <cstdint>
14#include <functional>
15#include <optional>
16#include <span>
17#include <string>
18#include <string_view>
19
20namespace eve::state {
21
23using SubjectId = std::string;
24
26enum class MutationKind : std::uint8_t {
27 Set,
28 Remove,
29 AddTag,
32};
33
44 std::string key;
46 MutationKind kind = MutationKind::Set;
47 bool persistent = false;
48};
49
58 std::string transactionId;
59 std::string correlationId;
60 std::string causationId;
61};
62
65 std::string transactionId;
66 std::size_t changedCount = 0;
67};
68
80public:
81 static constexpr const char* capabilityName = "eve.state.IStateQuery";
83 virtual ~IStateQuery() = default;
84
86 [[nodiscard]] virtual std::optional<eve::Value> value(std::string_view subject, std::string_view key) const = 0;
88 [[nodiscard]] virtual std::optional<bool> hasTag(std::string_view subject, std::string_view tag) const = 0;
90 [[nodiscard]] virtual std::optional<eve::Value> attribute(std::string_view subject, std::string_view key) const = 0;
92 [[nodiscard]] virtual std::optional<eve::Value> resource(std::string_view subject, std::string_view key) const = 0;
94 [[nodiscard]] virtual std::optional<eve::Value> state(std::string_view subject, std::string_view key) const = 0;
96 [[nodiscard]] virtual std::optional<bool> authority(std::string_view subject, std::string_view scope) const = 0;
97};
98
108public:
109 static constexpr const char* capabilityName = "eve.state.IStateMutation";
111 virtual ~IStateMutation() = default;
112
114 [[nodiscard]] virtual eve::Result<MutationReceipt> apply(std::span<const StateMutation> mutations,
115 const MutationContext& context) = 0;
116};
117
118} // namespace eve::state
119
120// Root aliases keep the common capability discoverable alongside existing
121// interfaces such as eve::ISceneQuery while retaining the state namespace as
122// the canonical spelling for new code.
123namespace eve {
130} // namespace eve
int subject
Definition AnimSmr.cpp:163
#define EVENGINE_API_FOUNDATION_INLINE
仅供"只有内联成员"的类型使用的组宏:拥有者 dllexport,消费方不导入。
Definition Export.h:170
std::uint32_t key
JobScope scope
const std::string * tag
Move-only, checked operation results for the common layer.
Owning, renderer-independent dynamic values.
const VegetationPresetContext & context
Move-only operation result carrying either a value or Status.
Definition Result.h:155
The canonical owning dynamic value used by data-facing protocols.
Definition Value.h:31
All-or-nothing mutation boundary owned by the consumer.
virtual ~IStateMutation()=default
I state mutation.
virtual eve::Result< MutationReceipt > apply(std::span< const StateMutation > mutations, const MutationContext &context)=0
Apply a complete mutation set atomically.
Read-only world-state boundary owned by consumers such as Dialogue.
Definition StateAccess.h:79
virtual std::optional< eve::Value > state(std::string_view subject, std::string_view key) const =0
Query a persistent/world state value.
virtual std::optional< bool > hasTag(std::string_view subject, std::string_view tag) const =0
Query exact tag membership.
virtual ~IStateQuery()=default
I state query.
virtual std::optional< eve::Value > resource(std::string_view subject, std::string_view key) const =0
Query a resource value or marker.
virtual std::optional< bool > authority(std::string_view subject, std::string_view scope) const =0
Query read-only authority for a scope.
virtual std::optional< eve::Value > value(std::string_view subject, std::string_view key) const =0
Query a generic world value.
virtual std::optional< eve::Value > attribute(std::string_view subject, std::string_view key) const =0
Query a numeric or structured attribute.
MutationKind
Kind of one requested world-state mutation.
Definition StateAccess.h:26
std::string SubjectId
Stable textual identity used at a cross-module state boundary.
Definition StateAccess.h:23
Build metadata (engine git commit, build time, third-party version).
Definition Build.cpp:16
Correlation metadata shared by a mutation transaction.
Definition StateAccess.h:57
Observable result of an all-or-nothing mutation request.
Definition StateAccess.h:64
One immutable mutation request owned by its caller.
Definition StateAccess.h:42