JobOptionsSvc Class Reference

#include <src/JobOptionsSvc/JobOptionsSvc.h>

Inheritance diagram for JobOptionsSvc:
Collaboration diagram for JobOptionsSvc:

Public Types

typedef std::vector< const Property * > PropertiesT
 
- Public Types inherited from extends< Service, IProperty, 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
typedef Gaudi::PluginService::Factory< IService *, const std::string &, ISvcLocator * > Factory
 
- 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)
 
 ~JobOptionsSvc () override=default
 destructor More...
 
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 Property &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 Property * > * getProperties (const std::string &client) const override
 Get the properties associated to a given 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...
 
StatusCode setProperty (const Property &p) override
 IProperty implementation (needed for initialisation) More...
 
StatusCode getProperty (Property *p) const override
 
- Public Member Functions inherited from extends< Service, IProperty, 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...
 
 ~extends () override=default
 Virtual destructor. 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...
 
StatusCode setProperty (const Property &p) override
 
StatusCode setProperty (const std::string &s) override
 
StatusCode setProperty (const std::string &n, const std::string &v) override
 
StatusCode getProperty (Property *p) const override
 
const PropertygetProperty (const std::string &name) const override
 
StatusCode getProperty (const std::string &n, std::string &v) const override
 
const std::vector< Property * > & getProperties () const override
 
bool hasProperty (const std::string &name) const override
 
template<class TYPE >
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value 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 >
PropertydeclareProperty (const std::string &name, T &property, const std::string &doc="none") const
 Declare the named property. More...
 
PropertydeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="") const
 Declare remote named properties. More...
 
template<class T >
StatusCode declarePrivateTool (ToolHandle< T > &handle, std::string toolTypeAndName="", bool createIf=true)
 Declare used Private tool. More...
 
template<class T >
StatusCode declarePublicTool (ToolHandle< T > &handle, std::string toolTypeAndName="", bool createIf=true)
 Declare used Public 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 CommonMessagingBase
virtual ~CommonMessagingBase ()=default
 Virtual destructor. More...
 
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...
 
MSG::Level msgLevel () const
 get the output level from the embedded MsgStream More...
 
MSG::Level outputLevel () const __attribute__((deprecated))
 Backward compatibility function for getting the output level. More...
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream More...
 
- Public Member Functions inherited from extend_interfaces< Interfaces...>
 ~extend_interfaces () override=default
 Virtual destructor. 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

PropertyMgr m_pmgr
 dump the content of Properties catalog to the predefined file More...
 
std::string m_source_path
 
std::string m_source_type
 
std::string m_dir_search_path
 
std::string m_dump
 
std::string m_pythonAction
 
std::string m_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 CommonMessaging< implements< IService, IProperty, IStateful > >
void updateMsgStreamOutputLevel (int level)
 Update the output level of the cached MsgStream. More...
 
- Protected Attributes inherited from Service
IntegerProperty m_outputLevel = MSG::NIL
 Service output level. More...
 
Gaudi::StateMachine::State m_state = Gaudi::StateMachine::OFFLINE
 Service state. More...
 
Gaudi::StateMachine::State m_targetState = Gaudi::StateMachine::OFFLINE
 Service state. More...
 

Detailed Description

Definition at line 20 of file JobOptionsSvc.h.

Member Typedef Documentation

Definition at line 24 of file JobOptionsSvc.h.

Constructor & Destructor Documentation

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

Definition at line 27 of file JobOptionsSvc.cpp.

27  :
28  base_class(name,svc)
29 {
30  m_pmgr.addRef(); // make sure the refCount doesn't go to zero too soon...
31  std::string tmp ;
32  tmp = System::getEnv ( "JOBOPTSEARCHPATH" ) ;
33  if ( !tmp.empty() && ("UNKNOWN" != tmp) ) { m_dir_search_path = tmp ; }
34  tmp = System::getEnv ( "JOBOPTSDUMPFILE" ) ;
35  if ( !tmp.empty() && ("UNKNOWN" != tmp) ) { m_dump = tmp ; }
36 
39  m_pmgr.declareProperty( "SEARCHPATH" , m_dir_search_path ) ;
40  m_pmgr.declareProperty( "DUMPFILE" , m_dump ) ;
41  m_pmgr.declareProperty( "PYTHONACTION" , m_pythonAction ) ;
42  m_pmgr.declareProperty( "PYTHONPARAMS" , m_pythonParams ) ;
43 }
GAUDI_API std::string getEnv(const char *var)
get a particular environment variable (returning "UNKNOWN" if not set)
Definition: System.cpp:617
T empty(T...args)
std::string m_source_type
Definition: JobOptionsSvc.h:77
std::string m_pythonAction
Definition: JobOptionsSvc.h:80
extends base_class
Typedef to this class.
Definition: extends.h:14
std::string m_dir_search_path
Definition: JobOptionsSvc.h:78
STL class.
Property * declareProperty(const std::string &name, TYPE &value, const std::string &doc="none")
Declare a property (templated)
Definition: PropertyMgr.h:186
unsigned long addRef() override
Reference Interface instance.
Definition: implements.h:44
std::string m_dump
Definition: JobOptionsSvc.h:79
std::string m_pythonParams
Definition: JobOptionsSvc.h:81
PropertyMgr m_pmgr
dump the content of Properties catalog to the predefined file
Definition: JobOptionsSvc.h:75
std::string m_source_path
Definition: JobOptionsSvc.h:76
JobOptionsSvc::~JobOptionsSvc ( )
overridedefault

