The Gaudi Framework  v30r3 (a5ef0a68)
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 23 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 {
26  if ( System::isEnvSet( "JOBOPTSEARCHPATH" ) ) m_dir_search_path = System::getEnv( "JOBOPTSEARCHPATH" );
27  if ( System::isEnvSet( "JOBOPTSDUMPFILE" ) ) m_dump = System::getEnv( "JOBOPTSDUMPFILE" );
28 }
GAUDI_API std::string getEnv(const char *var)
get a particular environment variable (returning "UNKNOWN" if not set)
Definition: System.cpp:411
extends base_class
Typedef to this class.
Definition: extends.h:15
Gaudi::Property< std::string > m_dump
Definition: JobOptionsSvc.h:75
Gaudi::Property< std::string > m_dir_search_path
Definition: JobOptionsSvc.h:74
GAUDI_API bool isEnvSet(const char *var)
Check if an environment variable is set or not.
Definition: System.cpp:433

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 49 of file JobOptionsSvc.cpp.

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

Definition at line 89 of file JobOptionsSvc.cpp.

90 {
91  std::ofstream out( file, std::ios_base::out | std::ios_base::trunc );
92  if ( !out ) {
93  error() << "Unable to open dump-file \"" + file + "\"" << endmsg;
94  return; // RETURN
95  }
96  info() << "Properties are dumped into \"" + file + "\"" << endmsg;
97  // perform the actual dump:
98  out << catalog;
99 }
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:209
void JobOptionsSvc::fillServiceCatalog ( const Gaudi::Parsers::Catalog catalog)
private

Definition at line 101 of file JobOptionsSvc.cpp.

102 {
103  for ( const auto& client : catalog ) {
104  for ( const auto& current : client.second ) {
105  addPropertyToCatalogue( client.first,
106  Gaudi::Property<std::string>{current.NameInClient(), current.ValueAsString()} );
107  }
108  }
109 }
Implementation of property with value of concrete type.
Definition: Property.h:381
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 50 of file JobOptionsSvc.h.

52  {
53  return m_svc_catalog.getProperty( client, name );
54  }
SvcCatalog m_svc_catalog
Definition: JobOptionsSvc.h:79
const Gaudi::Details::PropertyBase * getProperty(const std::string &client, const std::string &name) const
Definition: SvcCatalog.cpp:120
std::vector< std::string > JobOptionsSvc::getClients ( ) const
override

Get the list of clients.

Definition at line 87 of file JobOptionsSvc.cpp.

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

Get the properties associated to a given client.

Definition at line 61 of file JobOptionsSvc.cpp.

62 {
63  return m_svc_catalog.getProperties( client );
64 }
const PropertiesT * getProperties(const std::string &client) const
Definition: SvcCatalog.cpp:65
SvcCatalog m_svc_catalog
Definition: JobOptionsSvc.h:79
StatusCode JobOptionsSvc::initialize ( )
override

Definition at line 30 of file JobOptionsSvc.cpp.

31 {
32  // Call base class initializer
34  // Read the job options if needed
35  if ( sc ) {
36  if ( m_source_type == "NONE" ) {
37  return sc;
38  } else if ( m_source_type == "PYTHON" ) {
39  PythonConfig conf( this );
40  return conf.evaluateConfig( m_source_path, m_pythonParams, m_pythonAction );
41  } else {
43  }
44  }
45  return sc;
46 }
StatusCode initialize() override
Definition: Service.cpp:63
Gaudi::Property< std::string > m_source_path
Definition: JobOptionsSvc.h:73
Gaudi::Property< std::string > m_pythonAction
Definition: JobOptionsSvc.h:76
Gaudi::Property< std::string > m_pythonParams
Definition: JobOptionsSvc.h:77
Gaudi::Property< std::string > m_dir_search_path
Definition: JobOptionsSvc.h:74
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:51
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:72
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 111 of file JobOptionsSvc.cpp.

112 {
113  std::string search_path = path;
114  if ( search_path.empty() && !m_dir_search_path.empty() ) {
115  search_path = m_dir_search_path;
116  }
117  //
118  if ( msgLevel( MSG::DEBUG ) )
119  debug() << "Reading options from the file "
120  << "'" << file << "'" << endmsg;
121  gp::Messages messages( msgStream() );
122  gp::Catalog catalog;
123  gp::Units units;
124  gp::PragmaOptions pragma;
125  gp::Node ast;
126  StatusCode sc = gp::ReadOptions( file, path, &messages, &catalog, &units, &pragma, &ast ) ? StatusCode::SUCCESS
128 
129  // --------------------------------------------------------------------------
130  if ( sc.isSuccess() ) {
131  if ( pragma.IsPrintOptions() ) {
132  info() << "Print options" << std::endl << catalog << endmsg;
133  }
134  if ( pragma.IsPrintTree() ) {
135  info() << "Print tree:" << std::endl << ast.ToString() << endmsg;
136  }
137  if ( pragma.HasDumpFile() ) dump( pragma.dumpFile(), catalog );
138  info() << "Job options successfully read in from " << file << endmsg;
139  fillServiceCatalog( catalog );
140  } else {
141  fatal() << "Job options errors." << endmsg;
142  }
143  // ----------------------------------------------------------------------------
144  return sc;
145 }
constexpr static const auto FAILURE
Definition: StatusCode.h:88
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:287
T endl(T...args)
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:390
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:74
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:51
constexpr static const auto SUCCESS
Definition: StatusCode.h:87
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
MsgStream & msgStream() const
Return an uninitialized MsgStream.
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:209
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 56 of file JobOptionsSvc.cpp.

57 {
58  return m_svc_catalog.removeProperty( client, name );
59 }
SvcCatalog m_svc_catalog
Definition: JobOptionsSvc.h:79
StatusCode removeProperty(const std::string &client, const std::string &name)
Definition: SvcCatalog.cpp:52
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 66 of file JobOptionsSvc.cpp.

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

Member Data Documentation

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

Definition at line 74 of file JobOptionsSvc.h.

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

Definition at line 75 of file JobOptionsSvc.h.

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

Definition at line 76 of file JobOptionsSvc.h.

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

Definition at line 77 of file JobOptionsSvc.h.

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

Definition at line 73 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 72 of file JobOptionsSvc.h.

SvcCatalog JobOptionsSvc::m_svc_catalog
private

Definition at line 79 of file JobOptionsSvc.h.


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