1 // This file is part of OpenCV project. 2 // It is subject to the license terms in the LICENSE file found in the top-level directory 3 // of this distribution and at http://opencv.org/license.html. 4 5 #ifndef OPENCV_CORE_PARALLEL_FACTORY_HPP 6 #define OPENCV_CORE_PARALLEL_FACTORY_HPP 7 8 #include "opencv2/core/parallel/parallel_backend.hpp" 9 10 namespace cv { namespace parallel { 11 12 class IParallelBackendFactory 13 { 14 public: ~IParallelBackendFactory()15 virtual ~IParallelBackendFactory() {} 16 virtual std::shared_ptr<cv::parallel::ParallelForAPI> create() const = 0; 17 }; 18 19 20 class StaticBackendFactory CV_FINAL: public IParallelBackendFactory 21 { 22 protected: 23 std::function<std::shared_ptr<cv::parallel::ParallelForAPI>(void)> create_fn_; 24 25 public: StaticBackendFactory(std::function<std::shared_ptr<cv::parallel::ParallelForAPI> (void)> && create_fn)26 StaticBackendFactory(std::function<std::shared_ptr<cv::parallel::ParallelForAPI>(void)>&& create_fn) 27 : create_fn_(create_fn) 28 { 29 // nothing 30 } 31 ~StaticBackendFactory()32 ~StaticBackendFactory() CV_OVERRIDE {} 33 create() const34 std::shared_ptr<cv::parallel::ParallelForAPI> create() const CV_OVERRIDE 35 { 36 return create_fn_(); 37 } 38 }; 39 40 // 41 // PluginBackendFactory is implemented in plugin_wrapper.cpp 42 // 43 44 std::shared_ptr<IParallelBackendFactory> createPluginParallelBackendFactory(const std::string& baseName); 45 46 }} // namespace 47 48 #endif // OPENCV_CORE_PARALLEL_FACTORY_HPP 49