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

Add support for .json options to Gaudi.exe

See merge request gaudi/Gaudi!1388
parents aeb7cf6c c97e0f4c
No related branches found
No related tags found
1 merge request!1388Add support for .json options to Gaudi.exe
Pipeline #4759574 canceled
#####################################################################################
# (c) Copyright 1998-2021 CERN for the benefit of the LHCb and ATLAS collaborations #
# (c) Copyright 1998-2022 CERN for the benefit of the LHCb and ATLAS collaborations #
# #
# This software is distributed under the terms of the Apache version 2 licence, #
# copied verbatim in the file "LICENSE". #
......@@ -57,6 +57,7 @@ gaudi_add_module(GaudiCoreSvc
Boost::regex
Boost::system
Boost::thread
nlohmann_json::nlohmann_json
TBB::tbb
${rt_LIBRARY} # UNIX only
${GAUDI_ATOMIC_LIBS})
......
......@@ -21,6 +21,7 @@
#include <Gaudi/Property.h>
#include <GaudiKernel/IProperty.h>
#include <GaudiKernel/MsgStream.h>
#include <GaudiKernel/PathResolver.h>
#include <GaudiKernel/PropertyHolder.h>
#include <GaudiKernel/Service.h>
#include <GaudiKernel/StatusCode.h>
......@@ -28,6 +29,7 @@
#include <algorithm>
#include <functional>
#include <memory>
#include <nlohmann/json.hpp>
#include <string>
#include <unordered_map>
#include <vector>
......@@ -233,10 +235,19 @@ void JobOptionsSvc::fillServiceCatalog( const gp::Catalog& catalog ) {
StatusCode JobOptionsSvc::readOptions( std::string_view file, std::string_view path ) {
std::string search_path = std::string{ path };
if ( search_path.empty() && !m_dir_search_path.empty() ) { search_path = m_dir_search_path; }
//
if ( msgLevel( MSG::DEBUG ) )
debug() << "Reading options from the file "
<< "'" << file << "'" << endmsg;
if ( file.size() >= 5 && file.substr( file.size() - 5 ) == ".json" ) {
nlohmann::json opts;
std::ifstream input( System::PathResolver::find_file( std::string( file ), std::string( path ) ) );
input >> opts;
for ( auto item = opts.begin(); item != opts.end(); ++item ) { set( item.key(), item.value().get<std::string>() ); }
return StatusCode::SUCCESS;
}
gp::Messages messages( msgStream() );
gp::Catalog catalog;
gp::Units units;
......
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