Exemplo n.º 1
0
    /**Creates an instance of a function
     * @param input :: An input string which defines the function and initial values for the parameters.
     * Parameters of different functions are separated by ';'. Parameters of the same function
     * are separated by ','. parameterName=value pairs are used to set a parameter value. For each function
     * "name" parameter must be set to a function name. E.g.
     * input = "name=LinearBackground,A0=0,A1=1; name = Gaussian, PeakCentre=10.,Sigma=1"
     * @return A pointer to the created function
     */
    IFitFunction* FunctionFactoryImpl::createInitialized(const std::string& input) const
    {
      //std::vector<std::string> ops;
      //ops.push_back(";");
      //ops.push_back(",");
      //ops.push_back("=");
      //ops.push_back("== < > <= >=");

      Expression expr;
      try
      {
        expr.parse(input);
      }
      catch(...)
      {
        inputError(input);
      }

      const Expression& e = expr.bracketsRemoved();

      if (e.name() == ";")
      {
        IFitFunction* fun = createComposite(e);
        if (!fun) inputError();
        return fun;
      }

      return createSimple(e);

    }
Exemplo n.º 2
0
/**Creates an instance of a function
 * @param input :: An input string which defines the function and initial values
 * for the parameters.
 * Parameters of different functions are separated by ';'. Parameters of the
 * same function
 * are separated by ','. parameterName=value pairs are used to set a parameter
 * value. For each function
 * "name" parameter must be set to a function name. E.g.
 * input = "name=LinearBackground,A0=0,A1=1; name = Gaussian,
 * PeakCentre=10.,Sigma=1"
 * @return A pointer to the created function
 */
IFunction_sptr
FunctionFactoryImpl::createInitialized(const std::string &input) const {
  Expression expr;
  try {
    expr.parse(input);
  } catch (...) {
    inputError(input);
  }

  const Expression &e = expr.bracketsRemoved();
  std::map<std::string, std::string> parentAttributes;
  if (e.name() == ";") {
    IFunction_sptr fun = createComposite(e, parentAttributes);
    if (!fun)
      inputError();
    return fun;
  }

  return createSimple(e, parentAttributes);
}