The Gaudi Framework  v31r0 (aeb156f0)
JobOptionsSvc Class Reference

#include <src/JobOptionsSvc/JobOptionsSvc.h>

Inheritance diagram for JobOptionsSvc:
Collaboration diagram for JobOptionsSvc:

Public Types

typedef std::vector< const Gaudi::Details::PropertyBase * > PropertiesT
 
- Public Types inherited from extends< Service, IJobOptionsSvc >
using base_class = extends
 Typedef to this class. More...
 
using extend_interfaces_base = extend_interfaces< Interfaces... >
 Typedef to the base of this class. More...
 
- Public Types inherited from Service
using Factory = Gaudi::PluginService::Factory< IService *(const std::string &, ISvcLocator *)>
 
- Public Types inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
using PropertyHolderImpl = PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
 Typedef used to refer to this class from derived classes, as in. More...
 
- Public Types inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
using base_class = CommonMessaging
 
- Public Types inherited from extend_interfaces< Interfaces... >
using ext_iids = typename Gaudi::interface_list_cat< typename Interfaces::ext_iids... >::type
 take union of the ext_iids of all Interfaces... More...
 

Public Member Functions

 JobOptionsSvc (const std::string &name, ISvcLocator *svc)
 
StatusCode initialize () override
 
StatusCode setMyProperties (const std::string &client, IProperty *me) override
 Override default properties of the calling client. More...
 
StatusCode addPropertyToCatalogue (const std::string &client, const Gaudi::Details::PropertyBase &property) override
 Add a property into the JobOptions catalog. More...
 
StatusCode removePropertyFromCatalogue (const std::string &client, const std::string &name) override
 Remove a property from the JobOptions catalog. More...
 
const std::vector< const Gaudi::Details::PropertyBase * > * getProperties (const std::string &client) const override
 Get the properties associated to a given client. More...
 
const Gaudi::Details::PropertyBasegetClientProperty (const std::string &client, const std::string &name) const override
 Get a property for a client. More...
 
std::vector< std::stringgetClients () const override
 Get the list of clients. More...
 
StatusCode readOptions (const std::string &file, const std::string &path="") override
 look for file 'file' into search path 'path' and read it to update existing JobOptionsCatalogue More...
 
- Public Member Functions inherited from extends< Service, IJobOptionsSvc >
void * i_cast (const InterfaceID &tid) const override
 Implementation of IInterface::i_cast. More...
 
StatusCode queryInterface (const InterfaceID &ti, void **pp) override
 Implementation of IInterface::queryInterface. More...
 
std::vector< std::stringgetInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames. More...
 
- Public Member Functions inherited from Service
const std::stringname () const override
 Retrieve name of the service. More...
 
StatusCode configure () override
 
StatusCode initialize () override
 
StatusCode start () override
 
StatusCode stop () override
 
StatusCode finalize () override
 
StatusCode terminate () override
 
Gaudi::StateMachine::State FSMState () const override
 
Gaudi::StateMachine::State targetFSMState () const override
 
StatusCode reinitialize () override
 
StatusCode restart () override
 
StatusCode sysInitialize () override
 Initialize Service. More...
 
StatusCode sysStart () override
 Initialize Service. More...
 
StatusCode sysStop () override
 Initialize Service. More...
 
StatusCode sysFinalize () override
 Finalize Service. More...
 
StatusCode sysReinitialize () override
 Re-initialize the Service. More...
 
StatusCode sysRestart () override
 Re-initialize the Service. More...
 
 Service (std::string name, ISvcLocator *svcloc)
 Standard Constructor. More...
 
SmartIF< ISvcLocator > & serviceLocator () const override
 Retrieve pointer to service locator. More...
 
StatusCode setProperties ()
 Method for setting declared properties to the values specified for the job. More...
 
template<class T >
StatusCode service (const std::string &name, const T *&psvc, bool createIf=true) const
 Access a service by name, creating it if it doesn't already exist. More...
 
template<class T >
StatusCode service (const std::string &name, T *&psvc, bool createIf=true) const
 
template<typename IFace = IService>
SmartIF< IFace > service (const std::string &name, bool createIf=true) const
 
template<class T >
StatusCode service (const std::string &svcType, const std::string &svcName, T *&psvc) const
 Access a service by name and type, creating it if it doesn't already exist. More...
 