destructor

Member Function Documentation

StatusCode JobOptionsSvc::addPropertyToCatalogue ( const std::string client,
const Property property 
)
override

Add a property into the JobOptions catalog.

Definition at line 75 of file JobOptionsSvc.cpp.

77 {
78  std::unique_ptr<Property> p { new StringProperty ( property.name(), "" ) } ;
79  return property.load( *p ) ? m_svc_catalog.addProperty( client , p.release() )
81 }
const std::string & name() const
property name
Definition: Property.h:45
SvcCatalog m_svc_catalog
Definition: JobOptionsSvc.h:82
StatusCode addProperty(const std::string &client, const Property *property)
Definition: SvcCatalog.cpp:35
SimpleProperty< std::string > StringProperty
Definition: Property.h:718
bool load(Property &dest) const override
set value for another property
Definition: Property.h:283
void JobOptionsSvc::dump ( const std::string file,
const Gaudi::Parsers::Catalog catalog 
) const
private

Definition at line 126 of file JobOptionsSvc.cpp.

127  {
128  std::ofstream out( file , std::ios_base::out | std::ios_base::trunc );
129  if ( !out ) {
130  error() << "Unable to open dump-file \""+file+"\"" << endmsg ;
131  return ; // RETURN
132  }
133  info() << "Properties are dumped into \""+file+"\"" << endmsg ;
134  // perform the actual dump:
135  out << catalog;
136 }
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:244
void JobOptionsSvc::fillServiceCatalog ( const Gaudi::Parsers::Catalog catalog)
private

Definition at line 138 of file JobOptionsSvc.cpp.

138  {
139  for (const auto& client : catalog) {
140  for (const auto& current : client.second ) {
141  addPropertyToCatalogue ( client.first ,
142  StringProperty{ current.NameInClient(),
143  current.ValueAsString() } );
144  }
145  }
146 }
StatusCode addPropertyToCatalogue(const std::string &client, const Property &property) override
Add a property into the JobOptions catalog.
std::vector< std::string > JobOptionsSvc::getClients ( ) const
override

Get the list of clients.

Definition at line 121 of file JobOptionsSvc.cpp.

121  {
122  return m_svc_catalog.getClients();
123 }
SvcCatalog m_svc_catalog
Definition: JobOptionsSvc.h:82
std::vector< std::string > getClients() const
Definition: SvcCatalog.cpp:67
const JobOptionsSvc::PropertiesT * JobOptionsSvc::getProperties ( const std::string client) const
override

Get the properties associated to a given client.

Definition at line 92 of file JobOptionsSvc.cpp.

93 {
94  return m_svc_catalog.getProperties(client);
95 }
const PropertiesT * getProperties(const std::string &client) const
Definition: SvcCatalog.cpp:65
SvcCatalog m_svc_catalog
Definition: JobOptionsSvc.h:82
StatusCode JobOptionsSvc::getProperty ( Property p) const
override

Definition at line 50 of file JobOptionsSvc.cpp.

51 {
52  return m_pmgr.getProperty( p );
53 }
StatusCode getProperty(Property *p) const override
get the property
PropertyMgr m_pmgr
dump the content of Properties catalog to the predefined file
Definition: JobOptionsSvc.h:75
StatusCode JobOptionsSvc::initialize ( )
override

Definition at line 55 of file JobOptionsSvc.cpp.

56 {
57  // Call base class initializer
59  // Read the job options if needed
60  if (sc) {
61  if (m_source_type == "NONE") {
62  return sc;
63  } else if (m_source_type == "PYTHON") {
64  PythonConfig conf(this);
65  return conf.evaluateConfig(m_source_path, m_pythonParams, m_pythonAction);
66  } else {
68  }
69  }
70  return sc;
71 }
StatusCode initialize() override
Definition: Service.cpp:68
std::string m_source_type
Definition: JobOptionsSvc.h:77
std::string m_pythonAction
Definition: JobOptionsSvc.h:80
std::string m_dir_search_path
Definition: JobOptionsSvc.h:78
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
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 ...
std::string m_pythonParams
Definition: JobOptionsSvc.h:81
std::string m_source_path
Definition: JobOptionsSvc.h:76
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 148 of file JobOptionsSvc.cpp.

