From eb16fefa15910c7c369b96b8c45c2889e005e8e4 Mon Sep 17 00:00:00 2001 From: Danilo Date: Fri, 2 Aug 2024 11:29:56 -0300 Subject: [PATCH] Comentarios e adiciona RemoveService em GameServiceContainer --- framework/game/servicecontainer.cpp | 8 ++++++++ inc/xna/game/servicecontainer.hpp | 5 +++++ 2 files changed, 13 insertions(+) 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; };