Mantid
Loading...
Searching...
No Matches
ConstraintFactory.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
12
13namespace Mantid::API {
14
16 // we need to make sure the library manager has been loaded before we
17 // are constructed so that it is destroyed after us and thus does
18 // not close any loaded DLLs with loaded algorithms in them
20}
21
31IConstraint *ConstraintFactoryImpl::createInitialized(IFunction *fun, const std::string &input, bool isDefault) const {
32 Expression expr;
33 expr.parse(input);
34 return createInitialized(fun, expr, isDefault);
35}
36
44 IConstraint *c = nullptr;
45 if (expr.name() == "==") {
46 c = createUnwrapped("BoundaryConstraint");
47 } else {
48 c = createUnwrapped(expr.name());
49 }
50 c->initialize(fun, expr, isDefault);
51 return c;
52}
53
54} // namespace Mantid::API
ConstraintFactoryImpl()
Private Constructor for singleton class.
IConstraint * createInitialized(IFunction *fun, const std::string &input, bool isDefault=false) const
Creates an instance of a Constraint.
This class represents an expression made up of names, binary operators and brackets.
Definition: Expression.h:36
std::string name() const
Returns the name of the expression which is a function or variable name.
Definition: Expression.h:71
void parse(const std::string &str)
Parse a string and create an expression.
Definition: Expression.cpp:159
An interface to a constraint.
Definition: IConstraint.h:26
virtual void initialize(IFunction *fun, const Expression &expr, bool isDefault=false)=0
Initialize the constraint from an expression.
This is an interface to a fitting function - a semi-abstarct class.
Definition: IFunction.h:163
The dynamic factory is a base dynamic factory for serving up objects in response to requests from oth...
virtual IConstraint * 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.
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...