Mantid
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
Mantid::API::FunctionFactoryImpl Class Referencefinal

The FunctionFactory class is in charge of the creation of concrete instances of fitting functions. More...

#include <FunctionFactory.h>

Inheritance diagram for Mantid::API::FunctionFactoryImpl:
Mantid::Kernel::DynamicFactory< IFunction >

Public Member Functions

std::shared_ptr< IFunctioncreateFunction (const std::string &type) const
 Creates an instance of a function. More...
 
std::shared_ptr< IFunctioncreateInitialized (const std::string &input) const
 Creates an instance of a function. More...
 
std::shared_ptr< MultiDomainFunctioncreateInitializedMultiDomainFunction (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...
 
FunctionFactoryImploperator= (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< IFunctioncreate (const std::string &className) const
 Creates a new instance of the class with the given name. More...
 
virtual IFunctioncreateUnwrapped (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...
 
DynamicFactoryoperator= (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< CompositeFunctioncreateComposite (const Expression &expr, std::map< std::string, std::string > &parentAttributes) const
 Create a composite function. More...
 
std::shared_ptr< IPeakFunctioncreatePeakFunction (const Expression &expr, const std::string &name) const
 
std::shared_ptr< IFunctioncreateSimple (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...
 

Detailed Description

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.

Author
Roman Tolchenov, Tessella Support Services plc
Date
27/10/2009

Definition at line 43 of file FunctionFactory.h.

Constructor & Destructor Documentation

◆ FunctionFactoryImpl() [1/2]

Mantid::API::FunctionFactoryImpl::FunctionFactoryImpl ( const FunctionFactoryImpl )
delete

◆ FunctionFactoryImpl() [2/2]

Mantid::API::FunctionFactoryImpl::FunctionFactoryImpl ( )
private

Private Constructor for singleton class.

Definition at line 26 of file FunctionFactory.cpp.

References Mantid::Kernel::SingletonHolder< T >::Instance().

◆ ~FunctionFactoryImpl()

Mantid::API::FunctionFactoryImpl::~FunctionFactoryImpl ( )
overrideprivatedefault

Private Destructor.

Member Function Documentation

◆ addConstraint() [1/2]

void Mantid::API::FunctionFactoryImpl::addConstraint ( const std::shared_ptr< IFunction > &  fun,
const Expression constraint_expr,
const Expression penalty_expr 
) const
private

Add a single constraint to the created function with non-default penalty.

Add a constraint to the function with non-default penalty.

Parameters
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().

◆ addConstraint() [2/2]

void Mantid::API::FunctionFactoryImpl::addConstraint ( const std::shared_ptr< IFunction > &  fun,
const Expression expr 
) const
private

Add a single constraint to the created function.

Add a constraints to the function.

Parameters
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().

◆ addConstraints()

void Mantid::API::FunctionFactoryImpl::addConstraints ( const std::shared_ptr< IFunction > &  fun,
const Expression expr 
) const
private

Add constraints to the created function.

Parameters
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().

◆ addTie()

void Mantid::API::FunctionFactoryImpl::addTie ( const std::shared_ptr< IFunction > &  fun,
const Expression expr 
) const
private

Add a tie to the created function.

Parameters
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().

◆ addTies()

void Mantid::API::FunctionFactoryImpl::addTies ( const std::shared_ptr< IFunction > &  fun,
const Expression expr 
) const
private

Add ties to the created function.

Parameters
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().

◆ createComposite()

CompositeFunction_sptr Mantid::API::FunctionFactoryImpl::createComposite ( const Expression expr,
std::map< std::string, std::string > &  parentAttributes 
) const
private

Create a composite function.

Create a composite function from an expression.

Parameters
expr:: The input expression
parentAttributes:: An output map filled with the attribute name & values of the parent function
Returns
A pointer to the created 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().

◆ createFunction()

IFunction_sptr Mantid::API::FunctionFactoryImpl::createFunction ( const std::string &  type) const

Creates an instance of a function.

Parameters
type:: The function's type
Returns
A pointer to the created function

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().

◆ createInitialized()

IFunction_sptr Mantid::API::FunctionFactoryImpl::createInitialized ( const std::string &  input) const

Creates an instance of a function.

Parameters
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"
Returns
A pointer to the created function

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().

◆ createInitializedMultiDomainFunction()

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.

Parameters
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.
Returns
A pointer to the created function.

Definition at line 87 of file FunctionFactory.cpp.

References createInitialized().

Referenced by export_FunctionFactory().

◆ createPeakFunction()

std::shared_ptr< IPeakFunction > Mantid::API::FunctionFactoryImpl::createPeakFunction ( const Expression expr,
const std::string &  name 
) const
private

◆ createSimple()

IFunction_sptr Mantid::API::FunctionFactoryImpl::createSimple ( const Expression expr,
std::map< std::string, std::string > &  parentAttributes 
) const
private

Create a simple function.

Create a function from an expression.

Parameters
expr:: The input expression
parentAttributes:: An output map filled with the attribute name & values of the parent function
Returns
A pointer to the created 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().

◆ getFunctionNames()

template<typename FunctionType >
std::vector< std::string > Mantid::API::FunctionFactoryImpl::getFunctionNames

Query available functions based on the template type.

Template Parameters
FunctionType:: The type of the functions to list
Returns
A vector of the names of the functions matching the template type

Definition at line 114 of file FunctionFactory.h.

References Mantid::Kernel::DynamicFactory< IFunction >::getKeys(), m_cachedFunctionNames, and m_mutex.

◆ getFunctionNamesGUI()

std::vector< std::string > Mantid::API::FunctionFactoryImpl::getFunctionNamesGUI ( ) const

◆ inputError()

void Mantid::API::FunctionFactoryImpl::inputError ( const std::string &  str = "") const
private

Throw an exception.

Definition at line 274 of file FunctionFactory.cpp.

Referenced by createComposite(), createInitialized(), and createSimple().

◆ operator=()

FunctionFactoryImpl & Mantid::API::FunctionFactoryImpl::operator= ( const FunctionFactoryImpl )
delete

◆ subscribe()

void Mantid::API::FunctionFactoryImpl::subscribe ( const std::string &  className,
std::unique_ptr< AbstractFactory pAbstractFactory,
Kernel::DynamicFactory< IFunction >::SubscribeAction  replace = ErrorIfExists 
)

◆ unsubscribe()

void Mantid::API::FunctionFactoryImpl::unsubscribe ( const std::string &  className)

Friends And Related Function Documentation

◆ Mantid::Kernel::CreateUsingNew< FunctionFactoryImpl >

Definition at line 70 of file FunctionFactory.h.

Member Data Documentation

◆ m_cachedFunctionNames

std::map<std::string, std::vector<std::string> > Mantid::API::FunctionFactoryImpl::m_cachedFunctionNames
mutableprivate

Definition at line 105 of file FunctionFactory.h.

Referenced by getFunctionNames(), subscribe(), and unsubscribe().

◆ m_mutex

std::mutex Mantid::API::FunctionFactoryImpl::m_mutex
mutableprivate

Definition at line 106 of file FunctionFactory.h.

Referenced by getFunctionNames().


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