template<class T >
StatusCode declareTool (ToolHandle< T > &handle, std::string toolTypeAndName, bool createIf=true)
 Declare used tool. More...
 
SmartIF< IAuditorSvc > & auditorSvc () const
 The standard auditor service.May not be invoked before sysInitialize() has been invoked. More...
 
- Public Member Functions inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
 PropertyHolder ()=default
 
Gaudi::Details::PropertyBasedeclareProperty (Gaudi::Details::PropertyBase &prop)
 Declare a property. More...
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, TYPE &value, const std::string &doc="none")
 Helper to wrap a regular data member and use it as a regular property. More...
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, Gaudi::Property< TYPE, VERIFIER, HANDLERS > &prop, const std::string &doc="none")
 Declare a PropertyBase instance setting name and documentation. More...
 
Gaudi::Details::PropertyBasedeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="")
 Declare a remote property. More...
 
StatusCode setProperty (const Gaudi::Details::PropertyBase &p) override
 set the property form another property More...
 
StatusCode setProperty (const std::string &s) override
 set the property from the formatted string More...
 
StatusCode setProperty (const std::string &n, const std::string &v) override
 set the property from name and the value More...
 
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value More...
 
StatusCode getProperty (Gaudi::Details::PropertyBase *p) const override
 get the property More...
 
const Gaudi::Details::PropertyBasegetProperty (const std::string &name) const override
 get the property by name More...
 
StatusCode getProperty (const std::string &n, std::string &v) const override
 convert the property to the string More...
 
const std::vector< Gaudi::Details::PropertyBase * > & getProperties () const override
 get all properties More...
 
bool hasProperty (const std::string &name) const override
 Return true if we have a property with the given name. More...
 
 PropertyHolder (const PropertyHolder &)=delete
 
PropertyHolderoperator= (const PropertyHolder &)=delete
 
- Public Member Functions inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
MSG::Level msgLevel () const
 get the cached level (originally extracted from the embedded MsgStream) More...
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream More...
 
MSG::Level outputLevel () const
 Backward compatibility function for getting the output level. More...
 
- Public Member Functions inherited from CommonMessagingBase
virtual ~CommonMessagingBase ()=default
 Virtual destructor. More...
 
const SmartIF< IMessageSvc > & msgSvc () const
 The standard message service. More...
 
MsgStreammsgStream () const
 Return an uninitialized MsgStream. More...
 
MsgStreammsgStream (const MSG::Level level) const
 Predefined configurable message stream for the efficient printouts. More...
 
MsgStreamalways () const
 shortcut for the method msgStream(MSG::ALWAYS) More...
 
MsgStreamfatal () const
 shortcut for the method msgStream(MSG::FATAL) More...
 
MsgStreamerr () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamerror () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamwarning () const
 shortcut for the method msgStream(MSG::WARNING) More...
 
MsgStreaminfo () const
 shortcut for the method msgStream(MSG::INFO) More...
 
MsgStreamdebug () const
 shortcut for the method msgStream(MSG::DEBUG) More...
 
MsgStreamverbose () const
 shortcut for the method msgStream(MSG::VERBOSE) More...
 
MsgStreammsg () const
 shortcut for the method msgStream(MSG::INFO) More...
 

Private Member Functions

void fillServiceCatalog (const Gaudi::Parsers::Catalog &catalog)
 
void dump (const std::string &file, const Gaudi::Parsers::Catalog &catalog) const
 

Private Attributes

Gaudi::Property< std::stringm_source_type {this, "TYPE"}
 dump the content of Properties catalog to the predefined file More...
 
Gaudi::Property< std::stringm_source_path {this, "PATH"}
 
Gaudi::Property< std::stringm_dir_search_path {this, "SEARCHPATH"}
 
Gaudi::Property< std::stringm_dump {this, "DUMPFILE"}
 
Gaudi::Property< std::stringm_pythonAction {this, "PYTHONACTION"}
 
Gaudi::Property< std::stringm_pythonParams {this, "PYTHONPARAMS"}
 
SvcCatalog m_svc_catalog
 

Additional Inherited Members

- Protected Member Functions inherited from Service
 ~Service () override
 Standard Destructor. More...
 
int outputLevel () const
 get the Service's output level More...
 
- Protected Member Functions inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
Gaudi::Details::PropertyBaseproperty (const std::string &name) const
 
- Protected Member Functions inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
MSG::Level setUpMessaging () const
 Set up local caches. More...
 
