载入中...
搜索中...
未找到
SubjectRef.h
浏览该文件的文档.
1#pragma once
2
13#include "common/Identity.h"
14
15#include <cstddef>
16
17namespace eve {
18
27public:
29 SubjectRef() = default;
30
32 [[nodiscard]] static SubjectRef fromPersistentId(PersistentId id) noexcept { return SubjectRef(id); }
33
35 [[nodiscard]] static SubjectRef nil() noexcept { return {}; }
36
38 [[nodiscard]] bool isValid() const noexcept { return !id_.isNil(); }
39
41 [[nodiscard]] PersistentId persistentId() const noexcept { return id_; }
42
44 [[nodiscard]] std::string format() const { return id_.format(); }
45
46 friend bool operator==(const SubjectRef&, const SubjectRef&) noexcept = default;
47
48private:
49 explicit SubjectRef(PersistentId id) noexcept : id_(id) {}
50
51 PersistentId id_;
52};
53
54} // namespace eve
55
56namespace std {
57
58template <>
60struct hash<eve::SubjectRef> {
62 size_t operator()(const eve::SubjectRef& value) const noexcept {
63 return static_cast<size_t>(value.persistentId().hash());
64 }
65};
66
67} // namespace std
double value
std::array< std::uint8_t, 32 > hash
Definition Evpack.cpp:172
Strong identity values shared by persistence, content and logical-name APIs.
Strong, domain-neutral reference to a runtime subject.
Definition SubjectRef.h:26
PersistentId persistentId() const noexcept
Return the wrapped persistent identity.
Definition SubjectRef.h:41
friend bool operator==(const SubjectRef &, const SubjectRef &) noexcept=default
static SubjectRef fromPersistentId(PersistentId id) noexcept
Wrap a persistent identity without changing its bytes.
Definition SubjectRef.h:32
SubjectRef()=default
Construct an invalid nil reference.
static SubjectRef nil() noexcept
Return the invalid nil reference.
Definition SubjectRef.h:35
std::string format() const
Return the canonical lower-case UUID spelling.
Definition SubjectRef.h:44
bool isValid() const noexcept
Return whether this reference is valid and non-nil.
Definition SubjectRef.h:38
Id128 public API.
Definition Identity.h:112
std::string format() const
Formats the ID in lower-case canonical UUID text.
Definition Identity.h:173
constexpr bool isNil() const noexcept
Returns whether this value is the all-zero nil ID.
Definition Identity.h:176
::eve::SubjectRef SubjectRef
Strong reference to a runtime subject.
Definition Targeting.h:76
Build metadata (engine git commit, build time, third-party version).
Definition Build.cpp:16