Skip to content

Commit

Permalink
Re #9018. Adding IPropertyManager::hasProperty to make work easier.
Browse files Browse the repository at this point in the history
  • Loading branch information
peterfpeterson committed Feb 17, 2014
1 parent 872f7f3 commit 5a936d3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
Expand Up @@ -89,6 +89,8 @@ class MANTID_KERNEL_DLL IPropertyManager

/// Get the list of managed properties.
virtual const std::vector< Property*>& getProperties() const = 0;
/// checks if the property exists
bool hasProperty(const std::string &name) const;

/** Templated method to set the value of a PropertyWithValue
* @param name :: The name of the property (case insensitive)
Expand Down
15 changes: 15 additions & 0 deletions Code/Mantid/Framework/Kernel/src/IPropertyManager.cpp
Expand Up @@ -53,6 +53,21 @@ namespace Mantid
return this;
}

/**
* @param name The name of the property being looked for.
* @return True if the property is managed by this.
*/
bool IPropertyManager::hasProperty(const std::string &name) const
{
auto props = this->getProperties();
for (std::vector< Property*>::const_iterator prop = props.begin(); prop != props.end(); ++prop)
{
if (name == (*prop)->name())
return true;
}
return false;
}

// Definitions for TypedValue cast operators
// Have to come after getValue definitions above to keep MSVS2010 happy
IPropertyManager::TypedValue::operator int16_t () { return pm.getValue<int16_t>(prop); }
Expand Down

0 comments on commit 5a936d3

Please sign in to comment.