MSG::Level resetMessaging ()
 Reinitialize internal states. More...
 
void updateMsgStreamOutputLevel (int level)
 Update the output level of the cached MsgStream. More...
 
- Protected Attributes inherited from Service
Gaudi::StateMachine::State m_state = Gaudi::StateMachine::OFFLINE
 Service state. More...
 
Gaudi::StateMachine::State m_targetState = Gaudi::StateMachine::OFFLINE
 Service state. More...
 
Gaudi::Property< int > m_outputLevel {this, "OutputLevel", MSG::NIL, "output level"}
 
Gaudi::Property< bool > m_auditInit {this, "AuditServices", false, "[[deprecated]] unused"}
 
Gaudi::Property< bool > m_auditorInitialize {this, "AuditInitialize", false, "trigger auditor on initialize()"}
 
Gaudi::Property< bool > m_auditorStart {this, "AuditStart", false, "trigger auditor on start()"}
 
Gaudi::Property< bool > m_auditorStop {this, "AuditStop", false, "trigger auditor on stop()"}
 
Gaudi::Property< bool > m_auditorFinalize {this, "AuditFinalize", false, "trigger auditor on finalize()"}
 
Gaudi::Property< bool > m_auditorReinitialize {this, "AuditReinitialize", false, "trigger auditor on reinitialize()"}
 
Gaudi::Property< bool > m_auditorRestart {this, "AuditRestart", false, "trigger auditor on restart()"}
 
SmartIF< IAuditorSvcm_pAuditorSvc
 Auditor Service. More...
 

Detailed Description

Definition at line 21 of file JobOptionsSvc.h.

Member Typedef Documentation

Constructor & Destructor Documentation

JobOptionsSvc::JobOptionsSvc ( const std::string name,
ISvcLocator svc 
)

Definition at line 24 of file JobOptionsSvc.cpp.

24  : base_class( name, svc ) {
25  if ( System::isEnvSet( "JOBOPTSEARCHPATH" ) ) m_dir_search_path = System::getEnv( "JOBOPTSEARCHPATH" );
26  if ( System::isEnvSet( "JOBOPTSDUMPFILE" ) ) m_dump = System::getEnv( "JOBOPTSDUMPFILE" );
27 }
GAUDI_API std::string getEnv(const char *var)
get a particular environment variable (returning "UNKNOWN" if not set)
Definition: System.cpp:380
extends base_class
Typedef to this class.
Definition: extends.h:14
Gaudi::Property< std::string > m_dump
Definition: JobOptionsSvc.h:71
Gaudi::Property< std::string > m_dir_search_path
Definition: JobOptionsSvc.h:70
GAUDI_API bool isEnvSet(const char *var)
Check if an environment variable is set or not.
Definition: System.cpp:400

Member Function Documentation

StatusCode JobOptionsSvc::addPropertyToCatalogue ( const std::string client,
const Gaudi::Details::PropertyBase property 
)
override

Add a property into the JobOptions catalog.

Definition at line 47 of file JobOptionsSvc.cpp.

48  {
49  auto p = std::make_unique<Gaudi::Property<std::string>>( property.name(), "" );
50  return property.load( *p ) ? m_svc_catalog.addProperty( client, p.release() ) : StatusCode::FAILURE;
51 }
SvcCatalog m_svc_catalog
Definition: JobOptionsSvc.h:75
StatusCode addProperty(const std::string &client, const Gaudi::Details::PropertyBase *property)
Definition: SvcCatalog.cpp:36
constexpr static const auto FAILURE
Definition: StatusCode.h:86
void JobOptionsSvc::dump ( const std::string file,
const Gaudi::Parsers::Catalog catalog 
) const
private

Definition at line 81 of file JobOptionsSvc.cpp.

81  {
82  std::ofstream out( file, std::ios_base::out | std::ios_base::trunc );
83  if ( !out ) {
84  error() << "Unable to open dump-file \"" + file + "\"" << endmsg;
85  return; // RETURN
86  }
87  info() << "Properties are dumped into \"" + file + "\"" << endmsg;
88  // perform the actual dump:
89  out << catalog;
90 }
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
STL class.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
void JobOptionsSvc::fillServiceCatalog ( const Gaudi::Parsers::Catalog catalog)
private

Definition at line 92 of file JobOptionsSvc.cpp.

