#ifndef GAME_OBJECT_FACTORY_H
#define GAME_OBJECT_FACTORY_H

#include <map>

#include "game/game_object.h"

typedef GameObject* (*createGameObject_t)();

class GameObjectFactory
{
public:
	void Register(const RuntimeClass* _pRuntimeClass, createGameObject_t _createObjectFunc);

	template <typename T>
	void Register();

	GameObject* Create(const char* classname);

private:
	std::map<const RuntimeClass*, createGameObject_t> m_factories;
};

template<typename T>
inline void GameObjectFactory::Register()
{
	Register(GetRuntimeClass<T>(), T::_Construct);
}

extern GameObjectFactory* g_objectFactory;

#endif // !GAME_OBJECT_FACTORY_H
