diff --git a/framework/game/servicecontainer.cpp b/framework/game/servicecontainer.cpp index 3673966..1749d3b 100644 --- a/framework/game/servicecontainer.cpp +++ b/framework/game/servicecontainer.cpp @@ -15,4 +15,12 @@ namespace xna { ? services[hashCode] : std::any(); } + + void GameServiceContainer::RemoveService(Type& type) { + auto hashCode = type.GetHashCode(); + + if (services.contains(hashCode)) + services.erase(hashCode); + + } } \ No newline at end of file diff --git a/inc/xna/game/servicecontainer.hpp b/inc/xna/game/servicecontainer.hpp index 69255d0..d50d4fc 100644 --- a/inc/xna/game/servicecontainer.hpp +++ b/inc/xna/game/servicecontainer.hpp @@ -6,13 +6,18 @@ #include namespace xna { + //A collection of game services. class GameServiceContainer : public IServiceProvider { public: + //Adds a service to the GameServiceContainer. void AddService(Type& type, std::any& provider); // Inherited via IServiceProvider std::any GetService(Type& serviceType) override; + //Removes the object providing a specified service. + void RemoveService(Type& type); + private: std::map services; };