summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service
diff options
context:
space:
mode:
authorDavid Marcec <dmarcecguzman@gmail.com>2018-10-06 08:49:01 +0200
committerDavid Marcec <dmarcecguzman@gmail.com>2018-10-06 08:49:01 +0200
commitf84b9ed4e8c38928e8e1bb57c2914256375b5af4 (patch)
tree248a593e98e8a14ed4a111dc9ad5241aa639784c /src/core/hle/service
parentMerge pull request #1447 from lioncash/mutex (diff)
downloadyuzu-f84b9ed4e8c38928e8e1bb57c2914256375b5af4.tar
yuzu-f84b9ed4e8c38928e8e1bb57c2914256375b5af4.tar.gz
yuzu-f84b9ed4e8c38928e8e1bb57c2914256375b5af4.tar.bz2
yuzu-f84b9ed4e8c38928e8e1bb57c2914256375b5af4.tar.lz
yuzu-f84b9ed4e8c38928e8e1bb57c2914256375b5af4.tar.xz
yuzu-f84b9ed4e8c38928e8e1bb57c2914256375b5af4.tar.zst
yuzu-f84b9ed4e8c38928e8e1bb57c2914256375b5af4.zip
Diffstat (limited to 'src/core/hle/service')
-rw-r--r--src/core/hle/service/sm/sm.h19
1 files changed, 19 insertions, 0 deletions
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 <memory>
#include <string>
+#include <type_traits>
#include <unordered_map>
+#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<Kernel::SharedPtr<Kernel::ClientPort>> GetServicePort(const std::string& name);
ResultVal<Kernel::SharedPtr<Kernel::ClientSession>> ConnectToService(const std::string& name);
+ template <typename T>
+ std::shared_ptr<T> GetService(const std::string& service_name) const {
+ static_assert(std::is_base_of_v<Kernel::SessionRequestHandler, T>,
+ "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<T>(port->hle_handler);
+ }
+
void InvokeControlRequest(Kernel::HLERequestContext& context);
private: