#pragma once #include "RetroTypes.hpp" namespace urde { class IObj { public: virtual ~IObj() = default; }; class TObjOwnerDerivedFromIObjUntyped : public IObj { protected: void* m_objPtr; public: TObjOwnerDerivedFromIObjUntyped(void* objPtr) : m_objPtr(objPtr) {} }; template class TObjOwnerDerivedFromIObj : public TObjOwnerDerivedFromIObjUntyped { TObjOwnerDerivedFromIObj(T* objPtr) : TObjOwnerDerivedFromIObjUntyped(objPtr) {} public: static std::unique_ptr> GetNewDerivedObject(std::unique_ptr&& obj) { return std::unique_ptr> (new TObjOwnerDerivedFromIObj(obj.release())); } ~TObjOwnerDerivedFromIObj() {std::default_delete()(static_cast(m_objPtr));} T* GetObj() {return static_cast(m_objPtr);} }; }