From f84b9ed4e8c38928e8e1bb57c2914256375b5af4 Mon Sep 17 00:00:00 2001 From: David Marcec Date: Sat, 6 Oct 2018 16:49:01 +1000 Subject: Ported #4296 from citra This will allow us to easily remove the use of "NFC" in "System" --- src/core/hle/service/sm/sm.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/core/hle/service') diff --git a/src/core/hle/service/sm/sm.h b/src/core/hle/service/sm/sm.h index da2c51082..4f8145dda 100644 --- a/src/core/hle/service/sm/sm.h +++ b/src/core/hle/service/sm/sm.h @@ -6,9 +6,12 @@ #include #include +#include #include +#include "core/hle/kernel/client_port.h" #include "core/hle/kernel/object.h" +#include "core/hle/kernel/server_port.h" #include "core/hle/result.h" #include "core/hle/service/service.h" @@ -48,6 +51,22 @@ public: ResultVal> GetServicePort(const std::string& name); ResultVal> ConnectToService(const std::string& name); + template + std::shared_ptr GetService(const std::string& service_name) const { + static_assert(std::is_base_of_v, + "Not a base of ServiceFrameworkBase"); + auto service = registered_services.find(service_name); + if (service == registered_services.end()) { + LOG_DEBUG(Service, "Can't find service: {}", service_name); + return nullptr; + } + auto port = service->second->GetServerPort(); + if (port == nullptr) { + return nullptr; + } + return std::static_pointer_cast(port->hle_handler); + } + void InvokeControlRequest(Kernel::HLERequestContext& context); private: -- cgit v1.2.3