#ifndef __PSHAG_CFACTORYMGR_HPP__ #define __PSHAG_CFACTORYMGR_HPP__ #include #include "RetroTypes.hpp" #include "IOStreams.hpp" namespace urde { struct SObjectTag; class CVParamTransfer; class IObj; using CFactoryFnReturn = std::unique_ptr; using FFactoryFunc = std::function; using FMemFactoryFunc = std::function&& in, u32 len, const urde::CVParamTransfer& vparms)>; class CFactoryMgr { std::unordered_map m_factories; std::unordered_map m_memFactories; public: CFactoryFnReturn MakeObject(const SObjectTag& tag, urde::CInputStream& in, const CVParamTransfer& paramXfer); bool CanMakeMemory(const urde::SObjectTag& tag) const; CFactoryFnReturn MakeObjectFromMemory(const SObjectTag& tag, std::unique_ptr&& buf, int size, bool compressed, const CVParamTransfer& paramXfer); void AddFactory(FourCC key, FFactoryFunc func) { m_factories[key] = func; } void AddFactory(FourCC key, FMemFactoryFunc func) { m_memFactories[key] = func; } }; } #endif // __PSHAG_CFACTORYMGR_HPP__