metaforce/Runtime/CFactoryMgr.hpp

35 lines
1.0 KiB
C++
Raw Normal View History

2016-02-13 09:02:47 +00:00
#ifndef __PSHAG_CFACTORYMGR_HPP__
#define __PSHAG_CFACTORYMGR_HPP__
2015-08-23 06:42:29 +00:00
#include <unordered_map>
#include "RetroTypes.hpp"
2016-02-16 05:50:41 +00:00
#include "IOStreams.hpp"
2015-08-23 06:42:29 +00:00
2016-03-04 23:04:53 +00:00
namespace urde
2015-08-23 06:42:29 +00:00
{
2016-02-17 03:42:27 +00:00
struct SObjectTag;
2015-08-23 06:42:29 +00:00
class CVParamTransfer;
2016-02-16 05:50:41 +00:00
class IObj;
2015-08-23 06:42:29 +00:00
2016-02-16 05:50:41 +00:00
using CFactoryFnReturn = std::unique_ptr<IObj>;
2016-03-04 23:04:53 +00:00
using FFactoryFunc = std::function<CFactoryFnReturn(const urde::SObjectTag& tag,
urde::CInputStream& in,
const urde::CVParamTransfer& vparms)>;
2015-08-23 06:42:29 +00:00
class CFactoryMgr
{
2016-02-16 05:50:41 +00:00
std::unordered_map<FourCC, FFactoryFunc> m_factories;
2015-08-23 06:42:29 +00:00
public:
2016-03-04 23:04:53 +00:00
CFactoryFnReturn MakeObject(const SObjectTag& tag, urde::CInputStream& in,
2016-02-16 05:50:41 +00:00
const CVParamTransfer& paramXfer);
CFactoryFnReturn MakeObjectFromMemory(const SObjectTag& tag, void* buf, int size, bool compressed,
const CVParamTransfer& paramXfer);
void AddFactory(FourCC key, FFactoryFunc func)
2015-08-23 06:42:29 +00:00
{
m_factories[key] = func;
}
};
}
2016-02-13 09:02:47 +00:00
#endif // __PSHAG_CFACTORYMGR_HPP__