summaryrefslogtreecommitdiffstats
path: root/src/core/frontend/camera/factory.cpp
diff options
context:
space:
mode:
authorwwylele <wwylele@gmail.com>2016-12-21 19:05:56 +0100
committerwwylele <wwylele@gmail.com>2017-01-11 10:46:44 +0100
commitcf3a272332b03640730d1434e9802e166ca931da (patch)
tree7297bf1b38679cb84b5baa7c98b5b9e729560131 /src/core/frontend/camera/factory.cpp
parentMerge pull request #2369 from MerryMage/core-frontend (diff)
downloadyuzu-cf3a272332b03640730d1434e9802e166ca931da.tar
yuzu-cf3a272332b03640730d1434e9802e166ca931da.tar.gz
yuzu-cf3a272332b03640730d1434e9802e166ca931da.tar.bz2
yuzu-cf3a272332b03640730d1434e9802e166ca931da.tar.lz
yuzu-cf3a272332b03640730d1434e9802e166ca931da.tar.xz
yuzu-cf3a272332b03640730d1434e9802e166ca931da.tar.zst
yuzu-cf3a272332b03640730d1434e9802e166ca931da.zip
Diffstat (limited to 'src/core/frontend/camera/factory.cpp')
-rw-r--r--src/core/frontend/camera/factory.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/core/frontend/camera/factory.cpp b/src/core/frontend/camera/factory.cpp
new file mode 100644
index 000000000..4b4da50dd
--- /dev/null
+++ b/src/core/frontend/camera/factory.cpp
@@ -0,0 +1,32 @@
+// Copyright 2016 Citra Emulator Project
+// Licensed under GPLv2 or any later version
+// Refer to the license.txt file included.
+
+#include <unordered_map>
+#include "common/logging/log.h"
+#include "core/frontend/camera/blank_camera.h"
+#include "core/frontend/camera/factory.h"
+
+namespace Camera {
+
+static std::unordered_map<std::string, std::unique_ptr<CameraFactory>> factories;
+
+CameraFactory::~CameraFactory() = default;
+
+void RegisterFactory(const std::string& name, std::unique_ptr<CameraFactory> factory) {
+ factories[name] = std::move(factory);
+}
+
+std::unique_ptr<CameraInterface> CreateCamera(const std::string& name, const std::string& config) {
+ auto pair = factories.find(name);
+ if (pair != factories.end()) {
+ return pair->second->Create(config);
+ }
+
+ if (name != "blank") {
+ LOG_ERROR(Service_CAM, "Unknown camera \"%s\"", name.c_str());
+ }
+ return std::make_unique<BlankCamera>();
+}
+
+} // namespace Camera