当前位置: 首页>>代码示例>>C++>>正文


C++ IAlgorithm_sptr::setPropertiesWithString方法代码示例

本文整理汇总了C++中IAlgorithm_sptr::setPropertiesWithString方法的典型用法代码示例。如果您正苦于以下问题:C++ IAlgorithm_sptr::setPropertiesWithString方法的具体用法?C++ IAlgorithm_sptr::setPropertiesWithString怎么用?C++ IAlgorithm_sptr::setPropertiesWithString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IAlgorithm_sptr的用法示例。


在下文中一共展示了IAlgorithm_sptr::setPropertiesWithString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: makeAlgorithm

/** Using the [Post]ProcessingAlgorithm and [Post]ProcessingProperties
 *properties,
 * create and initialize an algorithm for processing.
 *
 * @param postProcessing :: true to create the PostProcessingAlgorithm.
 *        false to create the ProcessingAlgorithm
 * @return shared pointer to the algorithm, ready for execution.
 *         Returns a NULL pointer if no algorithm was chosen.
 */
IAlgorithm_sptr LiveDataAlgorithm::makeAlgorithm(bool postProcessing) {
  std::string prefix;
  if (postProcessing)
    prefix = "Post";

  // Get the name of the algorithm to run
  std::string algoName = this->getPropertyValue(prefix + "ProcessingAlgorithm");
  algoName = Strings::strip(algoName);

  // Get the script to run. Ignored if algo is specified
  std::string script = this->getPropertyValue(prefix + "ProcessingScript");
  script = Strings::strip(script);

  std::string scriptfile =
      this->getPropertyValue(prefix + "ProcessingScriptFilename");

  if (!algoName.empty()) {
    g_log.information() << "Creating algorithm from name \'" << algoName
                        << "\'\n";

    // Properties to pass to algo
    std::string props = this->getPropertyValue(prefix + "ProcessingProperties");

    // Create the UNMANAGED algorithm
    IAlgorithm_sptr alg = this->createChildAlgorithm(algoName);

    // Skip some of the properties when setting
    std::unordered_set<std::string> ignoreProps;
    ignoreProps.insert("InputWorkspace");
    ignoreProps.insert("OutputWorkspace");

    // ...and pass it the properties
    alg->setPropertiesWithString(props, ignoreProps);

    // Warn if someone put both values.
    if (!script.empty())
      g_log.warning() << "Running algorithm " << algoName
                      << " and ignoring the script code in "
                      << prefix + "ProcessingScript\n";
    return alg;
  } else if (!script.empty() || !scriptfile.empty()) {
    // Run a snippet of python
    IAlgorithm_sptr alg = this->createChildAlgorithm("RunPythonScript");
    alg->setLogging(false);
    if (scriptfile.empty()) {
      g_log.information("Creating python algorithm from string");
      alg->setPropertyValue("Code", script);
    } else {
      g_log.information() << "Creating python algorithm from file \'"
                          << scriptfile << "\'\n";
      alg->setPropertyValue("Filename", scriptfile);
    }
    g_log.information("    stack traces will be off by 5"
                      " lines because of boiler-plate");
    return alg;
  } else {
    return IAlgorithm_sptr();
  }
}
开发者ID:mantidproject,项目名称:mantid,代码行数:68,代码来源:LiveDataAlgorithm.cpp


注:本文中的IAlgorithm_sptr::setPropertiesWithString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。