summaryrefslogtreecommitdiffstats
path: root/src/common/input.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/input.h')
-rw-r--r--src/common/input.h40
1 files changed, 37 insertions, 3 deletions
diff --git a/src/common/input.h b/src/common/input.h
index cb30b7254..449e0193f 100644
--- a/src/common/input.h
+++ b/src/common/input.h
@@ -383,6 +383,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 +405,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 +434,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 +461,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