aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/hle/service/service.h
diff options
context:
space:
mode:
authorGravatar Yuri Kunde Schlesner <yuriks@yuriks.net>2015-01-30 16:56:49 -0200
committerGravatar Yuri Kunde Schlesner <yuriks@yuriks.net>2015-02-02 15:36:59 -0200
commita79d21c83e3fa433924999940c18e40fe980f50f (patch)
tree938ffa50ced999b31f0ae7194fd7e21126c082b6 /src/core/hle/service/service.h
parent8779b31fe60c728ace89a9b5128b68feffa9c7d7 (diff)
Service: Clean-up Interface
Diffstat (limited to 'src/core/hle/service/service.h')
-rw-r--r--src/core/hle/service/service.h31
1 files changed, 9 insertions, 22 deletions
diff --git a/src/core/hle/service/service.h b/src/core/hle/service/service.h
index 533d3565..121e6993 100644
--- a/src/core/hle/service/service.h
+++ b/src/core/hle/service/service.h
@@ -5,11 +5,12 @@
#pragma once
#include <algorithm>
-#include <map>
#include <string>
#include <unordered_map>
#include <vector>
+#include <boost/container/flat_map.hpp>
+
#include "common/common.h"
#include "common/string_util.h"
#include "core/mem_map.h"
@@ -69,21 +70,6 @@ public:
return "[UNKNOWN SERVICE PORT]";
}
- /// Allocates a new handle for the service
- Handle CreateHandle(Kernel::Object *obj) {
- // TODO(yuriks): Fix error reporting
- Handle handle = Kernel::g_handle_table.Create(obj).ValueOr(INVALID_HANDLE);
- m_handles.push_back(handle);
- return handle;
- }
-
- /// Frees a handle from the service
- template <class T>
- void DeleteHandle(const Handle handle) {
- Kernel::g_handle_table.Close(handle);
- m_handles.erase(std::remove(m_handles.begin(), m_handles.end(), handle), m_handles.end());
- }
-
ResultVal<bool> SyncRequest() override {
u32* cmd_buff = Kernel::GetCommandBuffer();
auto itr = m_functions.find(cmd_buff[0]);
@@ -109,16 +95,17 @@ protected:
/**
* Registers the functions in the service
*/
- void Register(const FunctionInfo* functions, int len) {
- for (int i = 0; i < len; i++) {
- m_functions[functions[i].id] = functions[i];
+ template <size_t N>
+ void Register(const FunctionInfo (&functions)[N]) {
+ m_functions.reserve(N);
+ for (auto& fn : functions) {
+ // Usually this array is sorted by id already, so hint to instead at the end
+ m_functions.emplace_hint(m_functions.cend(), fn.id, fn);
}
}
private:
-
- std::vector<Handle> m_handles;
- std::map<u32, FunctionInfo> m_functions;
+ boost::container::flat_map<u32, FunctionInfo> m_functions;
};