factory.h
1 // Copyright 2016 Citra Emulator Project 2 // Licensed under GPLv2 or any later version 3 // Refer to the license.txt file included. 4 5 #pragma once 6 7 #include <memory> 8 #include <string> 9 #include "core/frontend/camera/interface.h" 10 11 namespace Camera { 12 13 class CameraFactory { 14 public: 15 virtual ~CameraFactory(); 16 17 /** 18 * Creates a camera object based on the configuration string. 19 * @param config Configuration string to create the camera. The implementation can decide the 20 * meaning of this string. 21 * @param flip The image flip to apply 22 * @returns a unique_ptr to the created camera object. 23 */ 24 virtual std::unique_ptr<CameraInterface> Create(const std::string& config, 25 const Service::CAM::Flip& flip) = 0; 26 27 /** 28 * Creates a camera object for preview based on the configuration string. 29 * @param config Configuration string to create the camera. The implementation can decide the 30 * meaning of this string. 31 * @param flip The image flip to apply 32 * @returns a unique_ptr to the created camera object. 33 * Note: The default implementation for this is to call Create(). Derived classes may have other 34 * Implementations. For example, A dialog may be used instead of LOG_ERROR when error 35 * occurs. 36 */ 37 virtual std::unique_ptr<CameraInterface> CreatePreview(const std::string& config, int width, 38 int height, 39 const Service::CAM::Flip& flip) { 40 return Create(config, flip); 41 } 42 }; 43 44 /** 45 * Registers an external camera factory. 46 * @param name Identifier of the camera factory. 47 * @param factory Camera factory to register. 48 */ 49 void RegisterFactory(const std::string& name, std::unique_ptr<CameraFactory> factory); 50 51 /** 52 * Creates a camera from the factory. 53 * @param name Identifier of the camera factory. 54 * @param config Configuration string to create the camera. The meaning of this string is 55 * defined by the factory. 56 */ 57 std::unique_ptr<CameraInterface> CreateCamera(const std::string& name, const std::string& config, 58 const Service::CAM::Flip& flip); 59 60 /** 61 * Creates a camera from the factory for previewing. 62 * @param name Identifier of the camera factory. 63 * @param config Configuration string to create the camera. The meaning of this string is 64 * defined by the factory. 65 */ 66 std::unique_ptr<CameraInterface> CreateCameraPreview(const std::string& name, 67 const std::string& config, int width, 68 int height, const Service::CAM::Flip& flip); 69 70 } // namespace Camera