| 1 | #pragma once |
| 2 | |
| 3 | #include "hostio/seadHostIOEventListener.h" |
| 4 | #include "prim/seadBitFlag.h" |
| 5 | #include "prim/seadSafeString.h" |
| 6 | |
| 7 | namespace sead |
| 8 | { |
| 9 | class Heap; |
| 10 | |
| 11 | namespace hostio |
| 12 | { |
| 13 | class Context; |
| 14 | class GenEvent; |
| 15 | |
| 16 | class Reflexible : public NodeEventListener |
| 17 | { |
| 18 | public: |
| 19 | enum class NodeClassType |
| 20 | { |
| 21 | /// sead::hostio::Reflexible |
| 22 | Reflexible = 0, |
| 23 | /// sead::hostio::Node |
| 24 | Node = 1, |
| 25 | /// Other classes |
| 26 | Other = 2, |
| 27 | }; |
| 28 | |
| 29 | virtual NodeClassType getNodeClassType() const { return NodeClassType::Reflexible; } |
| 30 | |
| 31 | enum class AllocFlg |
| 32 | { |
| 33 | Name = 1u << 0u, |
| 34 | Meta = 1u << 1u, |
| 35 | }; |
| 36 | |
| 37 | #ifdef SEAD_DEBUG |
| 38 | Reflexible(); |
| 39 | Reflexible(Heap* heap, IDisposer::HeapNullOption heap_null_option); |
| 40 | ~Reflexible() override { disposeHostIOImpl_(); } |
| 41 | |
| 42 | void listenNodeEvent([[maybe_unused]] const NodeEvent* event) override {} |
| 43 | virtual void genMessage([[maybe_unused]] Context* context) {} |
| 44 | virtual SafeString getMetaFilename() { return SafeString::cEmptyString; } |
| 45 | virtual void genObjectInfo(const GenEvent* event, u32); |
| 46 | virtual Reflexible* searchNode([[maybe_unused]] const SafeString& name) { return nullptr; } |
| 47 | virtual void calcURL(BufferedSafeString* url) const { url->copy("" ); } |
| 48 | virtual void calcNodeURL(const Reflexible* reflexible, BufferedSafeString* url) |
| 49 | { |
| 50 | return reflexible->calcURL(url); |
| 51 | } |
| 52 | |
| 53 | void callGenMessage(Context*, u32); |
| 54 | void correctChildNodeInfo(Context*); |
| 55 | void baseListen(const PropertyEvent* event); |
| 56 | void applyEventDataToMemory(const PropertyEvent* event); |
| 57 | |
| 58 | SafeString getNodeName() const { return mName; } |
| 59 | void setNodeName(const SafeString& name); |
| 60 | void setNodeNameCopyString(const SafeString& name, Heap* heap); |
| 61 | |
| 62 | SafeString getNodeMeta() const { return mMeta; } |
| 63 | void setNodeMeta(const SafeString& meta); |
| 64 | void setNodeMetaCopyString(const SafeString& meta, Heap* heap); |
| 65 | |
| 66 | protected: |
| 67 | void disposeHostIO() override |
| 68 | { |
| 69 | disposeHostIOImpl_(); |
| 70 | NodeEventListener::disposeHostIO(); |
| 71 | } |
| 72 | virtual void genChildNode(Context* context); |
| 73 | virtual bool isHaveChild() const { return false; } |
| 74 | |
| 75 | private: |
| 76 | using ApplyEventDataToMemoryCallback = bool (*)(const PropertyEvent* event); |
| 77 | |
| 78 | void safeDelete_(AllocFlg flag); |
| 79 | const char* createStringBuffer_(AllocFlg flag, const SafeString& name, Heap* heap); |
| 80 | void disposeHostIOImpl_(); |
| 81 | |
| 82 | const char* mName; |
| 83 | const char* mMeta; |
| 84 | bool mIsGenerated = false; |
| 85 | BitFlag8 mAllocFlg; |
| 86 | static ApplyEventDataToMemoryCallback sApplyEventDataToMemoryCallback; |
| 87 | #endif |
| 88 | }; |
| 89 | } // namespace hostio |
| 90 | } // namespace sead |
| 91 | |