载入中...
搜索中...
未找到
ResourceAccount.h
浏览该文件的文档.
131 [[nodiscard]] static eve::Result<ResourceCost> create(std::string_view resourceId, std::int64_t amountValue);
172 [[nodiscard]] static eve::Result<CostSpec> single(std::string_view resource, std::int64_t amount);
Move-only, checked operation results for the common layer.
Internal storage primitive for domain-owned unsigned values.
Opaque process-local identity of the account that issued a credential.
Definition ResourceAccount.h:237
constexpr std::uint64_t value() const noexcept
Return the opaque numeric value for diagnostics and comparisons.
Definition ResourceAccount.h:243
friend EVENGINE_API_FOUNDATION eve::Result< AccountNonce > allocateAccountNonce()
Allocate a process-local account identity for a credential issuer.
Definition ResourceAccount.cpp:27
constexpr bool isZero() const noexcept
Whether this nonce is invalid/zero.
Definition ResourceAccount.h:246
constexpr AccountNonce() noexcept=default
Construct the invalid zero nonce.
friend constexpr auto operator<=>(const AccountNonce &, const AccountNonce &) noexcept=default
Operator <=>.
friend constexpr bool operator==(const AccountNonce &, const AccountNonce &) noexcept=default
Non-negative integral quantity used by resource accounts.
Definition ResourceAccount.h:75
constexpr std::int64_t value() const noexcept
Return the native quantity at an explicit adapter boundary.
Definition ResourceAccount.h:98
eve::Result< Amount > checkedAdd(Amount other) const
Add two quantities with overflow checking.
Definition ResourceAccount.cpp:57
friend constexpr auto operator<=>(const Amount &, const Amount &) noexcept=default
Operator <=>.
friend constexpr bool operator==(const Amount &, const Amount &) noexcept=default
CostSpec()=default
Construct an invalid empty cost; use create/from/single for input.
friend bool operator==(const CostSpec &, const CostSpec &) noexcept=default
const std::vector< ResourceCost > & items() const noexcept
Return canonical items as a read-only borrowed view.
Definition ResourceAccount.h:185
bool isValid() const noexcept
Whether this value contains a validated non-empty cost.
Definition ResourceAccount.h:175
std::size_t size() const noexcept
Return the number of canonical resource entries.
Definition ResourceAccount.h:188
Provider-neutral resource account contract.
Definition ResourceAccount.h:316
virtual eve::Result< Receipt > credit(const CostSpec &cost)=0
Atomically credit all items immediately.
virtual eve::Result< Receipt > commit(const Reservation &reservation)=0
Commit one active reservation as an atomic debit.
virtual ~IResourceAccount()=default
Releases IResourceAccount resources.
virtual eve::Result< Reservation > reserve(const CostSpec &cost)=0
Reserve all items of a cost without changing visible balances.
virtual eve::Result< Receipt > debit(const CostSpec &cost)=0
Atomically debit all items immediately.
virtual eve::Result< Affordability > canAfford(const CostSpec &cost) const =0
Query whether a cost can be paid from currently available funds.
virtual eve::Result< void > rollback(const Reservation &reservation)=0
Release one active reservation without changing balances.
Strong identity of a resource kind, such as mana or gold.
Definition ResourceAccount.h:40
friend bool operator==(const ResourceId &, const ResourceId &) noexcept=default
const std::string & value() const noexcept
Return the canonical owned spelling.
Definition ResourceAccount.h:56
static eve::Result< ResourceId > parse(std::string_view text)
Parse a resource id at a public input boundary.
Definition ResourceAccount.cpp:38
friend auto operator<=>(const ResourceId &, const ResourceId &) noexcept=default
Operator <=>.
bool isValid() const noexcept
Whether this id passed the resource-name validation.
Definition ResourceAccount.h:53
Definition EventSequence.h:8
Definition ResourceAccount.cpp:9
eve::Result< AccountNonce > allocateAccountNonce()
Allocate a process-local account identity for a credential issuer.
Definition ResourceAccount.cpp:27
ReceiptOperation
Operation represented by a receipt returned from an account.
Definition ResourceAccount.h:221
Definition Container.h:602
ResourceReservationIdTag public API.
Definition ResourceAccount.h:31
std::vector< ResourceShortfall > shortfalls
Definition ResourceAccount.h:214
bool isAffordable() const noexcept
Return whether every item in the queried cost is available.
Definition ResourceAccount.h:217
Convenient unvalidated input used by CostSpec::from().
Definition ResourceAccount.h:135
Receipt proving one atomic debit or credit was applied.
Definition ResourceAccount.h:294
bool isValid() const noexcept
Whether this receipt contains a valid operation identity.
Definition ResourceAccount.h:302
Reservation credential returned by a successful reserve operation.
Definition ResourceAccount.h:279
bool isValid() const noexcept
Whether this credential has valid account/id identity and cost.
Definition ResourceAccount.h:285
One positive resource and quantity pair in a canonical cost.
Definition ResourceAccount.h:118
friend bool operator==(const ResourceCost &, const ResourceCost &) noexcept=default
Operator ==.
A resource missing from an affordability query.
Definition ResourceAccount.h:199
std::size_t operator()(const eve::resource::ResourceId &value) const noexcept
Hash a canonical resource id for account reservation maps.
Definition ResourceAccount.h:372