diff options
author | Yuri Kunde Schlesner <yuriks@yuriks.net> | 2017-01-30 07:16:39 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-30 07:16:39 +0100 |
commit | 1410aa182435fcca3756bbb58af90a479e9f248d (patch) | |
tree | 53685c7e5422428869ef45d4f8de0a350dcfdd7f /src/core/frontend/camera/factory.cpp | |
parent | Merge pull request #2429 from wwylele/auto-language-fix (diff) | |
parent | CAM: implement basic camera functions with a blank camera (diff) | |
download | yuzu-1410aa182435fcca3756bbb58af90a479e9f248d.tar yuzu-1410aa182435fcca3756bbb58af90a479e9f248d.tar.gz yuzu-1410aa182435fcca3756bbb58af90a479e9f248d.tar.bz2 yuzu-1410aa182435fcca3756bbb58af90a479e9f248d.tar.lz yuzu-1410aa182435fcca3756bbb58af90a479e9f248d.tar.xz yuzu-1410aa182435fcca3756bbb58af90a479e9f248d.tar.zst yuzu-1410aa182435fcca3756bbb58af90a479e9f248d.zip |
Diffstat (limited to 'src/core/frontend/camera/factory.cpp')
-rw-r--r-- | src/core/frontend/camera/factory.cpp | 32 |
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 |