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


C++ Attr::asInt方法代码示例

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


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

示例1: setAttribute

/**
 * @brief Update attributes WorkspaceIndex and Q according to certain precedence
 *rules.
 * Subclasses featuring additional attributes should override and insert a call
 *to
 * this method within the overriding setAttribute function.
 * There are two ways to update Q: (i) loading the value from the spectrum, and
 *(ii) manual
 * input from the user. Therefore, rules of precedence must be set to prevent
 *conflict. The
 * priority is to accept Q from the spectrum, if a Q value can be derived from
 *such. In
 * this case the existing Q value will be overwritten, irrespective of the
 *mannier in which
 * the old Q value was set.
 *
 * @param attName name of the attribute
 * @param attValue  value of the attribute
 */
void FunctionQDepends::setAttribute(const std::string &attName,
                                    const Attr &attValue) {
  // Q value is tied to WorkspaceIndex if we have a list of Q values
  if (attName == "WorkspaceIndex") {
    size_t wi{static_cast<size_t>(
        attValue.asInt())}; // ah!, the "joys" of C++ strong typing.
    if (!m_vQ.empty() && wi < m_vQ.size()) {
      Mantid::API::IFunction::setAttribute(attName, attValue);
      Mantid::API::IFunction::setAttribute("Q", Attribute(m_vQ.at(wi)));
    }
  }
  // Q can be manually changed by user only if list of Q values is empty
  else if (attName == "Q") {
    if (m_vQ.empty()) {
      Mantid::API::IFunction::setAttribute(attName, attValue);
    }
  } else {
    Mantid::API::IFunction::setAttribute(attName, attValue);
  }
}
开发者ID:DanNixon,项目名称:mantid,代码行数:39,代码来源:FunctionQDepends.cpp


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