16 using CreateFunc = std::function<Game*()>;
18 static GameFactory& instance() {
19 static GameFactory factory;
23 void registerClass(CreateFunc createFunc) {
24 this->creatorFunc = createFunc;
27 Game* create(GameInternal* gameInternal) {
28 if (this->creatorFunc ==
nullptr) {
29 throw std::runtime_error(
"No game implementation registered!");
32 Game* game = (this->creatorFunc)();
33 game->gameInternal = gameInternal;
38 CreateFunc creatorFunc =
nullptr;