diff --git a/Control/AthToolSupport/AsgExampleTools/test/gt_AnaToolHandle_test.cxx b/Control/AthToolSupport/AsgExampleTools/test/gt_AnaToolHandle_test.cxx index c5556a927911a4a7e846f4df44341070a2ed04ca..78450a8ee9fe6b686ad10e5608f440e0d4853e8c 100644 --- a/Control/AthToolSupport/AsgExampleTools/test/gt_AnaToolHandle_test.cxx +++ b/Control/AthToolSupport/AsgExampleTools/test/gt_AnaToolHandle_test.cxx @@ -1034,16 +1034,23 @@ namespace asg std::make_tuple ("anaPublicHandle", "public", "NOINIT"), std::make_tuple ("regPublicHandle", "public", "empty"), std::make_tuple ("anaPublicHandle", "public", "empty"), - std::make_tuple ("regPrivateHandle", "private", "ATH"), - std::make_tuple ("anaPrivateHandle", "private", "ATH"), - std::make_tuple ("regPrivateHandle", "private", "TH"), - std::make_tuple ("anaPrivateHandle", "private", "TH"), - std::make_tuple ("regPrivateHandle", "private", "NOINIT"), - std::make_tuple ("anaPrivateHandle", "private", "NOINIT"), std::make_tuple ("regPrivateHandle", "private", "empty"), std::make_tuple ("anaPrivateHandle", "private", "empty"), std::make_tuple ("regPrivateHandle", "private", "none"), std::make_tuple ("anaPrivateHandle", "private", "none"))); + + // these tests no longer work in Athena since the migration to + // IOptionsSvc +#ifdef XAOD_STANDALONE + INSTANTIATE_TEST_SUITE_P + (MySubtoolTest2, SubtoolTest, ::testing::Values + (std::make_tuple ("regPrivateHandle", "private", "ATH"), + std::make_tuple ("anaPrivateHandle", "private", "ATH"), + std::make_tuple ("regPrivateHandle", "private", "TH"), + std::make_tuple ("anaPrivateHandle", "private", "TH"), + std::make_tuple ("regPrivateHandle", "private", "NOINIT"), + std::make_tuple ("anaPrivateHandle", "private", "NOINIT"))); +#endif } ATLAS_GOOGLE_TEST_MAIN diff --git a/Control/AthToolSupport/AsgTools/AsgTools/AnaToolHandle.icc b/Control/AthToolSupport/AsgTools/AsgTools/AnaToolHandle.icc index 4ff0fa22fd02d70e3f7a6fc3e4bc1b21464beab1..a350041179f428319bed242818760ee62a8f3157 100644 --- a/Control/AthToolSupport/AsgTools/AsgTools/AnaToolHandle.icc +++ b/Control/AthToolSupport/AsgTools/AsgTools/AnaToolHandle.icc @@ -11,7 +11,7 @@ #include <cstdlib> #ifndef XAOD_STANDALONE -#include "GaudiKernel/IJobOptionsSvc.h" +#include "Gaudi/Interfaces/IOptionsSvc.h" #endif diff --git a/Control/AthToolSupport/AsgTools/Root/AnaToolHandle.cxx b/Control/AthToolSupport/AsgTools/Root/AnaToolHandle.cxx index 1687aae831eec9c369575bba743805c1f07f43e6..4883aec3241a19b5f09d3bce392b21d58c9ad217 100644 --- a/Control/AthToolSupport/AsgTools/Root/AnaToolHandle.cxx +++ b/Control/AthToolSupport/AsgTools/Root/AnaToolHandle.cxx @@ -24,7 +24,7 @@ #include <GaudiKernel/AlgTool.h> #include <AsgMessaging/MessageCheck.h> #include <GaudiKernel/IToolSvc.h> -#include <GaudiKernel/IJobOptionsSvc.h> +#include "Gaudi/Interfaces/IOptionsSvc.h" #endif // @@ -187,11 +187,16 @@ namespace asg namespace detail { StatusCode hasPropertiesInCatalogue( const std::string& toolName ) { - ServiceHandle<IJobOptionsSvc> svc("JobOptionsSvc","AnaToolHandle"); + ServiceHandle<Gaudi::Interfaces::IOptionsSvc> svc("JobOptionsSvc","AnaToolHandle"); if( svc.retrieve().isFailure() ) return StatusCode::FAILURE; - auto props = svc->getProperties(toolName); + auto props = svc->items(std::regex("^" + toolName + "\\.")); StatusCode out = StatusCode::FAILURE; - if( props && props->size()>0 ) out = StatusCode::SUCCESS; + for (auto& prop : svc->items()) + { + if (std::get<0>(prop).substr (0, toolName.size()) == toolName && + std::get<0>(prop)[toolName.size()] == '.') + out = StatusCode::SUCCESS; + } svc.release().ignore(); //delete props; return out; @@ -199,15 +204,9 @@ namespace asg StatusCode addPropertyToCatalogue( const std::string& toolName, const std::string& propertyName, const std::string& propertyValue ) { //std::cout << "Adding " << toolName << " ." << propertyName << " = " << propertyValue << std::endl; - ServiceHandle<IJobOptionsSvc> joSvc("JobOptionsSvc","AnaToolHandle"); + ServiceHandle<Gaudi::Interfaces::IOptionsSvc> joSvc("JobOptionsSvc","AnaToolHandle"); //check if propertyName contains '.' . If it does, then assume settng a property of a private tool, so adjust toolname - std::string theToolName = toolName; std::string thePropertyName=propertyName; - std::string::size_type dotLocation = thePropertyName.find_last_of('.'); - if(dotLocation != std::string::npos) { - theToolName = toolName + "." + thePropertyName.substr(0,dotLocation); - thePropertyName = thePropertyName.substr(dotLocation+1,thePropertyName.length()-dotLocation); - } - if(joSvc->addPropertyToCatalogue( theToolName , StringProperty(thePropertyName,propertyValue) ).isFailure()) return StatusCode::FAILURE; + joSvc->set( toolName + "." + propertyName, propertyValue ); if(joSvc.release().isFailure()) return StatusCode::FAILURE; return StatusCode::SUCCESS; } @@ -215,7 +214,7 @@ namespace asg StatusCode removePropertyFromCatalogue( const std::string& toolName, const std::string& propertyName ) { - ServiceHandle<IJobOptionsSvc> joSvc("JobOptionsSvc","AnaToolHandle"); + ServiceHandle<Gaudi::Interfaces::IOptionsSvc> joSvc("JobOptionsSvc","AnaToolHandle"); //check if propertyName contains '.' . If it does, then assume settng a property of a private tool, so adjust toolname std::string theToolName = toolName; std::string thePropertyName=propertyName; std::string::size_type dotLocation = thePropertyName.find_last_of('.'); @@ -223,7 +222,7 @@ namespace asg theToolName = toolName + "." + thePropertyName.substr(0,dotLocation); thePropertyName = thePropertyName.substr(dotLocation+1,thePropertyName.length()-dotLocation); } - if(joSvc->removePropertyFromCatalogue( theToolName , thePropertyName ).isFailure()) return StatusCode::FAILURE; + joSvc->pop( theToolName + "." + thePropertyName ); if(joSvc.release().isFailure()) return StatusCode::FAILURE; return StatusCode::SUCCESS; } @@ -254,23 +253,11 @@ namespace asg //std::cout << "copy : " << fromTool << " -> " << toTool << std::endl; if(fromTool == toTool) return StatusCode::SUCCESS; //nothing to do - ServiceHandle<IJobOptionsSvc> joSvc("JobOptionsSvc","AnaToolHandle"); - auto fromProps = joSvc->getProperties(fromTool); - if(fromProps) { - for(auto prop : *fromProps) { - ANA_CHECK( joSvc->addPropertyToCatalogue( toTool , *prop ) ); - } - for(auto prop : *fromProps) { - ANA_CHECK( joSvc->removePropertyFromCatalogue( fromTool , prop->name() ) ); - } - } - //now also check for subtools which will need copying over - auto clients = joSvc->getClients(); - for(auto& client : clients) { - if(client.find(fromTool+".") == 0 && client!=fromTool) { - std::string newClient(client); newClient.replace(0,strlen(fromTool.c_str()),toTool); - ANA_CHECK( copyPropertiesInCatalogue( client , newClient ) ); - } + ServiceHandle<Gaudi::Interfaces::IOptionsSvc> joSvc("JobOptionsSvc","AnaToolHandle"); + auto fromProps = joSvc->items(std::regex ("^" + fromTool)); + for(auto& prop : fromProps) { + std::get<0>(prop).replace (0, fromTool.size(), toTool); + joSvc->set( std::get<0>(prop) , std::get<1>(prop) ); } if(joSvc.release().isFailure()) return StatusCode::FAILURE; return StatusCode::SUCCESS; diff --git a/Control/AthToolSupport/AsgTools/Root/AsgComponentConfig.cxx b/Control/AthToolSupport/AsgTools/Root/AsgComponentConfig.cxx index a36a30bb57ead9e2665f6d5c7fbfb83c8e2c4ed4..f8c2fa148956fb7426bc1ce16df3d0e58ceffaf7 100644 --- a/Control/AthToolSupport/AsgTools/Root/AsgComponentConfig.cxx +++ b/Control/AthToolSupport/AsgTools/Root/AsgComponentConfig.cxx @@ -24,7 +24,7 @@ #else -#include <GaudiKernel/IJobOptionsSvc.h> +#include "Gaudi/Interfaces/IOptionsSvc.h" #include <GaudiKernel/ServiceHandle.h> #endif @@ -360,7 +360,7 @@ namespace asg ANA_CHECK (checkTypeName (nestedNames)); - ServiceHandle<IJobOptionsSvc> joSvc("JobOptionsSvc","AsgComponentConfig"); + ServiceHandle<Gaudi::Interfaces::IOptionsSvc> joSvc("JobOptionsSvc","AsgComponentConfig"); ANA_CHECK (joSvc.retrieve()); for (const auto& tool : m_privateTools) @@ -368,19 +368,13 @@ namespace asg std::string toolPath = prefix + m_name + "." + tool.first; const auto split = toolPath.rfind ('.'); std::string toolName = toolPath.substr (split+1); - std::string parentName = toolPath.substr (0, split); - StringProperty athenaProperty (toolName, tool.second + "/" + toolName); - ANA_CHECK (joSvc->addPropertyToCatalogue (parentName, std::move (athenaProperty))); + joSvc->set (toolPath, tool.second + "/" + toolName); } for (const auto& property : m_propertyValues) { std::string propertyPath = prefix + m_name + "." + property.first; - const auto split = propertyPath.rfind ('.'); - std::string propertyName = propertyPath.substr (split+1); - std::string componentName = propertyPath.substr (0, split); - StringProperty athenaProperty (propertyName, property.second); - ANA_CHECK (joSvc->addPropertyToCatalogue (componentName, std::move (athenaProperty))); + joSvc->set (propertyPath, property.second); } return StatusCode::SUCCESS;