diff --git a/Fit/Test/Minimizer/MinimizerTests.cpp b/Fit/Test/Minimizer/MinimizerTests.cpp index c72ad99a61e99762260dfe9541415dc6f8b6fa2d..eddbedd58dc049e60460de9b6c7cc46fa1cb1a39 100644 --- a/Fit/Test/Minimizer/MinimizerTests.cpp +++ b/Fit/Test/Minimizer/MinimizerTests.cpp @@ -14,21 +14,11 @@ #include "Fit/Kernel/Minimizer.h" #include "Fit/Test/Minimizer/PlanCases.h" -#include "Fit/Test/Minimizer/PlanFactory.h" #include "Tests/GTestWrapper/google_test.h" class Minimize : public ::testing::Test { }; -bool run(const std::string& minimizer_name, const std::string& algorithm_name, - const std::string& fit_plan_name, const std::string& options = "") -{ - auto plan = PlanFactory().createItemPtr(fit_plan_name); - mumufit::Minimizer minimizer; - minimizer.setMinimizer(minimizer_name, algorithm_name, options); - return plan->checkMinimizer(minimizer); -} - bool run(const std::string& minimizer_name, const std::string& algorithm_name, MinimizerTestPlan& plan, const std::string& options = "") { diff --git a/Fit/Test/Minimizer/PlanFactory.cpp b/Fit/Test/Minimizer/PlanFactory.cpp deleted file mode 100644 index 0622e39b0c8dc25a7099c50fd75ea4c718b27c0f..0000000000000000000000000000000000000000 --- a/Fit/Test/Minimizer/PlanFactory.cpp +++ /dev/null @@ -1,29 +0,0 @@ -// ************************************************************************************************ -// -// BornAgain: simulate and fit reflection and scattering -// -//! @file Fit/Test/Minimizer/PlanFactory.cpp -//! @brief Implements class FunctionTestPlanFactory -//! -//! @homepage http://www.bornagainproject.org -//! @license GNU General Public License v3 or higher (see COPYING) -//! @copyright Forschungszentrum Jülich GmbH 2018 -//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS) -// -// ************************************************************************************************ - -#include "Fit/Test/Minimizer/PlanFactory.h" -#include "Fit/Test/Minimizer/PlanCases.h" - -using mumufit::test::create_new; - -PlanFactory::PlanFactory() -{ - registerItem("RosenbrockPlan", create_new<RosenbrockPlan>); - registerItem("EasyRosenbrockPlan", create_new<EasyRosenbrockPlan>); - registerItem("WoodFourPlan", create_new<WoodFourPlan>); - registerItem("EasyWoodFourPlan", create_new<EasyWoodFourPlan>); - registerItem("DecayingSinPlan", create_new<DecayingSinPlan>); - registerItem("DecayingSinPlanV2", create_new<DecayingSinPlanV2>); - registerItem("TestMinimizerPlan", create_new<TestMinimizerPlan>); -} diff --git a/Fit/Test/Minimizer/PlanFactory.h b/Fit/Test/Minimizer/PlanFactory.h deleted file mode 100644 index 4e1e11d09e8822eafeaa4c327ff4efef94014200..0000000000000000000000000000000000000000 --- a/Fit/Test/Minimizer/PlanFactory.h +++ /dev/null @@ -1,28 +0,0 @@ -// ************************************************************************************************ -// -// BornAgain: simulate and fit reflection and scattering -// -//! @file Fit/Test/Minimizer/PlanFactory.h -//! @brief Defines class FunctionTestPlanFactory -//! -//! @homepage http://www.bornagainproject.org -//! @license GNU General Public License v3 or higher (see COPYING) -//! @copyright Forschungszentrum Jülich GmbH 2018 -//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS) -// -// ************************************************************************************************ - -#ifndef BORNAGAIN_FIT_TEST_MINIMIZER_PLANFACTORY_H -#define BORNAGAIN_FIT_TEST_MINIMIZER_PLANFACTORY_H - -#include "Fit/TestEngine/IFactory.h" -#include "Fit/TestEngine/MinimizerTestPlan.h" - -//! Factory to generate plans for fitting objective functions. - -class PlanFactory : public mumufit::test::IFactory<std::string, MinimizerTestPlan> { -public: - PlanFactory(); -}; - -#endif // BORNAGAIN_FIT_TEST_MINIMIZER_PLANFACTORY_H diff --git a/Fit/TestEngine/IFactory.h b/Fit/TestEngine/IFactory.h deleted file mode 100644 index fc5616cb3fdb26a6d9739b219117eeb971c41992..0000000000000000000000000000000000000000 --- a/Fit/TestEngine/IFactory.h +++ /dev/null @@ -1,90 +0,0 @@ -// ************************************************************************************************ -// -// BornAgain: simulate and fit reflection and scattering -// -//! @file Fit/TestEngine/IFactory.h -//! @brief Defines interface class IFactory. -//! -//! @homepage http://www.bornagainproject.org -//! @license GNU General Public License v3 or higher (see COPYING) -//! @copyright Forschungszentrum Jülich GmbH 2018 -//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS) -// -// ************************************************************************************************ - -#ifdef SWIG -#error no need to expose this header to Swig -#endif - -#ifndef USER_API -#ifndef BORNAGAIN_FIT_TESTENGINE_IFACTORY_H -#define BORNAGAIN_FIT_TESTENGINE_IFACTORY_H - -#include <cassert> -#include <functional> -#include <iostream> // debug -#include <map> -#include <memory> -#include <sstream> - -namespace mumufit::test { - -//! Base class for all factories. - -template <class Key, class AbstractProduct> class IFactory { -public: - //! function which will be used to create object of AbstractProduct base type - using CreateItemCallback = std::function<AbstractProduct*()>; - - //! map for correspondence between object identifier and object creation function - using CallbackMap_t = std::map<Key, CreateItemCallback>; - - //! Creates object by calling creation function corresponded to given identifier - AbstractProduct* createItem(const Key& item_key) const - { - auto it = m_callbacks.find(item_key); - assert(it != m_callbacks.end()); - return (it->second)(); - } - -#ifndef SWIG - std::unique_ptr<AbstractProduct> createItemPtr(const Key& item_key) const - { - return std::unique_ptr<AbstractProduct>{createItem(item_key)}; - } -#endif - - //! Registers object's creation function - bool registerItem(const Key& item_key, CreateItemCallback CreateFn) - { - assert(m_callbacks.find(item_key) == m_callbacks.end()); - return m_callbacks.insert(make_pair(item_key, CreateFn)).second; - } - - bool contains(const Key& item_key) const - { - return m_callbacks.find(item_key) != m_callbacks.end(); - } - - //! Returns number of registered objects - size_t size() const { return m_callbacks.size(); } - -protected: - CallbackMap_t m_callbacks; //!< map of correspondence of objectsId and creation functions -}; - -//! Returns new instance of class T. -//! -//! This templated function is used in catalogs in form of a function pointer -//! 'create_new<T>', with no function arguments supplied. Equivalently, we could -//! use a lambda function '[](){return new T;}'. - -template <class T> T* create_new() -{ - return new T(); -} - -} // namespace mumufit::test - -#endif // BORNAGAIN_FIT_TESTENGINE_IFACTORY_H -#endif // USER_API