diff --git a/Code/Mantid/Framework/API/inc/MantidAPI/DataProcessorAlgorithm.h b/Code/Mantid/Framework/API/inc/MantidAPI/DataProcessorAlgorithm.h index 104b2c5777383d1bed2e56fadd7547e26e2d766d..2cc4b78212ec9c2cdc8f8974d17eeaf7bda6f787 100644 --- a/Code/Mantid/Framework/API/inc/MantidAPI/DataProcessorAlgorithm.h +++ b/Code/Mantid/Framework/API/inc/MantidAPI/DataProcessorAlgorithm.h @@ -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 diff --git a/Code/Mantid/Framework/API/src/DataProcessorAlgorithm.cpp b/Code/Mantid/Framework/API/src/DataProcessorAlgorithm.cpp index 01fa7c5742b944082a03be9d396d81b26a48965a..68f2dd1a47e25b0c91343ee2a09d83233609b08b 100644 --- a/Code/Mantid/Framework/API/src/DataProcessorAlgorithm.cpp +++ b/Code/Mantid/Framework/API/src/DataProcessorAlgorithm.cpp @@ -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);