本文整理汇总了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);
}
}