Mantid
|
The FunctionFactory class is in charge of the creation of concrete instances of fitting functions. More...
#include <FunctionFactory.h>
Public Member Functions | |
std::shared_ptr< IFunction > | createFunction (const std::string &type) const |
Creates an instance of a function. More... | |
std::shared_ptr< IFunction > | createInitialized (const std::string &input) const |
Creates an instance of a function. More... | |
std::shared_ptr< MultiDomainFunction > | createInitializedMultiDomainFunction (const std::string &input, size_t domainNumber) const |
Creates an instnce of an inizialised multidomain function where each domain has the same function. More... | |
FunctionFactoryImpl (const FunctionFactoryImpl &)=delete | |
template<typename FunctionType > | |
std::vector< std::string > | getFunctionNames () const |
Query available functions based on the template type. More... | |
std::vector< std::string > | getFunctionNamesGUI () const |
Get function names that can be used by generic fitting GUIs. More... | |
FunctionFactoryImpl & | operator= (const FunctionFactoryImpl &)=delete |
void | subscribe (const std::string &className, std::unique_ptr< AbstractFactory > pAbstractFactory, Kernel::DynamicFactory< IFunction >::SubscribeAction replace=ErrorIfExists) |
void | unsubscribe (const std::string &className) |
Public Member Functions inherited from Mantid::Kernel::DynamicFactory< IFunction > | |
virtual std::shared_ptr< IFunction > | create (const std::string &className) const |
Creates a new instance of the class with the given name. More... | |
virtual IFunction * | createUnwrapped (const std::string &className) const |
Creates a new instance of the class with the given name, which is not wrapped in a boost shared_ptr. More... | |
void | disableNotifications () |
Disable notifications. More... | |
DynamicFactory (const DynamicFactory &)=delete | |
void | enableNotifications () |
Enable notifications. More... | |
bool | exists (const std::string &className) const |
Returns true if the given class is currently registered. More... | |
virtual const std::vector< std::string > | getKeys () const |
Returns the keys in the map. More... | |
DynamicFactory & | operator= (const DynamicFactory &)=delete |
void | subscribe (const std::string &className) |
Registers the instantiator for the given class with the DynamicFactory. More... | |
void | subscribe (const std::string &className, std::unique_ptr< AbstractFactory > pAbstractFactory, SubscribeAction replace=ErrorIfExists) |
Registers the instantiator for the given class with the DynamicFactory. More... | |
void | unsubscribe (const std::string &className) |
Unregisters the given class and deletes the instantiator for the class. More... | |
virtual | ~DynamicFactory ()=default |
Destroys the DynamicFactory and deletes the instantiators for all registered classes. More... | |
Private Member Functions | |
void | addConstraint (const std::shared_ptr< IFunction > &fun, const Expression &constraint_expr, const Expression &penalty_expr) const |
Add a single constraint to the created function with non-default penalty. More... | |
void | addConstraint (const std::shared_ptr< IFunction > &fun, const Expression &expr) const |
Add a single constraint to the created function. More... | |
void | addConstraints (const std::shared_ptr< IFunction > &fun, const Expression &expr) const |
Add constraints to the created function. More... | |
void | addTie (const std::shared_ptr< IFunction > &fun, const Expression &expr) const |
Add a tie to the created function. More... | |
void | addTies (const std::shared_ptr< IFunction > &fun, const Expression &expr) const |
Add ties to the created function. More... | |
std::shared_ptr< CompositeFunction > | createComposite (const Expression &expr, std::map< std::string, std::string > &parentAttributes) const |
Create a composite function. More... | |
std::shared_ptr< IPeakFunction > | createPeakFunction (const Expression &expr, const std::string &name) const |
std::shared_ptr< IFunction > | createSimple (const Expression &expr, std::map< std::string, std::string > &parentAttributes) const |
Create a simple function. More... | |
FunctionFactoryImpl () | |
Private Constructor for singleton class. More... | |
void | inputError (const std::string &str="") const |
Throw an exception. More... | |
~FunctionFactoryImpl () override=default | |
Private Destructor. More... | |
Private Attributes | |
std::map< std::string, std::vector< std::string > > | m_cachedFunctionNames |
std::mutex | m_mutex |
Friends | |
struct | Mantid::Kernel::CreateUsingNew< FunctionFactoryImpl > |
Additional Inherited Members | |
Public Types inherited from Mantid::Kernel::DynamicFactory< IFunction > | |
using | AbstractFactory = AbstractInstantiator< IFunction > |
A typedef for the instantiator. More... | |
enum | NotificationStatus |
Defines the whether notifications are dispatched. More... | |
enum | SubscribeAction |
Defines replacement behaviour. More... | |
Public Attributes inherited from Mantid::Kernel::DynamicFactory< IFunction > | |
Poco::NotificationCenter | notificationCenter |
Sends notifications to observers. More... | |
Protected Member Functions inherited from Mantid::Kernel::DynamicFactory< IFunction > | |
DynamicFactory () | |
Protected constructor for base class. More... | |
The FunctionFactory class is in charge of the creation of concrete instances of fitting functions.
It inherits most of its implementation from the Dynamic Factory base class. It is implemented as a singleton class.
Definition at line 43 of file FunctionFactory.h.
|
delete |
|
private |
Private Constructor for singleton class.
Definition at line 26 of file FunctionFactory.cpp.
References Mantid::Kernel::SingletonHolder< T >::Instance().
|
overrideprivatedefault |
Private Destructor.
|
private |
Add a single constraint to the created function with non-default penalty.
Add a constraint to the function with non-default penalty.
fun | :: The function |
constraint_expr | :: The constraint expression. |
penalty_expr | :: The penalty expression. |
Definition at line 336 of file FunctionFactory.cpp.
References createInitialized(), Mantid::Kernel::SingletonHolder< T >::Instance(), and Mantid::API::Expression::terms().
|
private |
Add a single constraint to the created function.
Add a constraints to the function.
fun | :: The function |
expr | :: The constraint expression. |
Definition at line 324 of file FunctionFactory.cpp.
References createInitialized(), and Mantid::Kernel::SingletonHolder< T >::Instance().
Referenced by addConstraints().
|
private |
Add constraints to the created function.
fun | :: The function |
expr | :: The constraint expression. The expression name must be either a single constraint expression such as "0 < Sigma < 1" or a list of constraint expressions separated by commas ',' and enclosed in brackets "(...)" . |
Definition at line 291 of file FunctionFactory.cpp.
References addConstraint(), Mantid::API::Expression::begin(), Mantid::API::Expression::end(), and Mantid::API::Expression::name().
Referenced by createComposite(), and createSimple().
|
private |
Add a tie to the created function.
fun | :: The function |
expr | :: The tie expression: parName = TieString |
Definition at line 363 of file FunctionFactory.cpp.
References Mantid::API::Expression::size(), Mantid::API::Expression::str(), and value.
Referenced by addTies().
|
private |
Add ties to the created function.
fun | :: The function |
expr | :: The tie expression: either parName = TieString or a list of name = string pairs |
Definition at line 349 of file FunctionFactory.cpp.
References addTie(), and Mantid::API::Expression::name().
Referenced by createComposite(), and createSimple().
|
private |
Create a composite function.
Create a composite function from an expression.
expr | :: The input expression |
parentAttributes | :: An output map filled with the attribute name & values of the parent function |
Definition at line 179 of file FunctionFactory.cpp.
References addConstraints(), addTies(), Mantid::API::Expression::bracketsRemoved(), createComposite(), createFunction(), createSimple(), inputError(), Mantid::API::Expression::name(), Mantid::API::Expression::size(), Mantid::API::Expression::str(), and Mantid::API::Expression::terms().
Referenced by createComposite(), and createInitialized().
IFunction_sptr Mantid::API::FunctionFactoryImpl::createFunction | ( | const std::string & | type | ) | const |
Creates an instance of a function.
type | :: The function's type |
Definition at line 33 of file FunctionFactory.cpp.
References Mantid::Kernel::DynamicFactory< IFunction >::create().
Referenced by createComposite(), Mantid::Algorithms::GetDetectorOffsets::createFunction(), createSimple(), and export_FunctionFactory().
IFunction_sptr Mantid::API::FunctionFactoryImpl::createInitialized | ( | const std::string & | input | ) | const |
Creates an instance of a function.
input | :: An input string which defines the function and initial values for the parameters. Parameters of different functions are separated by ';'. Parameters of the same function are separated by ','. parameterName=value pairs are used to set a parameter value. For each function "name" parameter must be set to a function name. E.g. input = "name=LinearBackground,A0=0,A1=1; name = Gaussian, PeakCentre=10.,Sigma=1" |
Definition at line 51 of file FunctionFactory.cpp.
References Mantid::API::Expression::bracketsRemoved(), createComposite(), createSimple(), inputError(), and Mantid::API::Expression::parse().
Referenced by addConstraint(), createInitializedMultiDomainFunction(), and export_FunctionFactory().
std::shared_ptr< MultiDomainFunction > Mantid::API::FunctionFactoryImpl::createInitializedMultiDomainFunction | ( | const std::string & | input, |
size_t | domainNumber | ||
) | const |
Creates an instnce of an inizialised multidomain function where each domain has the same function.
input | :: An input string which defines the function and initial values for the parameters. Parameters of different functions are separated by ';'. Parameters of the same function are separated by ','. parameterName=value pairs are used to set a parameter value. For each function "name" parameter must be set to a function name. E.g. input = "name=LinearBackground,A0=0,A1=1; name = Gaussian, PeakCentre=10.,Sigma=1" |
domainNumber | :: The number of domains to add to the function. |
Definition at line 87 of file FunctionFactory.cpp.
References createInitialized().
Referenced by export_FunctionFactory().
|
private |
|
private |
Create a simple function.
Create a function from an expression.
expr | :: The input expression |
parentAttributes | :: An output map filled with the attribute name & values of the parent function |
Definition at line 110 of file FunctionFactory.cpp.
References addConstraints(), addTies(), createFunction(), Mantid::API::IFunction::Attribute::fromString(), inputError(), Mantid::API::Expression::name(), Mantid::API::Expression::size(), Mantid::API::Expression::str(), and Mantid::API::Expression::terms().
Referenced by createComposite(), and createInitialized().
std::vector< std::string > Mantid::API::FunctionFactoryImpl::getFunctionNames |
Query available functions based on the template type.
FunctionType | :: The type of the functions to list |
Definition at line 114 of file FunctionFactory.h.
References Mantid::Kernel::DynamicFactory< IFunction >::getKeys(), m_cachedFunctionNames, and m_mutex.
std::vector< std::string > Mantid::API::FunctionFactoryImpl::getFunctionNamesGUI | ( | ) | const |
Get function names that can be used by generic fitting GUIs.
Definition at line 375 of file FunctionFactory.cpp.
References Mantid::Kernel::StringTokenizer::begin(), Mantid::Kernel::StringTokenizer::end(), Mantid::Kernel::SingletonHolder< T >::Instance(), and Mantid::Kernel::StringTokenizer::TOK_TRIM.
|
private |
Throw an exception.
Definition at line 274 of file FunctionFactory.cpp.
Referenced by createComposite(), createInitialized(), and createSimple().
|
delete |
void Mantid::API::FunctionFactoryImpl::subscribe | ( | const std::string & | className, |
std::unique_ptr< AbstractFactory > | pAbstractFactory, | ||
Kernel::DynamicFactory< IFunction >::SubscribeAction | replace = ErrorIfExists |
||
) |
Definition at line 393 of file FunctionFactory.cpp.
References m_cachedFunctionNames, and Mantid::Kernel::DynamicFactory< Base, Comparator >::subscribe().
void Mantid::API::FunctionFactoryImpl::unsubscribe | ( | const std::string & | className | ) |
Definition at line 400 of file FunctionFactory.cpp.
References m_cachedFunctionNames, and Mantid::Kernel::DynamicFactory< Base, Comparator >::unsubscribe().
Referenced by export_FunctionFactory().
|
friend |
Definition at line 70 of file FunctionFactory.h.
|
mutableprivate |
Definition at line 105 of file FunctionFactory.h.
Referenced by getFunctionNames(), subscribe(), and unsubscribe().
|
mutableprivate |
Definition at line 106 of file FunctionFactory.h.
Referenced by getFunctionNames().