diff --git a/Code/Mantid/Framework/Kernel/inc/MantidKernel/ConfigService.h b/Code/Mantid/Framework/Kernel/inc/MantidKernel/ConfigService.h index a3dc2b22ed283bd6a03a7bebf976b432934fcce6..b3ddf7d0a782301e8a3bb38bfdf54f8fcce06c3d 100644 --- a/Code/Mantid/Framework/Kernel/inc/MantidKernel/ConfigService.h +++ b/Code/Mantid/Framework/Kernel/inc/MantidKernel/ConfigService.h @@ -277,6 +277,8 @@ namespace Mantid /// The list of available facilities std::vector<FacilityInfo*> m_facilities; + /// Define a flag value for a removed property + const std::string m_removedFlag; }; /// Forward declaration of a specialisation of SingletonHolder for AlgorithmFactoryImpl (needed for dllexport/dllimport) and a typedef for it. diff --git a/Code/Mantid/Framework/Kernel/src/ConfigService.cpp b/Code/Mantid/Framework/Kernel/src/ConfigService.cpp index 281c1e66a1541b2945162cbed3245420c294f53b..cf98b77b7ce841d0467a18bd2ed1658c52d8be2a 100644 --- a/Code/Mantid/Framework/Kernel/src/ConfigService.cpp +++ b/Code/Mantid/Framework/Kernel/src/ConfigService.cpp @@ -129,7 +129,7 @@ ConfigServiceImpl::ConfigServiceImpl() : m_ConfigPaths(), m_AbsolutePaths(), m_strBaseDir(""), m_PropertyString(""), m_properties_file_name("Mantid.properties"), m_user_properties_file_name("Mantid.user.properties"), m_DataSearchDirs(), m_UserSearchDirs(), - m_instr_prefixes() + m_instr_prefixes(), m_removedFlag("@@REMOVED@@") { //getting at system details m_pSysConfig = new WrappedObject<Poco::Util::SystemConfiguration> ; @@ -855,6 +855,7 @@ std::string ConfigServiceImpl::getString(const std::string& keyName, bool use_ca try { retVal = m_pConf->getString(keyName); + if( retVal == m_removedFlag ) retVal = ""; } catch (Poco::NotFoundException&) { g_log.debug() << "Unable to find " << keyName << " in the properties file" << std::endl; @@ -872,10 +873,27 @@ std::string ConfigServiceImpl::getString(const std::string& keyName, bool use_ca */ std::vector<std::string> ConfigServiceImpl::getKeys(const std::string& keyName) const { + std::vector<std::string> rawKeys; std::vector<std::string> keyVector; + keyVector.reserve(rawKeys.size()); try { - m_pConf->keys(keyName,keyVector); + m_pConf->keys(keyName,rawKeys); + // Work around a limitation of Poco < v1.4 which has no remove functionality so + // check those that have been marked with the correct flag + const size_t nraw = rawKeys.size(); + for( size_t i = 0; i < nraw; ++i ) + { + const std::string key = rawKeys[i]; + try + { + if( m_pConf->getString(key) == m_removedFlag ) continue; + } + catch (Poco::NotFoundException&) + { + } + keyVector.push_back(key); + } } catch (Poco::NotFoundException&) { @@ -895,7 +913,9 @@ void ConfigServiceImpl::remove(const std::string& rootName) const { try { - m_pConf->remove(rootName); + // m_pConf->remove(rootName) will only work in Poco v >=1.4. Current Ubuntu and RHEL use 1.3.x + // Simulate removal by marking with a flag value + m_pConf->setString(rootName, m_removedFlag); } catch (Poco::NotFoundException&) { @@ -911,7 +931,8 @@ void ConfigServiceImpl::remove(const std::string& rootName) const */ bool ConfigServiceImpl::hasProperty(const std::string& rootName) const { - return m_pConf->hasProperty(rootName); + // Work around a limitation of Poco < v1.4 which has no remove functionality + return m_pConf->hasProperty(rootName) && m_pConf->getString(rootName) != m_removedFlag; } /** Checks to see whether the given file target is an executable one and it exists