1
0
mirror of https://github.com/borgesdan/xn65 synced 2024-12-29 21:54:47 +01:00
xn65/framework/game/servicecontainer.cpp

26 lines
574 B
C++

#include "xna/game/servicecontainer.hpp"
namespace xna {
void GameServiceContainer::AddService(Type& type, std::any& provider)
{
auto hashCode = type.GetHashCode();
services.insert({ hashCode, provider });
}
std::any GameServiceContainer::GetService(Type& serviceType)
{
auto hashCode = serviceType.GetHashCode();
return services.contains(hashCode)
? services[hashCode]
: std::any();
}
void GameServiceContainer::RemoveService(Type& type) {
auto hashCode = type.GetHashCode();
if (services.contains(hashCode))
services.erase(hashCode);
}
}