Newer
Older
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright © 2007 ISIS Rutherford Appleton Laboratory UKRI,
// NScD Oak Ridge National Laboratory, European Spallation Source
// & Institut Laue - Langevin
// SPDX - License - Identifier: GPL - 3.0 +
Peterson, Peter
committed
#ifndef MANTID_API_CONSTRAINTFACTORY_H_
#define MANTID_API_CONSTRAINTFACTORY_H_
//----------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------
Gigg, Martyn Anthony
committed
#include "MantidAPI/DllConfig.h"
Peterson, Peter
committed
#include "MantidKernel/DynamicFactory.h"
#include "MantidKernel/SingletonHolder.h"
Peterson, Peter
committed
Peterson, Peter
committed
Peterson, Peter
committed
//----------------------------------------------------------------------
Peterson, Peter
committed
//----------------------------------------------------------------------
class IConstraint;
class IFunction;
class Expression;
Peterson, Peter
committed
Peterson, Peter
committed
The ConstraintFactory class is in charge of the creation of concrete
instances of Constraints. It inherits most of its implementation from
the Dynamic Factory base class.
It is implemented as a singleton class.
Peterson, Peter
committed
@author Roman Tolchenov, Tessella Support Services plc
@date 4/02/2010
*/
class MANTID_API_DLL ConstraintFactoryImpl final
: public Kernel::DynamicFactory<IConstraint> {
public:
ConstraintFactoryImpl(const ConstraintFactoryImpl &) = delete;
ConstraintFactoryImpl &operator=(const ConstraintFactoryImpl &) = delete;
/// Creates an instance of a Constraint
IConstraint *createInitialized(IFunction *fun, const std::string &input,
bool isDefault = false) const;
/// Creates an instance of a Constraint
IConstraint *createInitialized(IFunction *fun, const Expression &expr,
bool isDefault = false) const;
private:
friend struct Mantid::Kernel::CreateUsingNew<ConstraintFactoryImpl>;
/// Private Constructor for singleton class
ConstraintFactoryImpl();
/// Private Destructor
Hahn, Steven
committed
~ConstraintFactoryImpl() override = default;
using ConstraintFactory =
Mantid::Kernel::SingletonHolder<ConstraintFactoryImpl>;
Peterson, Peter
committed
} // namespace API
} // namespace Mantid
namespace Mantid {
namespace Kernel {
EXTERN_MANTID_API template class MANTID_API_DLL
Mantid::Kernel::SingletonHolder<Mantid::API::ConstraintFactoryImpl>;
Roman Tolchenov
committed
/**
* Macro for declaring a new type of function to be used with the
* FunctionFactory
Roman Tolchenov
committed
*/
#define DECLARE_CONSTRAINT(classname) \
namespace { \
Mantid::Kernel::RegistrationHelper register_constraint_##classname( \
((Mantid::API::ConstraintFactory::Instance().subscribe<classname>( \
#classname)), \
0)); \
}
Peterson, Peter
committed
#endif /*MANTID_API_CONSTRAINTFACTORY_H_*/