wut  v1.7.0
Wii U Toolchain
LaunchInfoDatabase.h
Go to the documentation of this file.
1 #pragma once
2 
3 #ifdef __cplusplus
4 
5 #include <nn/result.h>
6 #include <nn/sl/FileStream.h>
7 #include <nn/sl/sl_cpp.h>
8 #include <optional>
9 #include <wut.h>
10 
11 namespace nn::sl {
12  namespace details {
13  typedef struct WUT_PACKED LaunchInfoDatabaseInternal {
14  uint64_t *currentIdPtr;
15  uint32_t *entryCountPtr;
16  uint32_t *maxEntriesPtr;
17  void *pDatabase;
20  uint32_t systemTableNum;
22  WUT_CHECK_SIZE(LaunchInfoDatabaseInternal, 0x1C);
23  WUT_CHECK_OFFSET(LaunchInfoDatabaseInternal, 0x00, currentIdPtr);
24  WUT_CHECK_OFFSET(LaunchInfoDatabaseInternal, 0x04, entryCountPtr);
25  WUT_CHECK_OFFSET(LaunchInfoDatabaseInternal, 0x08, maxEntriesPtr);
26  WUT_CHECK_OFFSET(LaunchInfoDatabaseInternal, 0x0C, pDatabase);
27  WUT_CHECK_OFFSET(LaunchInfoDatabaseInternal, 0x10, entriesPtr);
28  WUT_CHECK_OFFSET(LaunchInfoDatabaseInternal, 0x14, systemTablePtr);
29  WUT_CHECK_OFFSET(LaunchInfoDatabaseInternal, 0x18, systemTableNum);
30 
45  } // namespace details
46 
48  public:
51  }
52 
54  Finalize();
55  }
56 
57  void Finalize() {
58  // Only actually call finalize if the database is still loaded, otherwise we might trigger an assertion.
59  if (mInstance.pDatabase != nullptr) {
61  }
62  }
63 
65  if (mInstance.pDatabase != nullptr) { // Avoid triggering an assertion
67  }
68  return Load__Q3_2nn2sl18LaunchInfoDatabaseFRQ3_2nn2sl7IStreamQ3_2nn2sl6Region(&mInstance, fileStream.GetInternal(), region);
69  }
70 
72  if (mInstance.pDatabase == nullptr) { // Avoid triggering an assertion
74  }
75  return Store__Q3_2nn2sl18LaunchInfoDatabaseCFRQ3_2nn2sl7IStream(&mInstance, fileStream.GetInternal());
76  }
77 
78  nn::Result LoadInitial(int maxEntries, nn::sl::Region region) {
79  if (mInstance.pDatabase != nullptr) { // Avoid triggering an assertion
81  }
82  return LoadInitial__Q3_2nn2sl18LaunchInfoDatabaseFUiQ3_2nn2sl6Region(&mInstance, maxEntries, region);
83  }
84 
85  nn::Result GetLaunchInfoById(nn::sl::LaunchInfo *launchInfo, uint64_t id) const {
86  if (mInstance.pDatabase == nullptr) { // Avoid triggering an assertion
88  }
90  }
91 
92  [[nodiscard]] std::optional<uint32_t> GetEntryCount() const {
93  if (mInstance.pDatabase == nullptr) { // Avoid triggering an assertion
94  return {};
95  }
97  }
98 
99  [[nodiscard]] std::optional<uint64_t> GetCurrentId() const {
100  if (mInstance.pDatabase == nullptr) { // Avoid triggering an assertion
101  return {};
102  }
104  }
105 
106  [[nodiscard]] std::optional<uint64_t> Register(const nn::sl::LaunchInfo &launchInfo) {
107  if (mInstance.pDatabase == nullptr) { // Avoid triggering an assertion
108  return {};
109  }
111  }
112 
113  [[nodiscard]] nn::Result Unregister(uint64_t id) {
114  if (mInstance.pDatabase == nullptr) { // Avoid triggering an assertion
116  }
118  }
119 
120  void Clear() {
121  if (mInstance.pDatabase == nullptr) { // Avoid triggering an assertion
122  return;
123  }
125  }
126 
127  static nn::Result LoadInitial(LaunchInfoDatabase &launchDatabase, uint32_t maxEntries, nn::sl::LaunchInfoDatabaseEntry *defaultEntries, uint32_t defaultEntryNum) {
128  if (launchDatabase.mInstance.pDatabase != nullptr) { // Avoid triggering an assertion
130  }
131  return details::__CPR84__LoadInitial__Q3_2nn2sl18LaunchInfoDatabaseFUiPCQ4_2nn2slJ22J5EntryT1(&launchDatabase.mInstance, maxEntries, defaultEntries, defaultEntryNum);
132  }
133 
134  static uint32_t ListLaunchInfos(const LaunchInfoDatabase &launchDatabase, nn::sl::LaunchInfoDatabaseEntry *entriesOut, uint32_t num) {
135  if (launchDatabase.mInstance.pDatabase == nullptr) { // Avoid triggering an assertion
136  return 0;
137  }
139  }
140 
141  static nn::Result Load(LaunchInfoDatabase &launchDatabase, nn::sl::details::IStreamBase &fileStream, nn::sl::LaunchInfoDatabaseEntry *defaultEntries, uint32_t defaultEntryNum) {
142  if (launchDatabase.mInstance.pDatabase != nullptr) { // Avoid triggering an assertion
144  }
145  return details::__CPR93__Load__Q3_2nn2sl18LaunchInfoDatabaseFRQ3_2nn2sl7IStreamPCQ4_2nn2slJ15J5EntryUi(&launchDatabase.mInstance, fileStream.GetInternal(), defaultEntries, defaultEntryNum);
146  }
147 
148  private:
150  };
151 
152 } // namespace nn::sl
153 
154 #endif
Result value type used by nn libraries.
Definition: result.h:68
@ LEVEL_FATAL
Definition: result.h:73
@ RESULT_MODULE_NN_SL
Definition: result.h:114
std::optional< uint64_t > GetCurrentId() const
nn::Result Unregister(uint64_t id)
nn::Result GetLaunchInfoById(nn::sl::LaunchInfo *launchInfo, uint64_t id) const
static uint32_t ListLaunchInfos(const LaunchInfoDatabase &launchDatabase, nn::sl::LaunchInfoDatabaseEntry *entriesOut, uint32_t num)
static nn::Result Load(LaunchInfoDatabase &launchDatabase, nn::sl::details::IStreamBase &fileStream, nn::sl::LaunchInfoDatabaseEntry *defaultEntries, uint32_t defaultEntryNum)
std::optional< uint32_t > GetEntryCount() const
nn::Result Store(nn::sl::details::IStreamBase &fileStream)
nn::Result LoadInitial(int maxEntries, nn::sl::Region region)
nn::Result Load(nn::sl::details::IStreamBase &fileStream, nn::sl::Region region)
std::optional< uint64_t > Register(const nn::sl::LaunchInfo &launchInfo)
static nn::Result LoadInitial(LaunchInfoDatabase &launchDatabase, uint32_t maxEntries, nn::sl::LaunchInfoDatabaseEntry *defaultEntries, uint32_t defaultEntryNum)
nn::Result GetLaunchInfoById__Q3_2nn2sl18LaunchInfoDatabaseCFPQ3_2nn2sl10LaunchInfoUL(LaunchInfoDatabaseInternal *, nn::sl::LaunchInfo *, uint64_t titleId)
LaunchInfoDatabaseInternal * __ct__Q3_2nn2sl18LaunchInfoDatabaseFv(LaunchInfoDatabaseInternal *)
uint64_t GetCurrentId__Q3_2nn2sl18LaunchInfoDatabaseCFv(LaunchInfoDatabaseInternal *)
uint64_t Register__Q3_2nn2sl18LaunchInfoDatabaseFRCQ3_2nn2sl10LaunchInfo(LaunchInfoDatabaseInternal *, const nn::sl::LaunchInfo &)
nn::Result LoadInitial__Q3_2nn2sl18LaunchInfoDatabaseFUiQ3_2nn2sl6Region(LaunchInfoDatabaseInternal *, int, nn::sl::Region)
nn::Result Store__Q3_2nn2sl18LaunchInfoDatabaseCFRQ3_2nn2sl7IStream(LaunchInfoDatabaseInternal *, nn::sl::details::IStreamInternal *)
struct nn::sl::details::LaunchInfoDatabaseInternal LaunchInfoDatabaseInternal
uint32_t __CPR86__ListLaunchInfos__Q3_2nn2sl18LaunchInfoDatabaseCFPQ4_2nn2slJ26J5EntryUi(LaunchInfoDatabaseInternal *, nn::sl::LaunchInfoDatabaseEntry *entriesOut, uint32_t num)
nn::Result Load__Q3_2nn2sl18LaunchInfoDatabaseFRQ3_2nn2sl7IStreamQ3_2nn2sl6Region(LaunchInfoDatabaseInternal *, nn::sl::details::IStreamInternal *, nn::sl::Region)
uint32_t GetEntryCount__Q3_2nn2sl18LaunchInfoDatabaseCFv(LaunchInfoDatabaseInternal *)
void Clear__Q3_2nn2sl18LaunchInfoDatabaseFv(LaunchInfoDatabaseInternal *)
nn::Result Unregister__Q3_2nn2sl18LaunchInfoDatabaseFUL(LaunchInfoDatabaseInternal *, uint64_t)
nn::Result __CPR93__Load__Q3_2nn2sl18LaunchInfoDatabaseFRQ3_2nn2sl7IStreamPCQ4_2nn2slJ15J5EntryUi(LaunchInfoDatabaseInternal *, details::IStreamInternal *stream, nn::sl::LaunchInfoDatabaseEntry *defaultEntries, uint32_t defaultEntryNum)
nn::Result __CPR84__LoadInitial__Q3_2nn2sl18LaunchInfoDatabaseFUiPCQ4_2nn2slJ22J5EntryT1(LaunchInfoDatabaseInternal *, uint32_t max_entries, nn::sl::LaunchInfoDatabaseEntry *defaultEntries, uint32_t defaultEntryNum)
void Finalize__Q3_2nn2sl18LaunchInfoDatabaseFv(LaunchInfoDatabaseInternal *)
Region
Definition: sl_cpp.h:239