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-02-13 09:02:47 +00:00
|
|
|
namespace pshag
|
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>;
|
|
|
|
using FFactoryFunc = std::function<CFactoryFnReturn(const pshag::SObjectTag& tag,
|
|
|
|
pshag::CInputStream& in,
|
|
|
|
const pshag::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-02-16 05:50:41 +00:00
|
|
|
CFactoryFnReturn MakeObject(const SObjectTag& tag, pshag::CInputStream& in,
|
|
|
|
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__
|