metaforce/Runtime/CFactoryMgr.hpp

48 lines
1.5 KiB
C++
Raw Normal View History

2018-10-07 03:42:33 +00:00
#pragma once
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"
2016-04-13 06:07:23 +00:00
#include "IFactory.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
class CFactoryMgr
{
2016-02-16 05:50:41 +00:00
std::unordered_map<FourCC, FFactoryFunc> m_factories;
2016-03-29 23:14:14 +00:00
std::unordered_map<FourCC, FMemFactoryFunc> m_memFactories;
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,
const CVParamTransfer& paramXfer, CObjectReference* selfRef);
2016-03-29 23:14:14 +00:00
bool CanMakeMemory(const urde::SObjectTag& tag) const;
2016-04-13 06:07:23 +00:00
CFactoryFnReturn MakeObjectFromMemory(const SObjectTag& tag,
std::unique_ptr<u8[]>&& buf,
int size, bool compressed,
const CVParamTransfer& paramXfer,
CObjectReference* selfRef);
2016-03-31 02:44:43 +00:00
void AddFactory(FourCC key, FFactoryFunc func) {m_factories[key] = func;}
void AddFactory(FourCC key, FMemFactoryFunc func) {m_memFactories[key] = func;}
2017-10-26 05:37:46 +00:00
2017-10-31 03:52:22 +00:00
enum class ETypeTable : u8
2017-10-26 05:37:46 +00:00
{
CLSN, CMDL, CSKR, ANIM, CINF, TXTR,
PLTT, FONT, ANCS, EVNT, MADF, MLVL,
MREA, MAPW, MAPA, SAVW, SAVA, PART,
WPSC, SWHC, DPSC, ELSC, CRSC, AFSM,
DCLN, AGSC, ATBL, CSNG, STRG, SCAN,
PATH, DGRP, HMAP, CTWK, FRME, HINT,
2017-10-27 10:10:32 +00:00
MAPU, DUMB, OIDS,
Invalid = 127
2017-10-26 05:37:46 +00:00
};
static ETypeTable FourCCToTypeIdx(FourCC fcc);
static FourCC TypeIdxToFourCC(ETypeTable fcc);
2015-08-23 06:42:29 +00:00
};
}