Go to the documentation of this file.
32 #include <nlohmann/json.hpp>
34 #include <unordered_map>
37 #if __cplusplus >= 201703
38 # include <string_view>
40 # include <experimental/string_view>
42 using experimental::string_view;
135 "Allow definition of global defaults for properties as list of pairs (regex, value)" };
182 if ( !p.second.isBound() ) unused.
emplace_back( p.first );
185 if ( !unused.
empty() ) {
187 auto&
log = warning();
188 log << unused.
size() <<
" unused properties:";
189 for (
const auto& k : unused )
log <<
"\n - " << k;
205 error() <<
"Unable to open dump-file \"" + file +
"\"" <<
endmsg;
208 info() <<
"Properties are dumped into \"" + file +
"\"" <<
endmsg;
216 error() <<
"Unable to open dump-file \"" + file +
"\"" <<
endmsg;
218 info() <<
"Properties are dumped into \"" + file +
"\"" <<
endmsg;
219 for (
const auto& [
key, value] :
items() ) {
220 out <<
key <<
" = " << value <<
';';
228 for (
const auto& client : catalog ) {
229 for (
const auto& current : client.second ) {
230 set( client.first +
'.' + current.NameInClient(), current.ValueAsString() );
240 debug() <<
"Reading options from the file "
241 <<
"'" << file <<
"'" <<
endmsg;
243 if ( file.size() >= 5 && file.substr( file.size() - 5 ) ==
".json" ) {
247 for (
auto item =
opts.begin(); item !=
opts.end(); ++item ) {
set( item.key(), item.value().get<
std::string>() ); }
264 info() <<
"Job options successfully read in from " << file <<
endmsg;
267 fatal() <<
"Job options errors." <<
endmsg;
280 if ( regex_match(
key, match, p.first ) ) { defaultValue = {
true, p.second }; }
287 if ( std::get<0>( defaultValue ) )
set(
key,
std::string{ std::get<1>( defaultValue ) } );
293 if ( !defaults_only || !p.second.isSet() ) {
294 const auto s = p.first.str();
295 if ( regex_match(
s, match, filter ) ) { p.second = value; }
std::string get(const std::string &key, const std::string &default_={}) const override
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
StatusCode initialize() override
Gaudi::Property< bool > m_reportUnused
std::map< std::string, PropertiesT > m_old_iface_compat_2
GAUDI_API std::string getEnv(const char *var)
get a particular environment variable (returning "UNKNOWN" if not set)
Gaudi::Property< std::string > m_pythonAction
Gaudi::Property< std::string > m_source_path
void set(const std::string &key, const std::string &value) override
void bind(const std::string &prefix, Gaudi::Details::PropertyBase *property) override
Gaudi::Property< std::string > m_pythonParams
MSG::Level msgLevel() const
get the cached level (originally extracted from the embedded MsgStream)
Gaudi::Details::PropertyBase * property(std::string_view name) const
\fixme property and bindPropertiesTo should be protected
void broadcast(const std::regex &filter, const std::string &value, OnlyDefaults defaults_only) override
StatusCode start() override
std::map< std::string, std::unique_ptr< Gaudi::Details::PropertyBase > > m_old_iface_compat
AttribStringParser::Iterator begin(const AttribStringParser &parser)
const std::string & name() const override
Retrieve name of the service
std::string ToString(int indent=0) const
Gaudi::Property< std::string > m_dump
StatusCode stop() override
Gaudi::Property< std::vector< std::pair< std::string, std::string > > > m_globalDefaultsProp
Details::PropertyBase & declareUpdateHandler(std::function< void(Details::PropertyBase &)> fun) override
set new callback for update
StatusCode readOptions(std::string_view file, std::string_view path="") override
look for file 'file' into search path 'path' and read it to update existing JobOptionsCatalogue
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
GAUDI_API bool isEnvSet(const char *var)
Check if an environment variable is set or not.
Base class used to extend a class implementing other interfaces.
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
bool ReadOptions(std::string_view filename, std::string_view search_path, Messages *messages, Catalog *catalog, Units *units, PragmaOptions *pragma, Node *root)
Parse and analyze filename, save all messages and properties.
void dump(const std::string &file, const Gaudi::Parsers::Catalog &catalog) const
dump properties catalog to file
Gaudi::Property< std::string > m_dir_search_path
std::vector< const Gaudi::Details::PropertyBase * > PropertiesT
T emplace_back(T... args)
Helper to record a property identifier as a sequence of SharedString instances.
constexpr static const auto SUCCESS
StatusCode stop() override
StatusCode initialize() override
Gaudi::Property< std::string > m_source_type
static std::string find_file(const std::string &logical_file_name, const std::string &search_path, SearchType search_type=LocalSearch)
#define DECLARE_COMPONENT(type)
bool isSet(const std::string &key) const override
constexpr static const auto FAILURE
std::string pop(const std::string &key, const std::string &default_={}) override
void fillServiceCatalog(const Gaudi::Parsers::Catalog &catalog)
std::vector< std::tuple< std::string, std::string > > items() const override
const std::string & dumpFile() const
bool has(const std::string &key) const override
std::vector< std::pair< std::regex, std::string > > m_globalDefaults
JobOptionsSvc(const std::string &name, ISvcLocator *svc)