mirror of
https://github.com/CraftyBoss/SuperMarioOdysseyOnline.git
synced 2024-11-19 09:45:14 +00:00
42 lines
1 KiB
C++
42 lines
1 KiB
C++
#pragma once
|
|
|
|
#include "types.h"
|
|
#include "al/util.hpp"
|
|
#include "logger.hpp"
|
|
|
|
namespace al
|
|
{
|
|
template<class T>
|
|
struct NameToCreator
|
|
{
|
|
const char* creatorName;
|
|
T createActorFunction;
|
|
};
|
|
|
|
template<class T>
|
|
class Factory {
|
|
public:
|
|
inline Factory() {};
|
|
|
|
virtual const char * convertName(char const *name) const {
|
|
return name;
|
|
};
|
|
|
|
inline T getCreator(const char *name) {
|
|
for (size_t i = 0; i < this->factoryCount; i++)
|
|
{
|
|
if(isEqualString(this->actorTable[i].creatorName, name)) {
|
|
return this->actorTable[i].createActorFunction;
|
|
}
|
|
}
|
|
return nullptr;
|
|
};
|
|
|
|
protected:
|
|
// 0x0 is vtable
|
|
const char *factoryName; // 0x8
|
|
const al::NameToCreator<T> *actorTable; // 0x10
|
|
int factoryCount; // 0x18
|
|
};
|
|
|
|
} // namespace al
|