ImmutableCompositeFunction.h 3.64 KB
Newer Older
1
2
3
4
5
6
7
8
#ifndef MANTID_API_IMMUTABLECOMPOSITEFUNCTION_H_
#define MANTID_API_IMMUTABLECOMPOSITEFUNCTION_H_

//----------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------
#include "MantidAPI/CompositeFunction.h"

9
10
#include <map>

11
12
13
14
15
16
17
18
19
20
21
22
namespace Mantid {
namespace API {
/**
    Immutable composite function is a composite function which members cannot be
   added or removed
    after creation. Only a derived class can add functions in its contructor (or
   methods).
    The function factory treat an ImmutableCompositeFunction as a simple
   function.

    Copyright &copy; 2009 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge
   National Laboratory & European Spallation Source
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38

    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/>.

39
    File change history is stored at: <https://github.com/mantidproject/mantid>.
40
41
    Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
42
class MANTID_API_DLL ImmutableCompositeFunction : public CompositeFunction {
43
public:
44
  /* Overriden methods */
45
46

  /// Returns the function's name
47
  std::string name() const override { return "ImmutableCompositeFunction"; }
48
  /// Writes itself into a string
Roman Tolchenov's avatar
Roman Tolchenov committed
49
50
  std::string
  asString(const std::string &parentLocalAttributesStr = "") const override;
51
  /// Set i-th parameter
52
53
  void setParameter(size_t i, const double &value,
                    bool explicitlySet = true) override {
54
55
    CompositeFunction::setParameter(i, value, explicitlySet);
  }
56
  /// Set i-th parameter description
57
58
  void setParameterDescription(size_t i,
                               const std::string &description) override {
59
60
    CompositeFunction::setParameterDescription(i, description);
  }
61
  /// Set parameter by name.
62
  void setParameter(const std::string &name, const double &value,
63
                    bool explicitlySet = true) override;
64
  /// Set description of parameter by name.
65
  void setParameterDescription(const std::string &name,
66
                               const std::string &description) override;
67
  /// Get i-th parameter
68
  double getParameter(size_t i) const override {
69
70
    return CompositeFunction::getParameter(i);
  }
71
  /// Get parameter by name.
72
  double getParameter(const std::string &name) const override;
73
  /// Returns the index of parameter name
74
  size_t parameterIndex(const std::string &name) const override;
75
  /// Returns the name of parameter i
76
  std::string parameterName(size_t i) const override;
77
78

protected:
79
  /// Make it protected
80
  using CompositeFunction::addFunction;
81
  /// Overload addFunction to take a bare pointer
82
  void addFunction(IFunction *fun);
83
  /// Define an alias for a parameter
84
  void setAlias(const std::string &parName, const std::string &alias);
85
  /// Add default ties
86
  void addDefaultTies(const std::string &ties);
87
  /// Add default constraints
88
  void addDefaultConstraints(const std::string &constraints);
89
90
91

private:
  /// Keep paramater aliases
92
  std::map<std::string, size_t> m_aliases;
93
94
95
96
97
98
};

} // namespace API
} // namespace Mantid

#endif /*MANTID_API_IMMUTABLECOMPOSITEFUNCTION_H_*/