149  {
150  std::string search_path = path;
151  if ( search_path.empty() && !m_dir_search_path.empty() )
152  { search_path = m_dir_search_path ; }
153  //
154  if (msgLevel(MSG::DEBUG))
155  debug() << "Reading options from the file "
156  << "'" << file << "'" << endmsg;
157  gp::Messages messages(msgStream());
158  gp::Catalog catalog;
159  gp::Units units;
160  gp::PragmaOptions pragma;
161  gp::Node ast;
162  StatusCode sc = gp::ReadOptions(file, path, &messages, &catalog, &units,
163  &pragma, &ast);
164 
165  // --------------------------------------------------------------------------
166  if ( sc.isSuccess() )
167  {
168  if (pragma.IsPrintOptions()) {
169  info() << "Print options" << std::endl << catalog
170  << endmsg;
171  }
172  if (pragma.IsPrintTree()) {
173  info() << "Print tree:" << std::endl << ast.ToString()
174  << endmsg;
175  }
176  if (pragma.HasDumpFile()) dump(pragma.dumpFile(), catalog);
177  info() << "Job options successfully read in from " << file << endmsg;
178  fillServiceCatalog(catalog);
179  } else {
180  fatal() << "Job options errors."<< endmsg;
181  }
182  // ----------------------------------------------------------------------------
183  return sc;
184 }
T empty(T...args)
void fillServiceCatalog(const Gaudi::Parsers::Catalog &catalog)
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:76
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:416
std::string m_dir_search_path
Definition: JobOptionsSvc.h:78
STL class.
void dump(const std::string &file, const Gaudi::Parsers::Catalog &catalog) const
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
GAUDI_API std::string path(const AIDA::IBaseHistogram *aida)
get the path in THS for AIDA histogram
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)
MSG::Level msgLevel() const
get the output level from the embedded MsgStream
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
StatusCode JobOptionsSvc::removePropertyFromCatalogue ( const std::string client,
const std::string name 
)
override

Remove a property from the JobOptions catalog.

Definition at line 85 of file JobOptionsSvc.cpp.

87 {
88  return m_svc_catalog.removeProperty(client,name);
89 }
SvcCatalog m_svc_catalog
Definition: JobOptionsSvc.h:82
StatusCode removeProperty(const std::string &client, const std::string &name)
Definition: SvcCatalog.cpp:49
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 97 of file JobOptionsSvc.cpp.

99 {
100  const auto* props = m_svc_catalog.getProperties(client);
101  if ( !props ){ return StatusCode::SUCCESS; }
102 
103  bool fail = false;
104  for ( const auto& cur : *props )
105  {
106  StatusCode sc = myInt->setProperty ( *cur ) ;
107  if ( sc.isFailure() )
108  {
109  error()
110  << "Unable to set the property '" << cur->name() << "'"
111  << " of '" << client << "'. "
112  << "Check option and algorithm names, type and bounds."
113  << endmsg;
114  fail = true;
115  }
116  }
117  return fail ? StatusCode::FAILURE : StatusCode::SUCCESS ;
118 }
const PropertiesT * getProperties(const std::string &client) const
Definition: SvcCatalog.cpp:65
SvcCatalog m_svc_catalog
Definition: JobOptionsSvc.h:82
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
StatusCode JobOptionsSvc::setProperty ( const Property p)
override

IProperty implementation (needed for initialisation)

Definition at line 45 of file JobOptionsSvc.cpp.

46 {
47  return m_pmgr.setProperty( p );
48 }
StatusCode setProperty(const Property &p) override
set the property form another property
PropertyMgr m_pmgr
dump the content of Properties catalog to the predefined file
Definition: JobOptionsSvc.h:75

Member Data Documentation

std::string JobOptionsSvc::m_dir_search_path
private

Definition at line 78 of file JobOptionsSvc.h.

std::string JobOptionsSvc::m_dump
private

Definition at line 79 of file JobOptionsSvc.h.

PropertyMgr JobOptionsSvc::m_pmgr
private

dump the content of Properties catalog to the predefined file

Definition at line 75 of file JobOptionsSvc.h.

std::string JobOptionsSvc::m_pythonAction
private

Definition at line 80 of file JobOptionsSvc.h.

std::string JobOptionsSvc::m_pythonParams
private

Definition at line 81 of file JobOptionsSvc.h.

std::string JobOptionsSvc::m_source_path
private

Definition at line 76 of file JobOptionsSvc.h.

std::string JobOptionsSvc::m_source_type
private

Definition at line 77 of file JobOptionsSvc.h.

SvcCatalog JobOptionsSvc::m_svc_catalog
private

Definition at line 82 of file JobOptionsSvc.h.


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