metaforce/Runtime/CFactoryMgr.cpp

37 lines
964 B
C++
Raw Normal View History

2016-02-16 05:50:41 +00:00
#include "CFactoryMgr.hpp"
#include "IObj.hpp"
2016-03-04 23:04:53 +00:00
namespace urde
2016-02-16 05:50:41 +00:00
{
2016-03-04 23:04:53 +00:00
CFactoryFnReturn CFactoryMgr::MakeObject(const SObjectTag& tag, urde::CInputStream& in,
2016-02-16 05:50:41 +00:00
const CVParamTransfer& paramXfer)
{
auto search = m_factories.find(tag.type);
if (search == m_factories.end())
return {};
return search->second(tag, in, paramXfer);
}
CFactoryFnReturn CFactoryMgr::MakeObjectFromMemory(const SObjectTag& tag, void* buf, int size,
bool compressed, const CVParamTransfer& paramXfer)
{
auto search = m_factories.find(tag.type);
if (search == m_factories.end())
return {};
if (compressed)
{
2016-03-04 23:04:53 +00:00
CZipInputStream r(std::make_unique<athena::io::MemoryReader>(buf, size));
2016-02-16 05:50:41 +00:00
return search->second(tag, r, paramXfer);
}
else
{
CMemoryInStream r(buf, size);
2016-02-16 05:50:41 +00:00
return search->second(tag, r, paramXfer);
}
}
}