本文整理汇总了C++中api::IAlgorithm_sptr::existsProperty方法的典型用法代码示例。如果您正苦于以下问题:C++ IAlgorithm_sptr::existsProperty方法的具体用法?C++ IAlgorithm_sptr::existsProperty怎么用?C++ IAlgorithm_sptr::existsProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类api::IAlgorithm_sptr
的用法示例。
在下文中一共展示了IAlgorithm_sptr::existsProperty方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getWorkspace
/** Get a workspace identified by an InputData structure.
* @param data :: InputData with name and either spec or i fields defined.
* @return InputData structure with the ws field set if everything was OK.
*/
PlotPeakByLogValue::InputData PlotPeakByLogValue::getWorkspace(const InputData& data)
{
InputData out(data);
if (API::AnalysisDataService::Instance().doesExist(data.name))
{
DataObjects::Workspace2D_sptr ws = boost::dynamic_pointer_cast<DataObjects::Workspace2D>(
API::AnalysisDataService::Instance().retrieve(data.name));
if (ws)
{
out.ws = ws;
}
else
{
return data;
}
}
else
{
std::ifstream fil(data.name.c_str());
if (!fil)
{
g_log.warning() << "File "<<data.name<<" does not exist\n";
return data;
}
fil.close();
std::string::size_type i = data.name.find_last_of('.');
if (i == std::string::npos)
{
g_log.warning() << "Cannot open file "<<data.name<<"\n";
return data;
}
std::string ext = data.name.substr(i);
try
{
API::IAlgorithm_sptr load = createSubAlgorithm("Load");
load->initialize();
load->setPropertyValue("FileName",data.name);
load->execute();
if (load->isExecuted())
{
API::Workspace_sptr rws = load->getProperty("OutputWorkspace");
if (rws)
{
DataObjects::Workspace2D_sptr ws = boost::dynamic_pointer_cast<DataObjects::Workspace2D>(rws);
if (ws)
{
out.ws = ws;
}
else
{
API::WorkspaceGroup_sptr gws = boost::dynamic_pointer_cast<API::WorkspaceGroup>(rws);
if (gws)
{
std::vector<std::string> wsNames = gws->getNames();
std::string propName = "OUTPUTWORKSPACE_" + boost::lexical_cast<std::string>(data.period);
if (load->existsProperty(propName))
{
Workspace_sptr rws1 = load->getProperty(propName);
out.ws = boost::dynamic_pointer_cast<DataObjects::Workspace2D>(rws1);
}
}
}
}
}
}
catch(std::exception& e)
{
g_log.error(e.what());
return data;
}
}
if (!out.ws) return data;
API::Axis* axis = out.ws->getAxis(1);
if (axis->isSpectra())
{// spectra axis
if (out.spec < 0)
{
if (out.i >= 0)
{
out.spec = axis->spectraNo(out.i);
}
else
{// i < 0 && spec < 0 => use start and end
for(size_t i=0;i<axis->length();++i)
{
double s = double(axis->spectraNo(i));
if (s >= out.start && s <= out.end)
{
out.indx.push_back(static_cast<int>(i));
}
}
}
}
else
//.........这里部分代码省略.........