本文整理汇总了C++中IAlgorithm_sptr::name方法的典型用法代码示例。如果您正苦于以下问题:C++ IAlgorithm_sptr::name方法的具体用法?C++ IAlgorithm_sptr::name怎么用?C++ IAlgorithm_sptr::name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IAlgorithm_sptr
的用法示例。
在下文中一共展示了IAlgorithm_sptr::name方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
/**
* Queries each registered algorithm and asks it how confident it is that it can
* load the given file. The name of the one with the highest confidence is
* returned.
* @param filename A full file path pointing to an existing file
* @return A string containing the name of an algorithm to load the file
* @throws Exception::NotFoundError if an algorithm cannot be found
*/
const boost::shared_ptr<IAlgorithm>
FileLoaderRegistryImpl::chooseLoader(const std::string &filename) const {
using Kernel::FileDescriptor;
using Kernel::NexusDescriptor;
m_log.debug() << "Trying to find loader for '" << filename << "'"
<< std::endl;
IAlgorithm_sptr bestLoader;
if (NexusDescriptor::isHDF(filename)) {
m_log.debug()
<< filename
<< " looks like a Nexus file. Checking registered Nexus loaders\n";
bestLoader = searchForLoader<NexusDescriptor, IFileLoader<NexusDescriptor>>(
filename, m_names[Nexus], m_log);
} else {
m_log.debug() << "Checking registered non-HDF loaders\n";
bestLoader = searchForLoader<FileDescriptor, IFileLoader<FileDescriptor>>(
filename, m_names[Generic], m_log);
}
if (!bestLoader) {
throw Kernel::Exception::NotFoundError(filename, "Unable to find loader");
}
m_log.debug() << "Found loader " << bestLoader->name() << " for file '"
<< filename << "'" << std::endl;
return bestLoader;
}
示例2: getPropertyValue
/** Validate the properties together */
std::map<std::string, std::string> LiveDataAlgorithm::validateInputs()
{
std::map<std::string, std::string> out;
const std::string instrument = getPropertyValue("Instrument");
const bool eventListener = LiveListenerFactory::Instance().create(instrument,false)->buffersEvents();
if ( !eventListener && getPropertyValue("AccumulationMethod") == "Add" )
{
out["AccumulationMethod"] = "The " + instrument + " live stream produces histograms. Add is not a sensible accumulation method.";
}
if (this->getPropertyValue("OutputWorkspace").empty())
out["OutputWorkspace"] = "Must specify the OutputWorkspace.";
// Validate inputs
if (this->hasPostProcessing())
{
if (this->getPropertyValue("AccumulationWorkspace").empty())
out["AccumulationWorkspace"] = "Must specify the AccumulationWorkspace parameter if using PostProcessing.";
if (this->getPropertyValue("AccumulationWorkspace") == this->getPropertyValue("OutputWorkspace"))
out["AccumulationWorkspace"] = "The AccumulationWorkspace must be different than the OutputWorkspace, when using PostProcessing.";
}
// For StartLiveData and MonitorLiveData, make sure another thread is not already using these names
if (this->name() != "LoadLiveData")
{
/** Validate that the workspace names chosen are not in use already */
std::string outName = this->getPropertyValue("OutputWorkspace");
std::string accumName = this->getPropertyValue("AccumulationWorkspace");
// Check that no other MonitorLiveData thread is running with the same settings
auto it = AlgorithmManager::Instance().algorithms().begin();
for (; it != AlgorithmManager::Instance().algorithms().end(); it++)
{
IAlgorithm_sptr alg = *it;
// MonitorLiveData thread that is running, except THIS one.
if (alg->name() == "MonitorLiveData" && (alg->getAlgorithmID() != this->getAlgorithmID())
&& alg->isRunning())
{
if (!accumName.empty() && alg->getPropertyValue("AccumulationWorkspace") == accumName)
out["AccumulationWorkspace"] += "Another MonitorLiveData thread is running with the same AccumulationWorkspace.\n"
"Please specify a different AccumulationWorkspace name.";
if (alg->getPropertyValue("OutputWorkspace") == outName)
out["OutputWorkspace"] += "Another MonitorLiveData thread is running with the same OutputWorkspace.\n"
"Please specify a different OutputWorkspace name.";
}
}
}
return out;
}
示例3: addMatrixWSChunk
/**
* Add a matrix workspace to the accumulation workspace.
*
* @param algoName :: Name of algorithm which will be adding the workspaces.
* @param accumWS :: accumulation matrix workspace
* @param chunkWS :: processed live data chunk matrix workspace
*/
void LoadLiveData::addMatrixWSChunk(const std::string &algoName,
Workspace_sptr accumWS,
Workspace_sptr chunkWS) {
// Handle the addition of the internal monitor workspace, if present
auto accumMW = boost::dynamic_pointer_cast<MatrixWorkspace>(accumWS);
auto chunkMW = boost::dynamic_pointer_cast<MatrixWorkspace>(chunkWS);
if (accumMW && chunkMW) {
auto accumMon = accumMW->monitorWorkspace();
auto chunkMon = chunkMW->monitorWorkspace();
if (accumMon && chunkMon)
accumMon += chunkMon;
}
// Now do the main workspace
IAlgorithm_sptr alg = this->createChildAlgorithm(algoName);
alg->setProperty("LHSWorkspace", accumWS);
alg->setProperty("RHSWorkspace", chunkWS);
alg->setProperty("OutputWorkspace", accumWS);
alg->execute();
if (!alg->isExecuted()) {
throw std::runtime_error("Error when calling " + alg->name() +
" to add the chunk of live data. See log.");
} else {
// Get the output as the generic Workspace type
// This step is necessary for when we are operating on MD workspaces
// (PlusMD)
Property *prop = alg->getProperty("OutputWorkspace");
IWorkspaceProperty *wsProp = dynamic_cast<IWorkspaceProperty *>(prop);
if (!wsProp)
throw std::runtime_error(
"The " + alg->name() +
" Algorithm's OutputWorkspace property is not a WorkspaceProperty!");
Workspace_sptr temp = wsProp->getWorkspace();
accumWS = temp;
// And sort the events, if any
doSortEvents(accumWS);
}
}
示例4: update
void MonitorDlg::update() {
if (!m_tree) {
m_tree = new QTreeWidget(this);
m_tree->setColumnCount(3);
m_tree->setSelectionMode(QAbstractItemView::NoSelection);
// Make the algorithm name column wider
m_tree->setColumnWidth(0, 220);
QStringList hList;
hList << "Algorithm"
<< "Progress"
<< "";
m_tree->setHeaderLabels(hList);
QHeaderView *hHeader = (QHeaderView *)m_tree->header();
hHeader->setResizeMode(1, QHeaderView::Stretch);
hHeader->setResizeMode(2, QHeaderView::Fixed);
hHeader->setStretchLastSection(false);
} else
m_tree->clear();
if (!isVisible())
return;
m_algMonitor->lock();
QVector<Mantid::API::AlgorithmID>::const_iterator iend =
m_algMonitor->algorithms().end();
for (QVector<Mantid::API::AlgorithmID>::const_iterator itr =
m_algMonitor->algorithms().begin();
itr != iend; ++itr) {
IAlgorithm_sptr alg =
Mantid::API::AlgorithmManager::Instance().getAlgorithm(*itr);
// m_algorithms << alg;
QStringList iList;
iList << QString::fromStdString(alg->name());
QTreeWidgetItem *algItem = new QTreeWidgetItem(iList);
m_tree->addTopLevelItem(algItem);
QProgressBar *algProgress = new QProgressBar;
algProgress->setAlignment(Qt::AlignHCenter);
AlgButton *cancelButton = new AlgButton("Cancel", alg);
m_tree->setItemWidget(algItem, 1, algProgress);
m_tree->setItemWidget(algItem, 2, cancelButton);
const std::vector<Mantid::Kernel::Property *> &prop_list =
alg->getProperties();
for (std::vector<Mantid::Kernel::Property *>::const_iterator prop =
prop_list.begin();
prop != prop_list.end(); ++prop) {
QStringList lstr;
Mantid::Kernel::MaskedProperty<std::string> *maskedProp =
dynamic_cast<Mantid::Kernel::MaskedProperty<std::string> *>(*prop);
if (maskedProp) {
lstr << QString::fromStdString(maskedProp->name()) + ": "
<< QString::fromStdString(maskedProp->getMaskedValue());
} else {
lstr << QString::fromStdString((**prop).name()) + ": "
<< QString::fromStdString((**prop).value());
}
if ((**prop).isDefault())
lstr << " Default";
algItem->addChild(new QTreeWidgetItem(lstr));
}
connect(
cancelButton, SIGNAL(clicked(Mantid::API::AlgorithmID, QPushButton *)),
m_algMonitor, SLOT(cancel(Mantid::API::AlgorithmID, QPushButton *)));
}
m_algMonitor->unlock();
}