92  {
93  for ( const auto& client : catalog ) {
94  for ( const auto& current : client.second ) {
95  addPropertyToCatalogue( client.first,
96  Gaudi::Property<std::string>{current.NameInClient(), current.ValueAsString()} );
97  }
98  }
99 }
Implementation of property with value of concrete type.
Definition: Property.h:352
StatusCode addPropertyToCatalogue(const std::string &client, const Gaudi::Details::PropertyBase &property) override
Add a property into the JobOptions catalog.
const Gaudi::Details::PropertyBase* JobOptionsSvc::getClientProperty ( const std::string client,
const std::string name 
) const
inlineoverride

Get a property for a client.

Definition at line 47 of file JobOptionsSvc.h.

48  {
49  return m_svc_catalog.getProperty( client, name );
50  }
SvcCatalog m_svc_catalog
Definition: JobOptionsSvc.h:75
const Gaudi::Details::PropertyBase * getProperty(const std::string &client, const std::string &name) const
Definition: SvcCatalog.cpp:107
std::vector< std::string > JobOptionsSvc::getClients ( ) const
override

Get the list of clients.

Definition at line 79 of file JobOptionsSvc.cpp.

79 { return m_svc_catalog.getClients(); }
SvcCatalog m_svc_catalog
Definition: JobOptionsSvc.h:75
std::vector< std::string > getClients() const
Definition: SvcCatalog.cpp:63
const JobOptionsSvc::PropertiesT * JobOptionsSvc::getProperties ( const std::string client) const
override

Get the properties associated to a given client.

Definition at line 57 of file JobOptionsSvc.cpp.

57  {
58  return m_svc_catalog.getProperties( client );
59 }
const PropertiesT * getProperties(const std::string &client) const
Definition: SvcCatalog.cpp:59
SvcCatalog m_svc_catalog
Definition: JobOptionsSvc.h:75
StatusCode JobOptionsSvc::initialize ( )
override

Definition at line 29 of file JobOptionsSvc.cpp.

29  {
30  // Call base class initializer
32  // Read the job options if needed
33  if ( sc ) {
34  if ( m_source_type == "NONE" ) {
35  return sc;
36  } else if ( m_source_type == "PYTHON" ) {
37  PythonConfig conf( this );
38  return conf.evaluateConfig( m_source_path, m_pythonParams, m_pythonAction );
39  } else {
41  }
42  }
43  return sc;
44 }
StatusCode initialize() override
Definition: Service.cpp:60
Gaudi::Property< std::string > m_source_path
Definition: JobOptionsSvc.h:69
Gaudi::Property< std::string > m_pythonAction
Definition: JobOptionsSvc.h:72
Gaudi::Property< std::string > m_pythonParams
Definition: JobOptionsSvc.h:73
Gaudi::Property< std::string > m_dir_search_path
Definition: JobOptionsSvc.h:70
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
StatusCode readOptions(const std::string &file, const std::string &path="") override
look for file &#39;file&#39; into search path &#39;path&#39; and read it to update existing JobOptionsCatalogue ...
Gaudi::Property< std::string > m_source_type
dump the content of Properties catalog to the predefined file
Definition: JobOptionsSvc.h:68
StatusCode JobOptionsSvc::readOptions ( const std::string file,
const std::string path = "" 
)
override

look for file 'file' into search path 'path' and read it to update existing JobOptionsCatalogue

Parameters
filefile name
pathsearch path
Returns
status code

Definition at line 101 of file JobOptionsSvc.cpp.

