Skip to content
Snippets Groups Projects
Commit 3e272a0f authored by Walter Lampl's avatar Walter Lampl
Browse files

Merge branch 'ana_ioptsvc' into 'master'

AthAnalysisBaseComps: Migrate to IOptionsSvc

See merge request atlas/athena!36408
parents 23ff5e5d f7e5a7f0
No related branches found
No related tags found
No related merge requests found
///////////////////////// -*- C++ -*- /////////////////////////////
/*
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
*/
// AthAnalysisHelper.h
......@@ -16,7 +16,7 @@
#include "StoreGate/StoreGateSvc.h"
#include "GaudiKernel/ServiceHandle.h"
#include "GaudiKernel/IJobOptionsSvc.h"
#include "Gaudi/Interfaces/IOptionsSvc.h"
#include "GaudiKernel/IToolSvc.h"
#include "IOVDbDataModel/IOVMetaDataContainer.h"
......@@ -45,7 +45,7 @@ public:
///helper method for adding a property to the JobOptionsSvc
///to list all the properties in the catalogue, do: AthAnalysisHelper::dumpJobOptionProperties()
template<typename W> static StatusCode addPropertyToCatalogue( const std::string& name , const std::string& property, const W& value, bool override=true) {
ServiceHandle<IJobOptionsSvc> joSvc("JobOptionsSvc","AthAnalysisHelper");
ServiceHandle<Gaudi::Interfaces::IOptionsSvc> joSvc("JobOptionsSvc","AthAnalysisHelper");
if(joSvc.retrieve().isFailure()) return StatusCode::FAILURE;
if(!override) {
//check if property already defined. If so, then print a warning and return failure
......@@ -55,9 +55,8 @@ public:
return StatusCode::FAILURE;
}
}
StatusCode result = joSvc->addPropertyToCatalogue( name , StringProperty( property , Gaudi::Utils::toString ( value ) ) );
if(joSvc.release().isFailure()) return StatusCode::FAILURE;
return result;
joSvc->set( name+"."+property , Gaudi::Utils::toString ( value ) );
return StatusCode::SUCCESS;
}
......@@ -367,7 +366,7 @@ public:
///we keep a static handle to the joboptionsvc, since it's very useful
///can e.g. do: AAH::joSvc->readOptions("myJob.opts","$JOBOPTSEARCHPATH")
static ServiceHandle<IJobOptionsSvc> joSvc;
static ServiceHandle<Gaudi::Interfaces::IOptionsSvc> joSvc;
}; //AthAnalysisHelper class
......
......@@ -8,7 +8,7 @@
const std::string AthAnalysisHelper::UNDEFINED = "__UNDEFINED__";
ServiceHandle<IJobOptionsSvc> AthAnalysisHelper::joSvc = ServiceHandle<IJobOptionsSvc>("JobOptionsSvc","AthAnalysisHelper");
ServiceHandle<Gaudi::Interfaces::IOptionsSvc> AthAnalysisHelper::joSvc = ServiceHandle<Gaudi::Interfaces::IOptionsSvc>("JobOptionsSvc","AthAnalysisHelper");
//need a constructor, implemented here, so that the dictionary library is linked to
//the implementation library (see ldd libAthAnalysisBaseCompsDict.so ... needs a link)
......@@ -49,32 +49,18 @@ bool AthAnalysisHelper::toolExists( const std::string& fullName ) {
}
void AthAnalysisHelper::dumpJobOptionProperties(const std::string& client) {
ServiceHandle<IJobOptionsSvc> joSvc("JobOptionsSvc","AthAnalysisHelper");
ServiceHandle<Gaudi::Interfaces::IOptionsSvc> joSvc("JobOptionsSvc","AthAnalysisHelper");
if(joSvc.retrieve().isFailure()) return;
std::vector<std::string> clients = joSvc->getClients();
for(auto& cl : clients) {
if(cl.find(client)!=0) continue; //must start with client
auto props = joSvc->getProperties(cl);
if(!props) continue;
for(auto prop : *props) {
std::cout << cl << "." << prop->name() << " = " << prop->toString() << std::endl;
}
for(const auto& [name,value] : joSvc->items()) {
if(name.find(client)!=0) continue; //must start with client
std::cout << name << " = " << value << std::endl;
}
joSvc.release().ignore();
}
std::string AthAnalysisHelper::getProperty(const std::string& client, const std::string& property) {
std::string out(UNDEFINED);
ServiceHandle<IJobOptionsSvc> joSvc("JobOptionsSvc","AthAnalysisHelper");
if(joSvc.retrieve().isFailure()) return out;
auto props = joSvc->getProperties(client);
if(!props) { joSvc.release().ignore(); return out; }
for(auto prop : *props) {
if(prop->name()!=property) continue;
out = prop->toString(); break;
}
joSvc.release().ignore();
return out;
ServiceHandle<Gaudi::Interfaces::IOptionsSvc> joSvc("JobOptionsSvc","AthAnalysisHelper");
if(joSvc.retrieve().isFailure()) return UNDEFINED;
return joSvc->get(client+"."+property, UNDEFINED);
}
void AthAnalysisHelper::printAuxElement(const SG::AuxElement& ae) {
......
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