Ported #4296 from citra
This will allow us to easily remove the use of "NFC" in "System"
This commit is contained in:
parent
095c8d999b
commit
f84b9ed4e8
@ -7,13 +7,13 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
#include "core/hle/kernel/object.h"
|
#include "core/hle/kernel/object.h"
|
||||||
|
#include "core/hle/kernel/server_port.h"
|
||||||
#include "core/hle/result.h"
|
#include "core/hle/result.h"
|
||||||
|
|
||||||
namespace Kernel {
|
namespace Kernel {
|
||||||
|
|
||||||
class ClientSession;
|
class ClientSession;
|
||||||
class KernelCore;
|
class KernelCore;
|
||||||
class ServerPort;
|
|
||||||
|
|
||||||
class ClientPort final : public Object {
|
class ClientPort final : public Object {
|
||||||
public:
|
public:
|
||||||
@ -30,6 +30,10 @@ public:
|
|||||||
return HANDLE_TYPE;
|
return HANDLE_TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SharedPtr<ServerPort> GetServerPort() const {
|
||||||
|
return server_port;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new Session pair, adds the created ServerSession to the associated ServerPort's
|
* Creates a new Session pair, adds the created ServerSession to the associated ServerPort's
|
||||||
* list of pending sessions, and signals the ServerPort, causing any threads
|
* list of pending sessions, and signals the ServerPort, causing any threads
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
#include "core/hle/kernel/object.h"
|
#include "core/hle/kernel/object.h"
|
||||||
#include "core/hle/kernel/wait_object.h"
|
#include "core/hle/kernel/wait_object.h"
|
||||||
|
#include "core/hle/result.h"
|
||||||
|
|
||||||
namespace Kernel {
|
namespace Kernel {
|
||||||
|
|
||||||
|
@ -6,9 +6,12 @@
|
|||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <type_traits>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
|
#include "core/hle/kernel/client_port.h"
|
||||||
#include "core/hle/kernel/object.h"
|
#include "core/hle/kernel/object.h"
|
||||||
|
#include "core/hle/kernel/server_port.h"
|
||||||
#include "core/hle/result.h"
|
#include "core/hle/result.h"
|
||||||
#include "core/hle/service/service.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::ClientPort>> GetServicePort(const std::string& name);
|
||||||
ResultVal<Kernel::SharedPtr<Kernel::ClientSession>> ConnectToService(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);
|
void InvokeControlRequest(Kernel::HLERequestContext& context);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
Reference in New Issue
Block a user