Skip to content
Snippets Groups Projects
Commit 39c0446a authored by Peterson, Peter's avatar Peterson, Peter
Browse files

Adding methods to get properties while consulting PropertyManager property

parent d1cde78b
No related merge requests found
......@@ -43,6 +43,8 @@ class DLLExport DataProcessorAlgorithm : public Algorithm {
public:
DataProcessorAlgorithm();
virtual ~DataProcessorAlgorithm();
virtual std::string getPropertyValue(const std::string &name) const;
virtual TypedValue getProperty(const std::string &name) const;
protected:
virtual boost::shared_ptr<Algorithm> createChildAlgorithm(
......@@ -53,6 +55,7 @@ protected:
void setLoadAlgFileProp(const std::string &filePropName);
void setAccumAlg(const std::string &alg);
void setPropManagerPropName(const std::string &propName);
void mapPropertyName(const std::string &nameInProp, const std::string &nameInPropManager);
ITableWorkspace_sptr determineChunk();
void loadChunk();
Workspace_sptr load(const std::string &inputData,
......@@ -60,7 +63,7 @@ protected:
std::vector<std::string> splitInput(const std::string &input);
void forwardProperties();
boost::shared_ptr<Kernel::PropertyManager>
getProcessProperties(const std::string &propertyManager=std::string());
getProcessProperties(const std::string &propertyManager=std::string()) const;
/// MPI option. If false, we will use one job event if MPI is available
bool m_useMPI;
Workspace_sptr assemble(const std::string &partialWSName,
......@@ -130,6 +133,8 @@ private:
/// The name of the parameter that names the property manager. The default
/// value is "ReductionProperties".
std::string m_propertyManagerPropertyName;
/// Map property names to names in supplied properties manager
std::map<std::string, std::string> m_nameToPMName;
};
} // namespace API
......
......@@ -96,6 +96,49 @@ void DataProcessorAlgorithm::setPropManagerPropName(const std::string &propName)
m_propertyManagerPropertyName = propName;
}
void DataProcessorAlgorithm::mapPropertyName(const std::string &nameInProp,
const std::string &nameInPropManager) {
m_nameToPMName[nameInProp] = nameInPropManager;
}
std::string DataProcessorAlgorithm::getPropertyValue(const std::string &name) const {
// explicitely specifying a property wins
if (!isDefault(name)) {
return Algorithm::getPropertyValue(name);
}
// return it if it is in the held property manager
auto mapping = m_nameToPMName.find(name);
if (mapping != m_nameToPMName.end()) {
auto pm = this->getProcessProperties();
if (pm->existsProperty(mapping->second)) {
return pm->getPropertyValue(mapping->second);
}
}
// let the parent class version win
return Algorithm::getPropertyValue(name);
}
PropertyManagerOwner::TypedValue DataProcessorAlgorithm::getProperty(const std::string &name) const {
// explicitely specifying a property wins
if (!isDefault(name)) {
return Algorithm::getProperty(name);
}
// return it if it is in the held property manager
auto mapping = m_nameToPMName.find(name);
if (mapping != m_nameToPMName.end()) {
auto pm = this->getProcessProperties();
if (pm->existsProperty(mapping->second)) {
return pm->getProperty(mapping->second);
}
}
// let the parent class version win
return Algorithm::getProperty(name);
}
ITableWorkspace_sptr DataProcessorAlgorithm::determineChunk() {
throw std::runtime_error(
"DataProcessorAlgorithm::determineChunk is not implemented");
......@@ -248,7 +291,7 @@ Workspace_sptr DataProcessorAlgorithm::load(const std::string &inputData,
* @param propertyManager :: Name of the property manager to retrieve.
*/
boost::shared_ptr<PropertyManager> DataProcessorAlgorithm::getProcessProperties(
const std::string &propertyManager) {
const std::string &propertyManager) const {
std::string propertyManagerName(propertyManager);
if (propertyManager.empty() && (!m_propertyManagerPropertyName.empty())) {
propertyManagerName = this->getPropertyValue(m_propertyManagerPropertyName);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment