metaforce/Runtime/CResFactory.hpp

72 lines
1.8 KiB
C++
Raw Normal View History

2016-04-13 06:07:23 +00:00
#ifndef __URDE_CRESFACTORY_HPP__
#define __URDE_CRESFACTORY_HPP__
2015-08-17 20:33:58 +00:00
2015-08-23 06:42:29 +00:00
#include <unordered_map>
2015-08-18 05:54:43 +00:00
#include "IFactory.hpp"
2015-08-23 06:42:29 +00:00
#include "CResLoader.hpp"
#include "IVParamObj.hpp"
2015-08-18 05:54:43 +00:00
2016-03-04 23:04:53 +00:00
namespace urde
{
class IDvdRequest;
2015-08-18 05:54:43 +00:00
class CResFactory : public IFactory
2015-08-17 20:33:58 +00:00
{
2015-08-23 06:42:29 +00:00
CResLoader x4_loader;
2015-08-22 01:58:41 +00:00
public:
2015-08-23 06:42:29 +00:00
struct SLoadingData
{
SObjectTag x0_tag;
IDvdRequest* x8_dvdReq = nullptr;
IObj** xc_targetPtr = nullptr;
void* x10_loadBuffer = nullptr;
u32 x14_resSize = 0;
CVParamTransfer x18_cvXfer;
SLoadingData() = default;
SLoadingData(const SObjectTag& tag, IObj** ptr, const CVParamTransfer& xfer)
: x0_tag(tag), xc_targetPtr(ptr), x18_cvXfer(xfer) {}
2015-08-23 06:42:29 +00:00
};
private:
std::unordered_map<SObjectTag, SLoadingData> m_loadList;
void AddToLoadList(const SLoadingData& data) {m_loadList[data.x0_tag] = data;}
2015-08-23 06:42:29 +00:00
public:
2015-08-27 00:23:46 +00:00
CResLoader& GetLoader() {return x4_loader;}
2015-08-23 06:42:29 +00:00
std::unique_ptr<IObj> Build(const SObjectTag&, const CVParamTransfer&);
2015-08-22 01:58:41 +00:00
void BuildAsync(const SObjectTag&, const CVParamTransfer&, IObj**);
void CancelBuild(const SObjectTag&);
bool CanBuild(const SObjectTag& tag)
{
return x4_loader.ResourceExists(tag);
}
const SObjectTag* GetResourceIdByName(const char* name) const
{
return x4_loader.GetResourceIdByName(name);
}
2015-08-23 06:42:29 +00:00
2016-04-14 21:42:47 +00:00
FourCC GetResourceTypeById(ResId id) const
{
return x4_loader.GetResourceTypeById(id);
}
2015-08-23 06:42:29 +00:00
std::vector<std::pair<std::string, SObjectTag>> GetResourceIdToNameList() const
{
std::vector<std::pair<std::string, SObjectTag>> retval;
return retval;
}
2016-09-25 01:58:20 +00:00
void EnumerateResources(std::function<bool(const SObjectTag&)> lambda) const
{
}
void EnumerateNamedResources(std::function<bool(const std::string&, const SObjectTag&)> lambda) const
{
}
2015-08-17 20:33:58 +00:00
};
}
2016-04-13 06:07:23 +00:00
#endif // __URDE_CRESFACTORY_HPP__