过程级市场配置注册表:注册 / JSON 加载 / 按 id 或地区/国家查询 / 报价。 更多...
#include <Market.h>
静态 Public 成员函数 | |
| static Result< void > | registerMarket (const MarketConfig &config) |
| 注册或替换一个市场配置。 | |
| static Result< int > | loadFromJson (std::string_view json) |
| 解析单个市场对象或市场数组并逐项注册。 | |
| static const MarketConfig * | find (const std::string &id) |
按 id 查询;未注册返回 nullptr。 @ownership Borrowed from the process-wide registry; caller must not free it. @lifetime Valid until the next registerMarket / loadFromJson / clear. @nullable Yes when the id is unknown. | |
| static const MarketConfig * | findRegional (const std::string ®ionId) |
| 查找绑定该 regionId 的第一个启用地区市场。 @ownership Borrowed from the registry. @lifetime Valid until the next mutating registry call. @nullable Yes when none matches. | |
| static const MarketConfig * | findNational (const std::string &nationId) |
| 查找绑定该 nationId 的第一个启用全国市场。 @ownership Borrowed from the registry. @lifetime Valid until the next mutating registry call. @nullable Yes when none matches. | |
| static int | count () |
| 已注册市场数量。 | |
| static bool | has (const std::string &id) |
| id 是否已注册。 | |
| static const MarketConfig * | marketAt (int index) |
| 按 id 字典序返回第 index 个市场。 @ownership Borrowed from the registry. @lifetime Valid until the next mutating registry call. @nullable Yes when index is out of range. | |
| static void | clear () |
| 清空注册表(测试用)。 | |
| static Result< int > | quoteBuyPrice (const std::string &marketId, const std::string &resourceType) |
买入报价:basePrice * (10000 + buyPremiumBps) / 10000,至少为 1。 | |
| static Result< int > | quoteSellPrice (const std::string &marketId, const std::string &resourceType) |
卖出报价:basePrice * (10000 - sellDiscountBps) / 10000,至少为 0。 | |
详细描述
成员函数说明
◆ clear()
|
static |
◆ count()
|
static |
◆ find()
|
static |
按 id 查询;未注册返回 nullptr。 @ownership Borrowed from the process-wide registry; caller must not free it. @lifetime Valid until the next registerMarket / loadFromJson / clear. @nullable Yes when the id is unknown.
在文件 Market.cpp 第 292 行定义.
引用了 end.
被这些函数引用 eve::economy::Economy::getMarketCurrencyType(), eve::economy::Economy::getMarketListingBasePrice(), eve::economy::Economy::getMarketListingCount(), eve::economy::Economy::getMarketListingResourceType(), eve::economy::Economy::getMarketNationId(), eve::economy::Economy::getMarketRegionId(), eve::economy::Economy::getMarketScope(), eve::economy::Economy::getMarketTariffBps(), has(), eve::economy::Economy::isMarketEnabled(), marketAt(), quoteBuyPrice() , 以及 quoteSellPrice().
◆ findNational()
|
static |
查找绑定该 nationId 的第一个启用全国市场。 @ownership Borrowed from the registry. @lifetime Valid until the next mutating registry call. @nullable Yes when none matches.
在文件 Market.cpp 第 309 行定义.
引用了 best , 以及 eve::economy::National.
◆ findRegional()
|
static |
查找绑定该 regionId 的第一个启用地区市场。 @ownership Borrowed from the registry. @lifetime Valid until the next mutating registry call. @nullable Yes when none matches.
在文件 Market.cpp 第 298 行定义.
引用了 best , 以及 eve::economy::Regional.
◆ has()
|
static |
◆ loadFromJson()
|
static |
解析单个市场对象或市场数组并逐项注册。
- 参数
-
json eve.economy.marketv1 对象,或同结构对象数组。
- 返回
- 成功时为新注册/替换的市场数量。 @cost Cheap JSON parse of authoring-size market tables; amortize at load.
在文件 Market.cpp 第 260 行定义.
引用了 eve::Diagnostic::error(), eve::Result< T >::failure(), eve::Value::fromJson(), eve::Value::getIf(), eve::InvalidArgument, ok, registerMarket(), root , 以及 eve::Result< T >::success().
◆ marketAt()
|
static |
按 id 字典序返回第 index 个市场。 @ownership Borrowed from the registry. @lifetime Valid until the next mutating registry call. @nullable Yes when index is out of range.
在文件 Market.cpp 第 324 行定义.
引用了 find(), ids, index, left, right , 以及 size.
被这些函数引用 eve::economy::Economy::getMarketId().
◆ quoteBuyPrice()
|
static |
买入报价:basePrice * (10000 + buyPremiumBps) / 10000,至少为 1。
- 返回
- 市场或挂牌缺失时 NotFound。
在文件 Market.cpp 第 336 行定义.
引用了 eve::economy::MarketListing::basePrice, eve::economy::MarketListing::buyPremiumBps, eve::Diagnostic::error(), eve::Result< T >::failure(), find(), eve::NotFound , 以及 eve::Result< T >::success().
◆ quoteSellPrice()
|
static |
卖出报价:basePrice * (10000 - sellDiscountBps) / 10000,至少为 0。
- 返回
- 市场或挂牌缺失时 NotFound。
在文件 Market.cpp 第 353 行定义.
引用了 eve::economy::MarketListing::basePrice, eve::Diagnostic::error(), eve::Result< T >::failure(), find(), eve::NotFound, eve::economy::MarketListing::sellDiscountBps , 以及 eve::Result< T >::success().
◆ registerMarket()
|
static |
注册或替换一个市场配置。
- 返回
- 校验失败时返回 InvalidArgument 诊断。 @cost Cheap: 校验并拷贝一份小型挂牌表;按市场重建摊销。
在文件 Market.cpp 第 253 行定义.
引用了 eve::economy::MarketConfig::id, eve::economy::normalizeMarketConfig(), ok , 以及 eve::Result< T >::success().
被这些函数引用 loadFromJson().
该类的文档由以下文件生成:
- src/modules/economy/Market.h
- src/modules/economy/Market.cpp