本文整理汇总了C++中api::IAlgorithm_sptr::getProperties方法的典型用法代码示例。如果您正苦于以下问题:C++ IAlgorithm_sptr::getProperties方法的具体用法?C++ IAlgorithm_sptr::getProperties怎么用?C++ IAlgorithm_sptr::getProperties使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类api::IAlgorithm_sptr
的用法示例。
在下文中一共展示了IAlgorithm_sptr::getProperties方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: declareLoaderProperties
/**
* Declare any additional properties of the concrete loader here
* @param loader A pointer to the concrete loader
*/
void Load::declareLoaderProperties(const API::IAlgorithm_sptr &loader) {
// If we have switch loaders then the concrete loader will have different
// properties
// so take care of ensuring Load has the correct ones
// THIS IS A COPY as the properties are mutated as we move through them
const std::vector<Property *> existingProps = this->getProperties();
for (auto existingProp : existingProps) {
const std::string &name = existingProp->name();
// Wipe all properties except the Load native ones
if (m_baseProps.find(name) == m_baseProps.end()) {
this->removeProperty(name);
}
}
const std::vector<Property *> &loaderProps = loader->getProperties();
size_t numProps(loaderProps.size());
for (size_t i = 0; i < numProps; ++i) {
Property *loadProp = loaderProps[i];
if (loadProp->name() == m_filenamePropName)
continue;
try {
auto propClone = std::unique_ptr<Property>(loadProp->clone());
propClone->clearSettings(); // Get rid of special settings because it
// does not work in custom GUI.
declareProperty(std::move(propClone), loadProp->documentation());
} catch (Exception::ExistsError &) {
// Already exists as a static property
continue;
}
}
}
示例2: startingHandle
/** Handler of the start notifications. Adds an algorithm call to the script.
* @param alg :: Shared pointer to the starting algorithm.
*/
void RecordPythonScript::startingHandle(API::IAlgorithm_sptr alg)
{
auto props= alg->getProperties();
std::string algString;
for(auto p = props.begin() ; p != props.end(); ++p)
{
std::string opener = "='";
if ((**p).value().find('\\') != std::string::npos )
{
opener= "=r'";
}
std::string paramString = (**p).name() + opener + (**p).value() + "'";
// Miss out parameters that are empty.
if(paramString.length() != 0)
{
if(algString.length() != 0)
{
algString += ",";
}
algString += paramString;
}
}
m_generatedScript += alg->name() + "(" + algString + ")\n";
}
示例3: createAlgorithmDocs
std::string FrameworkManagerProxy::createAlgorithmDocs(const std::string& algName, const int version)
{
const std::string EOL="\n";
API::IAlgorithm_sptr algm = API::AlgorithmManager::Instance().createUnmanaged(algName, version);
algm->initialize();
// Put in the quick overview message
std::stringstream buffer;
std::string temp = algm->getOptionalMessage();
if (temp.size() > 0)
buffer << temp << EOL << EOL;
// get a sorted copy of the properties
PropertyVector properties(algm->getProperties());
std::sort(properties.begin(), properties.end(), PropertyOrdering());
// generate the sanitized names
StringVector names(properties.size());
size_t numProps = properties.size();
for ( size_t i = 0; i < numProps; ++i)
{
names[i] = removeCharacters(properties[i]->name(), "");
}
buffer << "Property descriptions: " << EOL << EOL;
// write the actual property descriptions
Mantid::Kernel::Property *prop;
for ( size_t i = 0; i < numProps; ++i)
{
prop = properties[i];
buffer << names[i] << "("
<< Mantid::Kernel::Direction::asText(prop->direction());
if (!prop->isValid().empty())
buffer << ":req";
buffer << ") *" << prop->type() << "* ";
std::set<std::string> allowed = prop->allowedValues();
if (!prop->documentation().empty() || !allowed.empty())
{
buffer << " " << prop->documentation();
if (!allowed.empty())
{
buffer << " [" << Kernel::Strings::join(allowed.begin(), allowed.end(), ", ");
buffer << "]";
}
buffer << EOL;
if( i < numProps - 1 ) buffer << EOL;
}
}
return buffer.str();
}
示例4: setOutputWorkspace
/**
* Set the output workspace(s) if the load's return workspace has type
* API::Workspace
* @param loader :: Shared pointer to load algorithm
*/
void Load::setOutputWorkspace(const API::IAlgorithm_sptr &loader) {
// Go through each OutputWorkspace property and check whether we need to make
// a counterpart here
const std::vector<Property *> &loaderProps = loader->getProperties();
const size_t count = loader->propertyCount();
for (size_t i = 0; i < count; ++i) {
Property *prop = loaderProps[i];
if (dynamic_cast<IWorkspaceProperty *>(prop) &&
prop->direction() == Direction::Output) {
const std::string &name = prop->name();
if (!this->existsProperty(name)) {
declareProperty(Kernel::make_unique<WorkspaceProperty<Workspace>>(
name, loader->getPropertyValue(name), Direction::Output));
}
Workspace_sptr wkspace = getOutputWorkspace(name, loader);
setProperty(name, wkspace);
}
}
}
示例5: findFilenameProperty
void Load::findFilenameProperty(const API::IAlgorithm_sptr &loader) {
// Use the first file property as the main Filename
const auto &props = loader->getProperties();
for (auto prop : props) {
auto *fp = dynamic_cast<API::MultipleFileProperty *>(prop);
auto *fp2 = dynamic_cast<API::FileProperty *>(prop);
if (fp) {
m_filenamePropName = fp->name();
break;
}
if (fp2) {
m_filenamePropName = fp2->name();
break;
}
}
if (m_filenamePropName.empty()) {
setPropertyValue("LoaderName", "");
setProperty("LoaderVersion", -1);
throw std::runtime_error("Cannot find FileProperty on " + loader->name() +
" algorithm.");
}
}
示例6: setUpLoader
/**
* Set the loader option for use as a Child Algorithm.
* @param loader :: Concrete loader
* @param startProgress :: The start progress fraction
* @param endProgress :: The end progress fraction
* @param logging:: If true, enable logging
*/
void Load::setUpLoader(API::IAlgorithm_sptr &loader, const double startProgress,
const double endProgress, const bool logging) const {
// Set as a child so that we are in control of output storage
loader->setChild(true);
loader->setLogging(logging);
// If output workspaces are nameless, give them a temporary name to satisfy
// validator
const std::vector<Property *> &props = loader->getProperties();
for (auto prop : props) {
auto wsProp = dynamic_cast<IWorkspaceProperty *>(prop);
if (wsProp && !wsProp->isOptional() &&
prop->direction() == Direction::Output) {
if (prop->value().empty())
prop->setValue("LoadChildWorkspace");
}
}
if (startProgress >= 0. && endProgress > startProgress && endProgress <= 1.) {
loader->addObserver(this->progressObserver());
setChildStartProgress(startProgress);
setChildEndProgress(endProgress);
}
}