summaryrefslogtreecommitdiffstats
path: root/src/common/input.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/common/input.h41
1 files changed, 38 insertions, 3 deletions
diff --git a/src/common/input.h b/src/common/input.h
index cb30b7254..fc14fd7bf 100644
--- a/src/common/input.h
+++ b/src/common/input.h
@@ -8,6 +8,7 @@
#include <string>
#include <unordered_map>
#include <utility>
+#include <vector>
#include "common/logging/log.h"
#include "common/param_package.h"
#include "common/uuid.h"
@@ -383,6 +384,16 @@ void RegisterFactory(const std::string& name, std::shared_ptr<Factory<InputDevic
}
}
+inline void RegisterInputFactory(const std::string& name,
+ std::shared_ptr<Factory<InputDevice>> factory) {
+ RegisterFactory<InputDevice>(name, std::move(factory));
+}
+
+inline void RegisterOutputFactory(const std::string& name,
+ std::shared_ptr<Factory<OutputDevice>> factory) {
+ RegisterFactory<OutputDevice>(name, std::move(factory));
+}
+
/**
* Unregisters an input device factory.
* @tparam InputDeviceType the type of input devices the factory can create
@@ -395,6 +406,14 @@ void UnregisterFactory(const std::string& name) {
}
}
+inline void UnregisterInputFactory(const std::string& name) {
+ UnregisterFactory<InputDevice>(name);
+}
+
+inline void UnregisterOutputFactory(const std::string& name) {
+ UnregisterFactory<OutputDevice>(name);
+}
+
/**
* Create an input device from given paramters.
* @tparam InputDeviceType the type of input devices to create
@@ -416,13 +435,21 @@ std::unique_ptr<InputDeviceType> CreateDeviceFromString(const std::string& param
return pair->second->Create(package);
}
+inline std::unique_ptr<InputDevice> CreateInputDeviceFromString(const std::string& params) {
+ return CreateDeviceFromString<InputDevice>(params);
+}
+
+inline std::unique_ptr<OutputDevice> CreateOutputDeviceFromString(const std::string& params) {
+ return CreateDeviceFromString<OutputDevice>(params);
+}
+
/**
- * Create an input device from given paramters.
+ * Create an input device from given parameters.
* @tparam InputDeviceType the type of input devices to create
- * @param A ParamPackage that contains all parameters for creating the device
+ * @param package A ParamPackage that contains all parameters for creating the device
*/
template <typename InputDeviceType>
-std::unique_ptr<InputDeviceType> CreateDevice(const Common::ParamPackage package) {
+std::unique_ptr<InputDeviceType> CreateDevice(const ParamPackage& package) {
const std::string engine = package.Get("engine", "null");
const auto& factory_list = Impl::FactoryList<InputDeviceType>::list;
const auto pair = factory_list.find(engine);
@@ -435,4 +462,12 @@ std::unique_ptr<InputDeviceType> CreateDevice(const Common::ParamPackage package
return pair->second->Create(package);
}
+inline std::unique_ptr<InputDevice> CreateInputDevice(const ParamPackage& package) {
+ return CreateDevice<InputDevice>(package);
+}
+
+inline std::unique_ptr<OutputDevice> CreateOutputDevice(const ParamPackage& package) {
+ return CreateDevice<OutputDevice>(package);
+}
+
} // namespace Common::Input