载入中...
搜索中...
未找到
EvpackRegistry.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4
11
12#include <map>
13#include <memory>
14#include <mutex>
15#include <functional>
16
17namespace eve::asset {
18
23 std::uint64_t generation = 0;
24
26 friend bool operator==(const EvpackHandle&, const EvpackHandle&) noexcept = default;
27};
28
32 std::uint32_t chunkIndex = 0;
33};
34
42
46 bool replacedExisting = false;
47 std::vector<Diagnostic> callbackDiagnostics;
48};
49
51enum class EvpackRegistryEventKind : std::uint8_t { Mounted, Replaced, Unmounted };
52
58
61 std::uint64_t value = 0;
64 const EvpackRegistrySubscription&) noexcept = default;
65};
66
70 std::vector<Diagnostic> callbackDiagnostics;
71};
72
78public:
82 PreparedEvpackMount& operator=(PreparedEvpackMount&&) noexcept = default;
84 PreparedEvpackMount& operator=(const PreparedEvpackMount&) = delete;
85
87 [[nodiscard]] const PersistentId& packageId() const noexcept { return pack_->packageId(); }
89 [[nodiscard]] const PersistentId& buildId() const noexcept { return pack_->buildId(); }
90
91private:
93 const EvpackLimits&,
94 const EvpackTrust&);
95 friend class EvpackRegistry;
96 explicit PreparedEvpackMount(std::shared_ptr<const Evpack> pack) : pack_(std::move(pack)) {}
97 std::shared_ptr<const Evpack> pack_;
98};
99
109 std::span<const std::uint8_t> bytes, const EvpackLimits& limits = {}, const EvpackTrust& trust = {});
110
113public:
114 using Callback = std::function<Result<void>(const EvpackRegistryEvent&)>;
115
122
124 [[nodiscard]] Result<void> unsubscribe(EvpackRegistrySubscription subscription);
125
133 [[nodiscard]] Result<EvpackMountReceipt> commit(PreparedEvpackMount candidate);
134
136 [[nodiscard]] Result<std::shared_ptr<const Evpack>> resolve(const EvpackHandle& handle) const;
137
143 [[nodiscard]] Result<EvpackAssetHandle> resolveAsset(
144 const AssetRef& asset, std::string_view expectedType,
145 const EvpackCapabilities& capabilities) const;
146
152 [[nodiscard]] Result<RuntimeAssetPayload> readAsset(
153 const EvpackAssetHandle& handle, std::uint64_t maximumDecodedBytes) const;
154
159 [[nodiscard]] Result<EvpackChunkHandle> resolveChunk(
160 const EvpackHandle& handle, const PersistentId& assetId, std::string_view type,
161 EvpackChunkKind kind, std::uint32_t chunkId, std::uint32_t variantIndex) const;
162
164 [[nodiscard]] Result<std::vector<std::uint8_t>> copyChunkBytes(const EvpackChunkHandle& handle) const;
165
167 [[nodiscard]] Result<EvpackUnmountReceipt> unmount(const EvpackHandle& handle);
168
169private:
170 struct Entry {
171 std::shared_ptr<const Evpack> pack;
172 std::uint64_t generation = 0;
173 };
174 mutable std::mutex mutex_;
175 std::map<PersistentId, Entry> packages_;
176 std::map<PersistentId, std::uint64_t> nextGenerations_;
177 std::map<std::uint64_t, Callback> callbacks_;
178 std::uint64_t nextSubscription_ = 0;
179};
180
181} // namespace eve::asset
Typed capability-aware runtime access to admitted packs.
#define EVENGINE_API_FOUNDATION
每个链接组(link group)各自的导出宏。
Definition Export.h:106
TokenKind kind
std::uint64_t bytes
std::uint32_t generation
PrimitiveHandle handle
const AssetImportLimits & limits
ViewPreparation callback
Stable asset identity backed by PersistentId.
Definition ResourceRef.h:53
Move-only operation result carrying either a value or Status.
Definition Result.h:155
Thread-safe owner of current runtime package generations.
std::function< Result< void >(const EvpackRegistryEvent &)> Callback
Owning admitted mount candidate that has not changed observable registry state.
const PersistentId & packageId() const noexcept
Identity of the fully admitted candidate package.
PreparedEvpackMount(PreparedEvpackMount &&) noexcept=default
Constructs a PreparedEvpackMount.
const PersistentId & buildId() const noexcept
Build identity of the fully admitted candidate package.
friend EVENGINE_API_FOUNDATION Result< PreparedEvpackMount > prepareEvpackMount(std::span< const std::uint8_t >, const EvpackLimits &, const EvpackTrust &)
Fully parse and verify package bytes without publishing them.
Id128 public API.
Definition Identity.h:112
EvpackRegistryEventKind
Observable registry lifecycle operation dispatched after commit and outside locks.
Result< PreparedEvpackMount > prepareEvpackMount(std::span< const std::uint8_t > bytes, const EvpackLimits &limits, const EvpackTrust &trust)
Fully parse and verify package bytes without publishing them.
EvpackChunkKind
Semantic role of a runtime chunk.
Definition Evpack.h:26
Generation-scoped stable-reference resolution across mounted packages.
EvpackCapabilities capabilities
Actual runtime device capabilities used for variant selection.
Definition Evpack.h:92
Generation-scoped handle to one verified chunk in a mounted package.
Generation-scoped handle to one mounted runtime package.
friend bool operator==(const EvpackHandle &, const EvpackHandle &) noexcept=default
Operator ==.
Resource limits checked before package allocations and hash work.
Definition Evpack.h:126
Receipt returned after an atomic registry publication.
std::vector< Diagnostic > callbackDiagnostics
Immutable lifecycle event delivered to registry subscribers.
EvpackRegistryEventKind kind
Opaque identity used to cancel a registry subscription.
friend bool operator==(const EvpackRegistrySubscription &, const EvpackRegistrySubscription &) noexcept=default
Operator ==.
Trust inputs kept separate from size/resource limits.
Definition Evpack.h:75
Receipt proving one generation was atomically unmounted.
std::vector< Diagnostic > callbackDiagnostics