SourceXtractorPlusPlus
0.8
Please provide a description of the project.
|
Keep a registry of supported engines, and bridge their factory methods. More...
#include <LeastSquareEngineManager.h>
Classes | |
struct | StaticEngine |
Public Types | |
using | FactoryMethod = std::function< std::shared_ptr< LeastSquareEngine >(unsigned)> |
Static Public Member Functions | |
static void | registerEngine (const std::string &name, FactoryMethod factory_method) |
static std::vector< std::string > | getImplementations () |
static std::shared_ptr < LeastSquareEngine > | create (const std::string &name, unsigned max_iterations=1000) |
Keep a registry of supported engines, and bridge their factory methods.
Engines can register themselves at compilation time using StaticEngine. In this manner, the final binary can have an arbitrary number of supported engines depending on the available dependencies when compiling.
Different engines may have different parametrization, so it is up to the respective factory methods to initialize them. The only parameter passed down to the factories is the maximum number of iterations.
Definition at line 29 of file LeastSquareEngineManager.h.
using ModelFitting::LeastSquareEngineManager::FactoryMethod = std::function<std::shared_ptr<LeastSquareEngine>(unsigned)> |
Factory methods must return a shared pointer to LeastSquareEngine, and receive an unsigned that sets the maximum number of iterations.
Definition at line 36 of file LeastSquareEngineManager.h.
|
static |
Create an instance of an engine 'name'
name | The name of the engine, as passed to registerEngine. Case insensitive. |
max_iterations | Maximum number of iterations. |
Definition at line 36 of file LeastSquareEngineManager.cpp.
References e, std::end(), ModelFitting::getEngineFactories(), and std::ostringstream::str().
Referenced by SourceXtractor::MoffatModelFittingTask::computeProperties(), SourceXtractor::FlexibleModelFittingTask::computeProperties(), and main().
|
static |
Definition at line 28 of file LeastSquareEngineManager.cpp.
References e, std::vector< T >::emplace_back(), and ModelFitting::getEngineFactories().
|
static |
Register a new engine.
name | The name of the engine. Case insensitive. |
factory_method | The function to call for creating a new instance. |
Definition at line 21 of file LeastSquareEngineManager.cpp.
References std::end(), std::find(), and ModelFitting::getEngineFactories().
Referenced by ModelFitting::LeastSquareEngineManager::StaticEngine::StaticEngine().