Immutable canonical multi-resource cost. 更多...
#include <ResourceAccount.h>
Public 成员函数 | |
| CostSpec ()=default | |
| Construct an invalid empty cost; use create/from/single for input. | |
| bool | isValid () const noexcept |
| Whether this value contains a validated non-empty cost. | |
| bool | empty () const noexcept |
| Whether this cost has no items. | |
| const std::vector< ResourceCost > & | items () const noexcept |
| Return canonical items as a read-only borrowed view. | |
| std::size_t | size () const noexcept |
| Return the number of canonical resource entries. | |
静态 Public 成员函数 | |
| static eve::Result< CostSpec > | create (std::vector< ResourceCost > items) |
| Validate and canonicalize resource items. | |
| static eve::Result< CostSpec > | from (std::initializer_list< CostInput > items) |
| Build a cost from string/integer pairs. | |
| static eve::Result< CostSpec > | single (std::string_view resource, std::int64_t amount) |
| Build a one-resource cost. | |
友元 | |
| bool | operator== (const CostSpec &, const CostSpec &) noexcept=default |
详细描述
Immutable canonical multi-resource cost.
Items are sorted by ResourceId and duplicate resources are merged with checked arithmetic. Empty costs and zero/negative items are rejected, so a successful CostSpec is safe to use in reserve/debit/credit operations.
在文件 ResourceAccount.h 第 147 行定义.
构造及析构函数说明
◆ CostSpec()
|
default |
Construct an invalid empty cost; use create/from/single for input.
被这些函数引用 create().
成员函数说明
◆ create()
|
static |
Validate and canonicalize resource items.
- 参数
-
items Input items; duplicate ids are merged deterministically.
- 返回
- A canonical cost or a rejected Result.
在文件 ResourceAccount.cpp 第 74 行定义.
引用了 CostSpec(), eve::Result< T >::failure(), items(), left, right , 以及 eve::Result< T >::success().
被这些函数引用 eve::rts::RTSProductionActionAdapter::build() , 以及 from().
◆ empty()
|
inlinenoexcept |
Whether this cost has no items.
在文件 ResourceAccount.h 第 178 行定义.
◆ from()
|
static |
Build a cost from string/integer pairs.
- 参数
-
items Non-empty positive resource entries.
- 返回
- A canonical cost or a rejected Result.
在文件 ResourceAccount.cpp 第 103 行定义.
引用了 eve::resource::ResourceCost::create(), create(), eve::Result< T >::failure(), input , 以及 items().
◆ isValid()
|
inlinenoexcept |
Whether this value contains a validated non-empty cost.
在文件 ResourceAccount.h 第 175 行定义.
被这些函数引用 eve::transaction::AtomicResourcePayment::execute(), eve::resource::Reservation::isValid() , 以及 eve::resource::Receipt::isValid().
◆ items()
|
inlinenoexcept |
Return canonical items as a read-only borrowed view.
- 备注
- The view remains valid while this CostSpec is alive and is invalidated by assignment or destruction.
在文件 ResourceAccount.h 第 185 行定义.
被这些函数引用 eve::attributes::AttributeSetResourceAccount::canAfford(), eve::economy::EconomyLedgerResourceAccount::canAfford(), eve::inventory::InventoryResourceAccount::canAfford(), eve::attributes::AttributeResourceAccountAdapter::commit(), create(), eve::attributes::AttributeSetResourceAccount::credit(), from() , 以及 eve::attributes::AttributeResourceAccountAdapter::rollback().
◆ single()
|
static |
Build a one-resource cost.
- 参数
-
resource Stable resource name. amount Positive quantity.
- 返回
- A canonical cost or a rejected Result.
在文件 ResourceAccount.cpp 第 117 行定义.
被这些函数引用 eve::rts::RTS::addScriptResource(), eve::rts::AbilitySystem::cast(), eve::attributes::AttributeResourceAccountAdapter::makeCost(), eve::card::CardPlayPaymentAdapter::manaCost(), eve::rts::RTS::queueScriptResearch(), eve::rts::RTS::queueScriptUnit(), eve::rts::RTS::sellScriptBuilding(), eve::rts::RTS::startScriptConstruction(), eve::rts::RepairSystem::step(), eve::rts::InfrastructureSystem::step() , 以及 eve::rts::MiningSystem::step().
◆ size()
|
inlinenoexcept |
Return the number of canonical resource entries.
在文件 ResourceAccount.h 第 188 行定义.
被这些函数引用 eve::attributes::AttributeResourceAccountAdapter::commit() , 以及 eve::attributes::AttributeResourceAccountAdapter::rollback().
友元及相关函数文档
◆ operator==
该类的文档由以下文件生成:
- src/engine/common/ResourceAccount.h
- src/engine/common/ResourceAccount.cpp