runtime.h 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560
  1. #pragma once
  2. #include <array>
  3. #include <cstddef>
  4. #include <cstdint>
  5. #include <span>
  6. #include <string_view>
  7. #include "abilities/definition.h"
  8. #include "collectibles/collectible_catalog.h"
  9. #include "constants/definition.h"
  10. #include "definition.h"
  11. #include "hash_names/definition.h"
  12. #include "inventory/buckets/definition.h"
  13. #include "items/details/definition.h"
  14. #include "items/item_catalog.h"
  15. #include "items/socket_plugs/definition.h"
  16. #include "material_requirements/material_requirement_catalog.h"
  17. #include "progressions/definition.h"
  18. #include "nodes/definition.h"
  19. #include "records/definition.h"
  20. #include "scenarios/definition.h"
  21. #include "socket_entry_buckets/definition.h"
  22. #include "socket_entry_lists/definition.h"
  23. #include "spawn_sets/definition.h"
  24. #include "vendors/definition.h"
  25. namespace sunrise::state::build_data {
  26. /**
  27. * Loads the one build-data cache next to the module, when there is one.
  28. * Once a snapshot is on disk, later replacements are refused until State restarts. A failed first
  29. * commit withdraws that publication and restores nothing. Keep readers out until this returns.
  30. * @param module Loaded Sunrise DLL module, or null to turn off disk saving.
  31. * @param configuredEquipmentHash Hash of the authored equipment. Not a secret.
  32. * @return True when the cache is missing, stale, or passes every check.
  33. */
  34. [[nodiscard]] bool initialize(void* module, std::uint64_t configuredEquipmentHash) noexcept;
  35. /** Clears all cached build mappings and persistence paths. */
  36. void shutdown() noexcept;
  37. /** @return True when named package mappings are complete in State. */
  38. [[nodiscard]] bool named_catalog_ready() noexcept;
  39. /**
  40. * Marks the already-filled named catalog complete, and saves once all data is ready.
  41. * Call only while named readiness is false. A failed first commit withdraws the target and does
  42. * not restore an earlier ready catalog.
  43. * @return True when the catalog is nonempty and any needed cache write succeeds.
  44. */
  45. [[nodiscard]] bool publish_named_catalog() noexcept;
  46. /** @return True when the whole item definition table is in State. */
  47. [[nodiscard]] bool item_definitions_ready() noexcept;
  48. /** @return Dense item-definition row count, read under the lock. */
  49. [[nodiscard]] std::size_t item_definition_count() noexcept;
  50. /**
  51. * Publishes the whole installed-build item definition table in one step.
  52. * Call only while item readiness is false. A failed first commit withdraws the target and does
  53. * not restore an earlier ready table.
  54. * @param definitions Dense native-index mappings extracted from the running client.
  55. * @return True when the mappings pass the checks and any needed cache write succeeds.
  56. */
  57. [[nodiscard]] bool
  58. publish_item_definitions(std::span<const items::Definition> definitions) noexcept;
  59. /**
  60. * Finds one authored item hash inside its expected inventory bucket.
  61. * @param definitionHash Authored item definition hash.
  62. * @param bucketId Expected inventory bucket id.
  63. * @param definition Receives the one matching native definition.
  64. * @return True when the item data is ready and exactly one mapping matches.
  65. */
  66. [[nodiscard]] bool find_item_definition(std::uint32_t definitionHash,
  67. std::uint8_t bucketId,
  68. items::Definition& definition) noexcept;
  69. /**
  70. * Finds an authored base-item or plug hash without storing a native index in settings.
  71. * @param definitionHash Authored item or plug definition hash.
  72. * @param definition Receives the one matching installed-build mapping.
  73. * @return True when the item data is ready and exactly one native row matches.
  74. */
  75. [[nodiscard]] bool find_item_definition_hash(std::uint32_t definitionHash,
  76. items::Definition& definition) noexcept;
  77. /**
  78. * Finds one installed item by the native dense definition index used by Collections requests.
  79. * @param definitionIndex Native item-definition row index.
  80. * @param definition Receives the exact installed mapping.
  81. * @return True when the complete table is ready and contains the requested row.
  82. */
  83. [[nodiscard]] bool find_item_definition_index(std::uint16_t definitionIndex,
  84. items::Definition& definition) noexcept;
  85. /** @return True when the whole dense collectible definition table is in State. */
  86. [[nodiscard]] bool collectible_definitions_ready() noexcept;
  87. /**
  88. * Publishes the installed collectible ordinal-to-item table in one step.
  89. * @param definitions Complete dense rows extracted from the investment root's collectible table.
  90. * @return True when the rows pass the checks and any needed cache write succeeds.
  91. */
  92. [[nodiscard]] bool
  93. publish_collectible_definitions(std::span<const collectibles::Definition> definitions) noexcept;
  94. /**
  95. * Resolves the native 15-bit collectible index carried by a Collections acquire request.
  96. * @param collectibleIndex Native collectible row ordinal.
  97. * @param itemDefinitionIndex Receives the installed item-definition row, or the unavailable
  98. * sentinel on failure.
  99. * @return True when both the complete table and an item link exist for this collectible.
  100. */
  101. [[nodiscard]] bool
  102. find_collectible_item_definition_index(std::uint16_t collectibleIndex,
  103. std::uint16_t& itemDefinitionIndex) noexcept;
  104. /** Finds one complete installed collectible row, including its acquisition material set. */
  105. [[nodiscard]] bool find_collectible_definition(std::uint16_t collectibleIndex,
  106. collectibles::Definition& definition) noexcept;
  107. /** @return True when every installed material-requirement set is available by native ordinal. */
  108. [[nodiscard]] bool material_requirement_sets_ready() noexcept;
  109. /** Publishes the complete dense native material-requirement table. */
  110. [[nodiscard]] bool publish_material_requirement_sets(
  111. std::span<const material_requirements::Definition> definitions) noexcept;
  112. /** Resolves one authored material-requirement set without embedding any prices in code. */
  113. [[nodiscard]] bool
  114. find_material_requirement_set(std::uint16_t requirementSetIndex,
  115. material_requirements::Definition& definition) noexcept;
  116. /** @return True when a complete configured-detail domain, empty or not, is published. */
  117. [[nodiscard]] bool configured_item_details_ready() noexcept;
  118. /**
  119. * Publishes configured item details. An empty domain is a complete one.
  120. * Call only while detail readiness is false. A failed first commit withdraws the target and does
  121. * not restore an earlier ready domain.
  122. * @param definitions Complete installed-build details for configured authored items.
  123. * @return True when the links pass the checks and any needed cache write succeeds.
  124. */
  125. [[nodiscard]] bool
  126. publish_configured_item_details(std::span<const items::details::Definition> definitions) noexcept;
  127. /**
  128. * Finds one configured item detail by native definition index.
  129. * @param definitionIndex Native installed-build item index.
  130. * @param definition Receives the matching configured detail.
  131. * @return True when the detail data is ready and holds that row.
  132. */
  133. [[nodiscard]] bool find_configured_item_detail(std::uint16_t definitionIndex,
  134. items::details::Definition& definition) noexcept;
  135. /** @return True when the exact installed ordinary-socket plug relation is in State. */
  136. [[nodiscard]] bool socket_plug_rules_ready() noexcept;
  137. /**
  138. * Publishes exact per-item, per-lane plug pools extracted from the installed packages.
  139. * @param rules Strictly item/lane-ordered rules.
  140. * @param pools Deduplicated contiguous pool ranges, beginning with the empty pool.
  141. * @param members Flat sorted plug-definition indices.
  142. * @return True when the relation and its item/detail links validate and any cache write succeeds.
  143. */
  144. [[nodiscard]] bool
  145. publish_socket_plug_rules(std::span<const items::socket_plugs::Rule> rules,
  146. std::span<const items::socket_plugs::Pool> pools,
  147. std::span<const items::socket_plugs::Member> members) noexcept;
  148. /**
  149. * Answers whether one installed plug definition is valid for one exact ordinary socket lane.
  150. * Missing or malformed relations fail closed.
  151. */
  152. [[nodiscard]] bool is_socket_plug_allowed(std::uint16_t itemDefinitionIndex,
  153. std::uint8_t lane,
  154. std::uint16_t plugDefinitionIndex) noexcept;
  155. /**
  156. * Walks every plug one exact ordinary socket lane accepts. Missing relations fail closed.
  157. * @return True when the lane has a pool and the visitor saw every member.
  158. */
  159. [[nodiscard]] bool visit_socket_plug_pool(std::uint16_t itemDefinitionIndex,
  160. std::uint8_t lane,
  161. items::socket_plugs::MemberVisitor visitor,
  162. void* context) noexcept;
  163. /** @return True when one plug definition occurs in any installed ordinary-socket plug pool. */
  164. [[nodiscard]] bool is_socket_plug_pooled(std::uint16_t plugDefinitionIndex) noexcept;
  165. /**
  166. * Answers whether one profile definition needs an item-instance resident so the native socket
  167. * action route can materialize it. Only stackable installed socket plugs in the supported mod and
  168. * shader profile buckets qualify; currency/material/intrinsic rows do not.
  169. */
  170. [[nodiscard]] bool is_profile_action_source(std::uint16_t itemDefinitionIndex,
  171. std::uint8_t bucketId) noexcept;
  172. /**
  173. * Answers whether applying one plug spends a stack the account has to hold.
  174. * @param itemDefinitionIndex Installed plug-definition row.
  175. * @param bucketId Installed profile bucket the plug belongs to.
  176. * @return True only for a shader Collections can grant. An ornament stays owned once applied,
  177. * and a socket's default plug belongs to no stack at all.
  178. */
  179. [[nodiscard]] bool is_consumed_on_apply(std::uint16_t itemDefinitionIndex,
  180. std::uint8_t bucketId) noexcept;
  181. /** @return True when the whole presentation node table is in State. */
  182. [[nodiscard]] bool node_definitions_ready() noexcept;
  183. /**
  184. * Publishes the whole presentation node table in one step.
  185. * @param definitions Complete dense rows in native node order.
  186. * @return True when the rows pass the domain checks and fit fixed State storage.
  187. */
  188. [[nodiscard]] bool
  189. publish_node_definitions(std::span<const nodes::Definition> definitions) noexcept;
  190. /** @return True when the whole record definition table is in State. */
  191. [[nodiscard]] bool record_definitions_ready() noexcept;
  192. /**
  193. * Publishes the whole record definition table in one step.
  194. * @param definitions Complete dense rows in native record order.
  195. * @return True when the rows pass the domain checks and fit fixed State storage.
  196. */
  197. [[nodiscard]] bool
  198. publish_record_definitions(std::span<const records::Definition> definitions) noexcept;
  199. /**
  200. * Resolves the native record row an opcode-1801 claim names.
  201. * @param definitionIndex Native record row carried by the claim.
  202. * @param definition Receives the row, including its completion flag index, only on success.
  203. * @return True when the table is complete and the row exists.
  204. */
  205. [[nodiscard]] bool find_record_definition(std::uint16_t definitionIndex,
  206. records::Definition& definition) noexcept;
  207. /** @return True when the whole progression definition table is in State. */
  208. [[nodiscard]] bool progression_definitions_ready() noexcept;
  209. /**
  210. * Publishes the whole progression definition table in one step.
  211. * @param definitions Dense rows in native definition order.
  212. * @return True when the rows pass the checks and any needed cache write succeeds.
  213. */
  214. [[nodiscard]] bool
  215. publish_progression_definitions(std::span<const progressions::Definition> definitions) noexcept;
  216. /**
  217. * Lists the definition index each slot of one scope's progression array carries.
  218. * @param scope Replicated object owning the array.
  219. * @param output Slot storage, one entry per slot the array holds.
  220. * @param count Receives the number of keyed slots.
  221. * @return True when the table is ready and every keyed slot fits.
  222. */
  223. [[nodiscard]] bool find_progression_slots(progressions::Scope scope,
  224. std::span<std::uint16_t> output,
  225. std::size_t& count) noexcept;
  226. /** @return True when a complete ability bucket domain, empty or not, is published. */
  227. [[nodiscard]] bool ability_buckets_ready() noexcept;
  228. /**
  229. * Publishes the ability buckets every configured subclass and ability selection publishes.
  230. * @param definitions Complete rows, or an empty complete domain.
  231. * @return True when the rows pass the checks and any needed cache write succeeds.
  232. */
  233. [[nodiscard]] bool
  234. publish_ability_buckets(std::span<const abilities::Definition> definitions) noexcept;
  235. /**
  236. * Finds the buckets one subclass publishes under one ability selection.
  237. * @param socketEntryListIndex Native socket-entry-list index of the subclass.
  238. * @param selection The character's 5 selected socket entries.
  239. * @param definition Receives the matching row.
  240. * @return True when the domain is ready and holds that exact key.
  241. */
  242. [[nodiscard]] bool find_ability_buckets(std::uint16_t socketEntryListIndex,
  243. const abilities::Selection& selection,
  244. abilities::Definition& definition) noexcept;
  245. /**
  246. * Drops the published ability bucket domain so the next investment refresh slice rebuilds it.
  247. * A committed subclass ability-entry change makes the published rows stale for their character,
  248. * since they were keyed by the selection in place when the domain was first built.
  249. */
  250. void invalidate_ability_buckets() noexcept;
  251. /**
  252. * @return True when at least one socket-entry list's resolved bucket destinations are published.
  253. * Never part of the on-disk content cache: it is small and cheap to recompute, so a warm boot that
  254. * skips re-extraction must not leave it empty for the whole session.
  255. */
  256. [[nodiscard]] bool socket_entry_buckets_ready() noexcept;
  257. /**
  258. * Publishes every socket-entry list's resolved per-entry ability-bucket destinations.
  259. * A derived cache of static content, so unlike the ability buckets above it never needs
  260. * invalidating: a subclass's entry table does not change after content extraction.
  261. * @param definitions Complete rows, one per socket-entry list that carries a super lane.
  262. * @return True when the rows pass the checks.
  263. */
  264. [[nodiscard]] bool publish_socket_entry_buckets(
  265. std::span<const socket_entry_buckets::Definition> definitions) noexcept;
  266. /**
  267. * Finds which of the 12 semantic ability buckets one socket entry resolves to.
  268. * @param socketEntryListIndex Native socket-entry-list index of the subclass.
  269. * @param entryIndex The entry to look up.
  270. * @param bucket Receives the resolved destination, or the no-destination sentinel.
  271. * @return True when the list's row is published and the entry index is in range.
  272. */
  273. [[nodiscard]] bool find_socket_entry_bucket(std::uint16_t socketEntryListIndex,
  274. std::uint8_t entryIndex,
  275. std::uint8_t& bucket) noexcept;
  276. /** @return True when the installed investment constants are in State. */
  277. [[nodiscard]] bool investment_constants_ready() noexcept;
  278. /**
  279. * Publishes the stat rows read from the installed investment constants blob.
  280. * @param value Constants extracted from the blob.
  281. * @return True when the row is extracted and any needed cache write succeeds.
  282. */
  283. [[nodiscard]] bool
  284. publish_investment_constants(const constants::InvestmentConstants& value) noexcept;
  285. /**
  286. * Reads the published investment constants.
  287. * @param value Receives the published stat rows.
  288. * @return True when the constants are in State.
  289. */
  290. [[nodiscard]] bool find_investment_constants(constants::InvestmentConstants& value) noexcept;
  291. /** @return True when the whole inventory-bucket descriptor table is in State. */
  292. [[nodiscard]] bool inventory_bucket_descriptors_ready() noexcept;
  293. /**
  294. * Publishes the whole inventory-bucket routing table in one step.
  295. * Call only while bucket readiness is false. A failed first commit withdraws the target and does
  296. * not restore an earlier ready table.
  297. * @param descriptors Installed-build bucket descriptors.
  298. * @return True when the descriptors pass the checks and any needed cache write succeeds.
  299. */
  300. [[nodiscard]] bool publish_inventory_bucket_descriptors(
  301. std::span<const inventory::buckets::Descriptor> descriptors) noexcept;
  302. /**
  303. * Finds one inventory-bucket descriptor by native bucket id.
  304. * @param bucketId Native inventory-bucket id.
  305. * @param descriptor Receives the matching routing descriptor.
  306. * @return True when the bucket data is ready and holds that row.
  307. */
  308. [[nodiscard]] bool
  309. find_inventory_bucket_descriptor(std::uint8_t bucketId,
  310. inventory::buckets::Descriptor& descriptor) noexcept;
  311. /** @return True when the whole dense socket-entry-list table is in State. */
  312. [[nodiscard]] bool socket_entry_lists_ready() noexcept;
  313. /** @return Dense socket-entry-list row count, read under the lock. */
  314. [[nodiscard]] std::size_t socket_entry_list_count() noexcept;
  315. /**
  316. * Publishes the whole dense socket-entry-list table in one step.
  317. * Call only while socket-list readiness is false. A failed first commit withdraws the target and
  318. * does not restore an earlier ready table.
  319. * @param definitions Installed-build socket-entry-list definitions.
  320. * @param entryTables Per-entry inputs for the lists that carry a super lane.
  321. * @return True when the rows pass the checks and any needed cache write succeeds.
  322. */
  323. [[nodiscard]] bool
  324. publish_socket_entry_lists(std::span<const socket_entry_lists::Definition> definitions,
  325. std::span<const socket_entry_lists::EntryTable> entryTables) noexcept;
  326. /**
  327. * Finds one list's per-entry selection inputs.
  328. * @param definitionIndex Native socket-entry-list index.
  329. * @param table Receives the matching row.
  330. * @return True when a table is kept for that list.
  331. */
  332. [[nodiscard]] bool find_socket_entry_table(std::uint16_t definitionIndex,
  333. socket_entry_lists::EntryTable& table) noexcept;
  334. /**
  335. * Finds one socket-entry-list definition by native definition index.
  336. * @param definitionIndex Native socket-entry-list index.
  337. * @param definition Receives the matching installed-build row.
  338. * @return True when the socket-list data is ready and holds that row.
  339. */
  340. [[nodiscard]] bool find_socket_entry_list(std::uint16_t definitionIndex,
  341. socket_entry_lists::Definition& definition) noexcept;
  342. /** Number of subclass items every character class ships in this build. */
  343. inline constexpr std::size_t kSubclassGroupSize = 3;
  344. /**
  345. * Finds the 2 other subclasses that share one character class with a known member.
  346. * The installed manifest lists every subclass item as one dense run per class, in native
  347. * definition-index order, so the run holding a known member gives every other member.
  348. * @param memberDefinitionIndex Native item-definition index of one subclass in the class.
  349. * @param group Receives the 3 member indices, in native definition-index order.
  350. * @return True when every subclass item was found and `memberDefinitionIndex` is one of them.
  351. */
  352. [[nodiscard]] bool
  353. find_subclass_group(std::uint16_t memberDefinitionIndex,
  354. std::array<std::uint16_t, kSubclassGroupSize>& group) noexcept;
  355. /** @return True when a complete destination-layout domain, empty or not, is published. */
  356. [[nodiscard]] bool scenario_layouts_ready() noexcept;
  357. /**
  358. * Publishes the extracted destination layouts and their roster groups in one step.
  359. * @param definitions Complete rows swept from the installed packages.
  360. * @param groups Complete roster groups the same sweep reached.
  361. * @return True when the rows pass the checks and any needed cache write succeeds.
  362. */
  363. [[nodiscard]] bool
  364. publish_scenario_layouts(std::span<const scenarios::Definition> definitions,
  365. std::span<const scenarios::RosterGroup> groups) noexcept;
  366. /**
  367. * Copies one roster group by the table index a destination row carries.
  368. * @param index Roster table index.
  369. * @param group Receives the group.
  370. * @return True when the domain is ready and the index is inside its table.
  371. */
  372. [[nodiscard]] bool find_roster_group(std::size_t index, scenarios::RosterGroup& group) noexcept;
  373. /** @return Number of published destination layouts, read under the lock. */
  374. [[nodiscard]] std::size_t scenario_layout_count() noexcept;
  375. /**
  376. * Copies every published destination layout.
  377. * @param output Caller-owned fixed row storage.
  378. * @param count Receives the copied row count.
  379. * @return True when the domain is ready and output can hold every row.
  380. */
  381. [[nodiscard]] bool snapshot_scenario_layouts(std::span<scenarios::Definition> output,
  382. std::size_t& count) noexcept;
  383. /** @return True when a complete bubble-name table, empty or not, is published. */
  384. [[nodiscard]] bool hash_names_ready() noexcept;
  385. /**
  386. * Publishes the resolved bubble names in one step.
  387. * @param names Complete rows in ascending hash order, or an empty complete table.
  388. * @return True when the rows pass the checks and any needed cache write succeeds.
  389. */
  390. [[nodiscard]] bool publish_hash_names(std::span<const hash_names::Name> names) noexcept;
  391. /**
  392. * Finds one bubble's internal name by its hash.
  393. * @param hash Bubble name hash from a destination layout.
  394. * @param name Receives the matching row.
  395. * @return True when the table is ready and holds that exact hash.
  396. */
  397. [[nodiscard]] bool find_hash_name(std::uint32_t hash, hash_names::Name& name) noexcept;
  398. /** @return True when a complete spawn-set catalog, empty or not, is published. */
  399. [[nodiscard]] bool spawn_sets_ready() noexcept;
  400. /**
  401. * Publishes the spawn-set catalog extracted from the installed packages, in one step.
  402. * @param stems Complete stem rows in ascending name order, or an empty complete catalog.
  403. * @param nameHashes Complete flat bank in stem then hash order.
  404. * @param points Complete point bank in extraction order, which may be empty.
  405. * @return True when the rows pass the checks and any needed cache write succeeds.
  406. */
  407. [[nodiscard]] bool publish_spawn_sets(std::span<const spawn_sets::Stem> stems,
  408. std::span<const spawn_sets::NameHash> nameHashes,
  409. std::span<const spawn_sets::Point> points) noexcept;
  410. /**
  411. * Finds the spawn point of one map-package stem nearest a world position.
  412. * @param stem Normalized stem a destination row carries.
  413. * @param position World position to measure from.
  414. * @param point Receives the nearest point and the set it belongs to.
  415. * @param distance Receives the distance to it, in world units.
  416. * @return True when the catalog is ready, holds the stem, and the stem owns a point.
  417. */
  418. [[nodiscard]] bool
  419. find_nearest_spawn_point(std::string_view stem,
  420. const std::array<float, spawn_sets::kPositionComponents>& position,
  421. spawn_sets::Point& point,
  422. float& distance) noexcept;
  423. /**
  424. * Copies the whole flat spawn-name hash bank.
  425. * @param output Caller-owned fixed row storage.
  426. * @param count Receives the copied row count.
  427. * @return True when the catalog is ready and output can hold every row.
  428. */
  429. [[nodiscard]] bool snapshot_spawn_name_hashes(std::span<spawn_sets::NameHash> output,
  430. std::size_t& count) noexcept;
  431. /**
  432. * Finds the spawn sets one map-package stem declares.
  433. * @param stem Normalized stem a destination row carries.
  434. * @param output Caller-owned fixed row storage.
  435. * @param count Receives the copied row count.
  436. * @return True when the catalog is ready, holds the stem, and the range fits.
  437. */
  438. [[nodiscard]] bool find_spawn_sets(std::string_view stem,
  439. std::span<spawn_sets::NameHash> output,
  440. std::size_t& count) noexcept;
  441. /**
  442. * Finds one destination's bubble layout by package name.
  443. * @param name Package name the client's selection carried.
  444. * @param definition Receives the matching row.
  445. * @return True when the domain is ready and holds that exact name.
  446. */
  447. [[nodiscard]] bool find_scenario_layout(std::string_view name,
  448. scenarios::Definition& definition) noexcept;
  449. /** @return True when the installed vendor index is in State. */
  450. [[nodiscard]] bool vendor_catalog_ready() noexcept;
  451. /**
  452. * Publishes the vendor index and every extracted vendor definition in one step.
  453. * @param index Complete index rows in ascending index order.
  454. * @param definitions Extracted definitions in ascending index order, which may be empty.
  455. * @param saleRows Complete flat sale bank in definition then row order.
  456. * @param installedRows Complete flat installed bank in definition then row order.
  457. * @return True when the rows pass the checks and any needed cache write succeeds.
  458. */
  459. [[nodiscard]] bool
  460. publish_vendor_catalog(std::span<const vendors::IndexEntry> index,
  461. std::span<const vendors::Definition> definitions,
  462. std::span<const vendors::SaleRow> saleRows,
  463. std::span<const vendors::InstalledRow> installedRows) noexcept;
  464. /**
  465. * Finds one vendor's index row, which carries the index the wire uses.
  466. * @param definitionHash Vendor definition hash.
  467. * @param entry Receives the matching row.
  468. * @return True when the catalog is ready and exactly one row carries the hash.
  469. */
  470. [[nodiscard]] bool find_vendor_index(std::uint32_t definitionHash,
  471. vendors::IndexEntry& entry) noexcept;
  472. /**
  473. * Finds one extracted vendor definition.
  474. * @param definitionHash Vendor definition hash.
  475. * @param definition Receives the matching definition.
  476. * @return True when the catalog is ready and holds that definition.
  477. */
  478. [[nodiscard]] bool find_vendor_definition(std::uint32_t definitionHash,
  479. vendors::Definition& definition) noexcept;
  480. /** @return True only when every domain is ready and any needed cache write succeeds. */
  481. [[nodiscard]] bool persist() noexcept;
  482. } // namespace sunrise::state::build_data