101  {
102  std::string search_path = path;
103  if ( search_path.empty() && !m_dir_search_path.empty() ) { search_path = m_dir_search_path; }
104  //
105  if ( msgLevel( MSG::DEBUG ) )
106  debug() << "Reading options from the file "
107  << "'" << file << "'" << endmsg;
108  gp::Messages messages( msgStream() );
109  gp::Catalog catalog;
110  gp::Units units;
111  gp::PragmaOptions pragma;
112  gp::Node ast;
113  StatusCode sc = gp::ReadOptions( file, path, &messages, &catalog, &units, &pragma, &ast ) ? StatusCode::SUCCESS
115 
116  // --------------------------------------------------------------------------
117  if ( sc.isSuccess() ) {
118  if ( pragma.IsPrintOptions() ) { info() << "Print options" << std::endl << catalog << endmsg; }
119  if ( pragma.IsPrintTree() ) { info() << "Print tree:" << std::endl << ast.ToString() << endmsg; }
120  if ( pragma.HasDumpFile() ) dump( pragma.dumpFile(), catalog );
121  info() << "Job options successfully read in from " << file << endmsg;
122  fillServiceCatalog( catalog );
123  } else {
124  fatal() << "Job options errors." << endmsg;
125  }
126  // ----------------------------------------------------------------------------
127  return sc;
128 }
T empty(T...args)
void fillServiceCatalog(const Gaudi::Parsers::Catalog &catalog)
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
bool isSuccess() const
Definition: StatusCode.h:267
T endl(T...args)
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
bool ReadOptions(const std::string &filename, const std::string &search_path, Messages *messages, Catalog *catalog, Units *units, PragmaOptions *pragma, Node *root)
Parse and analyze filename, save all messages and properties.
Definition: Analyzer.cpp:374
STL class.
void dump(const std::string &file, const Gaudi::Parsers::Catalog &catalog) const
Gaudi::Property< std::string > m_dir_search_path
Definition: JobOptionsSvc.h:70
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
MsgStream & msgStream() const
Return an uninitialized MsgStream.
constexpr static const auto FAILURE
Definition: StatusCode.h:86
MsgStream & fatal() const
shortcut for the method msgStream(MSG::FATAL)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
MSG::Level msgLevel() const
get the cached level (originally extracted from the embedded MsgStream)
StatusCode JobOptionsSvc::removePropertyFromCatalogue ( const std::string client,
const std::string name 
)
override

Remove a property from the JobOptions catalog.

Definition at line 53 of file JobOptionsSvc.cpp.

53  {
54  return m_svc_catalog.removeProperty( client, name );
55 }
SvcCatalog m_svc_catalog
Definition: JobOptionsSvc.h:75
StatusCode removeProperty(const std::string &client, const std::string &name)
Definition: SvcCatalog.cpp:47
StatusCode JobOptionsSvc::setMyProperties ( const std::string client,
IProperty me 
)
override

Override default properties of the calling client.

Parameters
clientName of the client algorithm or service
meAddress of the interface IProperty of the client

Definition at line 61 of file JobOptionsSvc.cpp.

61  {
62  const auto* props = m_svc_catalog.getProperties( client );
63  if ( !props ) { return StatusCode::SUCCESS; }
64 
65  bool fail = false;
66  for ( const auto& cur : *props ) {
67  StatusCode sc = myInt->setProperty( *cur );
68  if ( sc.isFailure() ) {
69  error() << "Unable to set the property '" << cur->name() << "'"
70  << " of '" << client << "'. "
71  << "Check option and algorithm names, type and bounds." << endmsg;
72  fail = true;
73  }
74  }
76 }
const PropertiesT * getProperties(const std::string &client) const
Definition: SvcCatalog.cpp:59
SvcCatalog m_svc_catalog
Definition: JobOptionsSvc.h:75
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
bool isFailure() const
Definition: StatusCode.h:130
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
constexpr static const auto FAILURE
Definition: StatusCode.h:86
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192

Member Data Documentation

Gaudi::Property<std::string> JobOptionsSvc::m_dir_search_path {this, "SEARCHPATH"}
private

Definition at line 70 of file JobOptionsSvc.h.

Gaudi::Property<std::string> JobOptionsSvc::m_dump {this, "DUMPFILE"}
private

Definition at line 71 of file JobOptionsSvc.h.

Gaudi::Property<std::string> JobOptionsSvc::m_pythonAction {this, "PYTHONACTION"}
private

Definition at line 72 of file JobOptionsSvc.h.

Gaudi::Property<std::string> JobOptionsSvc::m_pythonParams {this, "PYTHONPARAMS"}
private

Definition at line 73 of file JobOptionsSvc.h.

Gaudi::Property<std::string> JobOptionsSvc::m_source_path {this, "PATH"}
private

Definition at line 69 of file JobOptionsSvc.h.

Gaudi::Property<std::string> JobOptionsSvc::m_source_type {this, "TYPE"}
private

dump the content of Properties catalog to the predefined file

Definition at line 68 of file JobOptionsSvc.h.

SvcCatalog JobOptionsSvc::m_svc_catalog
private

Definition at line 75 of file JobOptionsSvc.h.


The documentation for this class was generated from the following files: