SourceXtractorPlusPlus  0.10
Please provide a description of the project.
Classes | Public Types | Static Public Member Functions | List of all members
ModelFitting::LeastSquareEngineManager Class Reference

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::stringgetImplementations ()
 
static std::shared_ptr< LeastSquareEnginecreate (const std::string &name, unsigned max_iterations=1000)
 

Detailed Description

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 45 of file LeastSquareEngineManager.h.

Member Typedef Documentation

◆ FactoryMethod

Factory methods must return a shared pointer to LeastSquareEngine, and receive an unsigned that sets the maximum number of iterations.

Definition at line 52 of file LeastSquareEngineManager.h.

Member Function Documentation

◆ create()

std::shared_ptr< LeastSquareEngine > ModelFitting::LeastSquareEngineManager::create ( const std::string name,
unsigned  max_iterations = 1000 
)
static

Create an instance of an engine 'name'

Parameters
nameThe name of the engine, as passed to registerEngine. Case insensitive.
max_iterationsMaximum number of iterations.
Returns
A new instance of the specific engine. An Elements::Exception is thrown if the engine name is unknown.

Definition at line 52 of file LeastSquareEngineManager.cpp.

References e, std::end(), ModelFitting::getEngineFactories(), and std::ostringstream::str().

Referenced by SourceXtractor::MoffatModelFittingTask::computeProperties(), SourceXtractor::FlexibleModelFittingTask::computeProperties(), and main().

Here is the call graph for this function:

◆ getImplementations()

std::vector< std::string > ModelFitting::LeastSquareEngineManager::getImplementations ( )
static
Returns
A list of known engines.

Definition at line 44 of file LeastSquareEngineManager.cpp.

References e, std::vector< T >::emplace_back(), and ModelFitting::getEngineFactories().

Here is the call graph for this function:

◆ registerEngine()

void ModelFitting::LeastSquareEngineManager::registerEngine ( const std::string name,
FactoryMethod  factory_method 
)
static

Register a new engine.

Parameters
nameThe name of the engine. Case insensitive.
factory_methodThe function to call for creating a new instance.

Definition at line 37 of file LeastSquareEngineManager.cpp.

References std::end(), std::find(), and ModelFitting::getEngineFactories().

Referenced by ModelFitting::LeastSquareEngineManager::StaticEngine::StaticEngine().

Here is the call graph for this function:

The documentation for this class was generated from the following files: