metaforce/Runtime/CFactoryMgr.hpp

75 lines
1.6 KiB
C++
Raw Normal View History

2018-10-06 20:42:33 -07:00
#pragma once
2015-08-22 23:42:29 -07:00
#include <unordered_map>
#include "Runtime/IFactory.hpp"
#include "Runtime/Streams/IOStreams.hpp"
#include "Runtime/RetroTypes.hpp"
2015-08-22 23:42:29 -07:00
2021-04-10 01:42:06 -07:00
namespace metaforce {
2016-02-16 19:42:27 -08:00
struct SObjectTag;
2015-08-22 23:42:29 -07:00
class CVParamTransfer;
2016-02-15 21:50:41 -08:00
class IObj;
2015-08-22 23:42:29 -07:00
2018-12-07 21:30:43 -08:00
class CFactoryMgr {
2022-02-20 16:03:38 -08:00
std::unordered_map<FourCC, FFactoryFunc> x10_factories;
std::unordered_map<FourCC, FMemFactoryFunc> x24_memFactories;
2018-12-07 21:30:43 -08:00
2015-08-22 23:42:29 -07:00
public:
2021-04-10 01:42:06 -07:00
CFactoryFnReturn MakeObject(const SObjectTag& tag, metaforce::CInputStream& in, const CVParamTransfer& paramXfer,
2018-12-07 21:30:43 -08:00
CObjectReference* selfRef);
2021-04-10 01:42:06 -07:00
bool CanMakeMemory(const metaforce::SObjectTag& tag) const;
2018-12-07 21:30:43 -08:00
CFactoryFnReturn MakeObjectFromMemory(const SObjectTag& tag, std::unique_ptr<u8[]>&& buf, int size, bool compressed,
const CVParamTransfer& paramXfer, CObjectReference* selfRef);
2022-02-20 16:03:38 -08:00
void AddFactory(FourCC key, FFactoryFunc func) { x10_factories.insert_or_assign(key, std::move(func)); }
void AddFactory(FourCC key, FMemFactoryFunc func) { x24_memFactories.insert_or_assign(key, std::move(func)); }
2017-10-25 22:37:46 -07:00
2018-12-07 21:30:43 -08:00
enum class ETypeTable : u8 {
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,
MAPU,
DUMB,
OIDS,
Invalid = 127
};
2017-10-25 22:37:46 -07:00
2018-12-07 21:30:43 -08:00
static ETypeTable FourCCToTypeIdx(FourCC fcc);
static FourCC TypeIdxToFourCC(ETypeTable fcc);
2015-08-22 23:42:29 -07:00
};
2021-04-10 01:42:06 -07:00
} // namespace metaforce