wut  v1.7.0
Wii U Toolchain
ITimeAccessorDetails.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <coreinit/time.h>
4 #include <nn/result.h>
5 #include <wut.h>
6 
7 #ifdef __cplusplus
8 
9 namespace nn::sl {
10  class Condition;
11  class DrcManager;
12  class KillerNotificationSelector;
13  class TitleListCache;
14 
15  namespace details {
16  class ITimeAccessorBase;
17  struct ITimeAccessorInternal;
18 
21 
22  struct WUT_PACKED ITimeAccessorInternalVTable {
23  ITimeAccessorBase *instance; // Is normally padding
24  uint32_t info;
25  WUT_PADDING_BYTES(4);
26  uint32_t destructor;
27  WUT_PADDING_BYTES(4);
29  WUT_PADDING_BYTES(4);
31  };
32  WUT_CHECK_SIZE(ITimeAccessorInternalVTable, 0x20);
33  WUT_CHECK_OFFSET(ITimeAccessorInternalVTable, 0x00, instance);
34  WUT_CHECK_OFFSET(ITimeAccessorInternalVTable, 0x14, GetNetworkTimeFn);
35  WUT_CHECK_OFFSET(ITimeAccessorInternalVTable, 0x1C, GetLocalTimeFn);
36 
37  typedef struct WUT_PACKED ITimeAccessorInternal {
40  WUT_CHECK_SIZE(ITimeAccessorInternal, 0x04);
41  WUT_CHECK_OFFSET(ITimeAccessorInternal, 0x00, vtable);
42 
44  friend class nn::sl::Condition;
45  friend class nn::sl::DrcManager;
47  friend class nn::sl::TitleListCache;
48 
49  public:
50  ITimeAccessorBase() = default;
51 
52  virtual ~ITimeAccessorBase() = default;
53 
54  virtual nn::Result GetNetworkTime(OSTime *, bool *) const = 0;
55  virtual nn::Result GetLocalTime(OSTime *, bool *) const = 0;
56 
57  private:
58  virtual details::ITimeAccessorInternal *GetInternal() = 0;
59  };
60 
62  public:
63  explicit TimeAccessorFromPtr(details::ITimeAccessorInternal *ptr) : mInstancePtr(ptr) {
64  }
65  nn::Result GetNetworkTime(OSTime *outTime, bool *outSuccess) const override {
66  if (!mInstancePtr) {
68  }
69  return mInstancePtr->vtable->GetNetworkTimeFn(mInstancePtr, outTime, outSuccess);
70  }
71  nn::Result GetLocalTime(OSTime *outTime, bool *outSuccess) const override {
72  if (!mInstancePtr) {
74  }
75  return mInstancePtr->vtable->GetLocalTimeFn(mInstancePtr, outTime, outSuccess);
76  }
77 
78  private:
79  details::ITimeAccessorInternal *GetInternal() override {
80  return mInstancePtr;
81  }
82 
83  details::ITimeAccessorInternal *mInstancePtr;
84  };
85  } // namespace details
86 
87 
88 } // namespace nn::sl
89 
90 #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
virtual ~ITimeAccessorBase()=default
virtual nn::Result GetLocalTime(OSTime *, bool *) const =0
virtual nn::Result GetNetworkTime(OSTime *, bool *) const =0
TimeAccessorFromPtr(details::ITimeAccessorInternal *ptr)
nn::Result GetLocalTime(OSTime *outTime, bool *outSuccess) const override
nn::Result GetNetworkTime(OSTime *outTime, bool *outSuccess) const override
int64_t OSTime
Definition: time.h:18
struct nn::sl::details::ITimeAccessorInternal ITimeAccessorInternal
nn::Result(* ITimeAccessor_GetNetworkTimeFn)(ITimeAccessorInternal *, OSTime *, bool *)
nn::Result(* ITimeAccessor_GetLocalTimeFn)(ITimeAccessorInternal *, OSTime *, bool *)
ITimeAccessor_GetNetworkTimeFn GetNetworkTimeFn
ITimeAccessorInternalVTable * vtable