2016-04-13 06:07:23 +00:00
|
|
|
#ifndef __URDE_IFACTORY_HPP__
|
|
|
|
#define __URDE_IFACTORY_HPP__
|
2015-08-18 05:54:43 +00:00
|
|
|
|
2015-08-23 06:42:29 +00:00
|
|
|
#include <memory>
|
2016-09-25 01:58:20 +00:00
|
|
|
#include <functional>
|
2015-08-22 01:58:41 +00:00
|
|
|
#include "RetroTypes.hpp"
|
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
namespace urde
|
2015-08-18 05:54:43 +00:00
|
|
|
{
|
2015-08-22 01:58:41 +00:00
|
|
|
class CVParamTransfer;
|
|
|
|
class IObj;
|
2016-09-02 19:32:57 +00:00
|
|
|
class CObjectReference;
|
2017-10-26 05:37:46 +00:00
|
|
|
class CResLoader;
|
|
|
|
class CFactoryMgr;
|
2017-10-26 10:09:51 +00:00
|
|
|
class CSimplePool;
|
2017-10-27 10:10:32 +00:00
|
|
|
class IDvdRequest;
|
2015-08-18 05:54:43 +00:00
|
|
|
|
2016-04-13 06:07:23 +00:00
|
|
|
using CFactoryFnReturn = std::unique_ptr<IObj>;
|
|
|
|
using FFactoryFunc = std::function<CFactoryFnReturn(const urde::SObjectTag& tag,
|
|
|
|
urde::CInputStream& in,
|
2016-09-02 19:32:57 +00:00
|
|
|
const urde::CVParamTransfer& vparms,
|
|
|
|
CObjectReference* selfRef)>;
|
2016-04-13 06:07:23 +00:00
|
|
|
using FMemFactoryFunc = std::function<CFactoryFnReturn(const urde::SObjectTag& tag,
|
|
|
|
std::unique_ptr<u8[]>&& in, u32 len,
|
2016-09-02 19:32:57 +00:00
|
|
|
const urde::CVParamTransfer& vparms,
|
|
|
|
CObjectReference* selfRef)>;
|
2016-04-13 06:07:23 +00:00
|
|
|
|
2015-08-18 05:54:43 +00:00
|
|
|
class IFactory
|
|
|
|
{
|
2015-08-22 01:58:41 +00:00
|
|
|
public:
|
2016-03-28 22:39:56 +00:00
|
|
|
virtual ~IFactory() = default;
|
2016-09-02 19:32:57 +00:00
|
|
|
virtual CFactoryFnReturn Build(const SObjectTag&, const CVParamTransfer&, CObjectReference*)=0;
|
2017-10-26 10:09:51 +00:00
|
|
|
virtual void BuildAsync(const SObjectTag&, const CVParamTransfer&, std::unique_ptr<IObj>*, CObjectReference*)=0;
|
2015-08-22 01:58:41 +00:00
|
|
|
virtual void CancelBuild(const SObjectTag&)=0;
|
|
|
|
virtual bool CanBuild(const SObjectTag&)=0;
|
2015-08-28 00:11:31 +00:00
|
|
|
virtual const SObjectTag* GetResourceIdByName(const char*) const=0;
|
2017-08-13 05:26:14 +00:00
|
|
|
virtual FourCC GetResourceTypeById(CAssetId id) const=0;
|
2016-09-25 01:58:20 +00:00
|
|
|
virtual void EnumerateResources(const std::function<bool(const SObjectTag&)>& lambda) const=0;
|
|
|
|
virtual void EnumerateNamedResources(const std::function<bool(const std::string&, const SObjectTag&)>& lambda) const=0;
|
2017-10-27 10:10:32 +00:00
|
|
|
virtual CResLoader* GetResLoader() { return nullptr; }
|
|
|
|
virtual CFactoryMgr* GetFactoryMgr() { return nullptr; }
|
2017-10-26 10:09:51 +00:00
|
|
|
virtual void LoadOriginalIDs(CSimplePool& sp) {}
|
|
|
|
virtual void AsyncIdle() {}
|
2016-07-23 21:41:18 +00:00
|
|
|
|
|
|
|
/* Non-factory versions, replaces CResLoader */
|
|
|
|
virtual u32 ResourceSize(const urde::SObjectTag& tag)=0;
|
2017-10-27 10:10:32 +00:00
|
|
|
virtual std::shared_ptr<IDvdRequest> LoadResourceAsync(const urde::SObjectTag& tag, void* target)=0;
|
2017-11-05 02:08:05 +00:00
|
|
|
virtual std::shared_ptr<IDvdRequest> LoadResourcePartAsync(const urde::SObjectTag& tag, u32 off, u32 size, void* target)=0;
|
2016-07-23 21:41:18 +00:00
|
|
|
virtual std::unique_ptr<u8[]> LoadResourceSync(const urde::SObjectTag& tag)=0;
|
2017-11-05 02:08:05 +00:00
|
|
|
virtual std::unique_ptr<u8[]> LoadNewResourcePartSync(const urde::SObjectTag& tag, u32 off, u32 size)=0;
|
2017-02-12 23:56:03 +00:00
|
|
|
virtual void GetTagListForFile(const char* pakName, std::vector<SObjectTag>& out) const {}
|
|
|
|
|
2017-08-13 05:26:14 +00:00
|
|
|
virtual CAssetId TranslateOriginalToNew(CAssetId id) const { return -1; }
|
|
|
|
virtual CAssetId TranslateNewToOriginal(CAssetId id) const { return -1; }
|
2015-08-18 05:54:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-04-13 06:07:23 +00:00
|
|
|
#endif // __URDE_IFACTORY_HPP__
|