Skip to content
Snippets Groups Projects
Commit 1329410b authored by Marco Clemencic's avatar Marco Clemencic
Browse files

Made OptionsSvc lookup case insensitive

for backward compatibility, but issuing a warning in case the wrong
case is used
parent d516f8f2
No related branches found
No related tags found
No related merge requests found
......@@ -110,6 +110,20 @@ StatusCode JobOptionsSvc::setMyProperties( const std::string& client, IProperty*
return fail ? StatusCode::FAILURE : StatusCode::SUCCESS;
}
JobOptionsSvc::StorageType::const_iterator JobOptionsSvc::find( const std::string& key, bool warn ) const
{
StorageType::const_iterator iter = m_options.find( key );
if ( iter == m_options.end() ) { // try case insensitive lookup
iter = std::find_if( m_options.begin(), m_options.end(),
[&key]( auto& item ) { return Gaudi::Utils::iequal( item.first, key ); } );
if ( warn && iter != m_options.end() ) {
warning() << "mismatching case for property name: actual name is " << key << " but " << iter->first
<< " is in the option files" << endmsg;
}
}
return iter;
}
/// Get the list of clients
std::vector<std::string> JobOptionsSvc::getClients() const
{
......
......@@ -27,18 +27,22 @@ public:
typedef std::vector<const Gaudi::Details::PropertyBase*> PropertiesT;
private:
std::map<std::string, std::string> m_options;
using StorageType = std::map<std::string, std::string>;
StorageType m_options;
mutable std::map<std::string, std::unique_ptr<Gaudi::Details::PropertyBase>> m_old_iface_compat;
mutable std::map<std::string, PropertiesT> m_old_iface_compat_2;
StorageType::const_iterator find( const std::string& key, bool warn ) const;
protected:
void set( const std::string& key, const std::string& value ) override { m_options[key] = value; }
std::string get( const std::string& key ) const override
{
auto item = m_options.find( key );
auto item = find( key, true );
return item != m_options.end() ? item->second : std::string{};
}
bool has( const std::string& key ) const override { return m_options.find( key ) != m_options.end(); }
bool has( const std::string& key ) const override { return find( key, false ) != m_options.end(); }
public:
// Constructor
......
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