FuncMinimizerFactory.h 3.29 KB
Newer Older
1
2
#ifndef MANTID_API_FUNCMINIMIZERFACTORY_H_
#define MANTID_API_FUNCMINIMIZERFACTORY_H_
Peterson, Peter's avatar
Peterson, Peter committed
3
4
5
6
7

//----------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------
#include <vector>
8
#include "MantidAPI/DllConfig.h"
Peterson, Peter's avatar
Peterson, Peter committed
9
10
11
#include "MantidKernel/DynamicFactory.h"
#include "MantidKernel/SingletonHolder.h"

12
13
namespace Mantid {
namespace API {
Peterson, Peter's avatar
Peterson, Peter committed
14
15
16
17

//----------------------------------------------------------------------
// More forward declarations
//----------------------------------------------------------------------
18
class IFuncMinimizer;
Peterson, Peter's avatar
Peterson, Peter committed
19
20
21
22
23
24
25

/** @class FuncMinimizerFactoryImpl

    The FuncMinimizerFactory class is in charge of the creation of concrete
    instances of minimizers. It inherits most of its implementation from
    the Dynamic Factory base class.
    It is implemented as a singleton class.
26

Peterson, Peter's avatar
Peterson, Peter committed
27
28
    @author Anders Markvardsen, ISIS, RAL
    @date 20/05/2010
29
30
31

    Copyright &copy; 2010 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge
   National Laboratory & European Spallation Source
Peterson, Peter's avatar
Peterson, Peter committed
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47

    This file is part of Mantid.

    Mantid is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.

    Mantid is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

48
    File change history is stored at: <https://github.com/mantidproject/mantid>
Peterson, Peter's avatar
Peterson, Peter committed
49
50
*/

51
52
53
54
55
class MANTID_API_DLL FuncMinimizerFactoryImpl
    : public Kernel::DynamicFactory<IFuncMinimizer> {
public:
  /// Creates an instance of a minimizer
  boost::shared_ptr<IFuncMinimizer>
56
  createMinimizer(const std::string &str) const;
57
58
59
60
61
62
63
64
65

private:
  friend struct Mantid::Kernel::CreateUsingNew<FuncMinimizerFactoryImpl>;
  /// Private Constructor for singleton class
  FuncMinimizerFactoryImpl();
};

/// Forward declaration of a specialisation of SingletonHolder for
/// AlgorithmFactoryImpl (needed for dllexport/dllimport) and a typedef for it.
Peterson, Peter's avatar
Peterson, Peter committed
66
67
#ifdef _WIN32
// this breaks new namespace declaraion rules; need to find a better fix
68
69
template class MANTID_API_DLL
    Mantid::Kernel::SingletonHolder<FuncMinimizerFactoryImpl>;
Peterson, Peter's avatar
Peterson, Peter committed
70
#endif /* _WIN32 */
71
72
73
typedef MANTID_API_DLL Mantid::Kernel::SingletonHolder<FuncMinimizerFactoryImpl>
    FuncMinimizerFactory;

Peterson, Peter's avatar
Peterson, Peter committed
74
75
76
} // namespace API
} // namespace Mantid

77
/**
78
79
 * Macro for declaring a new type of minimizers to be used with the
 * FuncMinimizerFactory
80
 */
81
82
83
84
85
86
87
#define DECLARE_FUNCMINIMIZER(classname, username)                             \
  namespace {                                                                  \
  Mantid::Kernel::RegistrationHelper register_funcminimizer_##classname(       \
      ((Mantid::API::FuncMinimizerFactory::Instance().subscribe<classname>(    \
           #username)),                                                        \
       0));                                                                    \
  }
88

89
#endif /*MANTID_API_FUNCMINIMIZERFACTORY_H_*/