ImmutableCompositeFunction.h 3.59 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
44
public:
  /// Default constructor
45
  ImmutableCompositeFunction() : CompositeFunction() {}
46
  // Destructor
47
  ~ImmutableCompositeFunction() {}
48

49
  /* Overriden methods */
50
51

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

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

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

} // namespace API
} // namespace Mantid

#endif /*MANTID_API_IMMUTABLECOMPOSITEFUNCTION_H_*/