Gaudi::MetaDataSvc Class Reference

#include <src/MetaDataSvc/MetaDataSvc.h>

Inheritance diagram for Gaudi::MetaDataSvc:
Collaboration diagram for Gaudi::MetaDataSvc:

Public Member Functions

 MetaDataSvc (const std::string &name, ISvcLocator *svc)
 
 ~MetaDataSvc ()
 
StatusCode initialize ()
 
StatusCode start ()
 
bool isEnabled () const
 
StatusCode collectData ()
 
MetaDatagetMetaData ()
 
std::map< std::string, std::stringgetMetaDataMap ()
 
- Public Member Functions inherited from extends< Service, IMetaDataSvc >
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 Attributes

bool m_isEnabled
 
std::map< std::string, std::stringm_metadata
 

Additional Inherited Members

- Public Types inherited from extends< Service, IMetaDataSvc >
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...
 
- 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 14 of file MetaDataSvc.h.

Constructor & Destructor Documentation

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

Definition at line 58 of file MetaDataSvc.cpp.

59 : base_class(name, svc) {
60  declareProperty("Enable", m_isEnabled = true);
61 }
extends base_class
Typedef to this class.
Definition: extends.h:14
Property * declareProperty(const std::string &name, T &property, const std::string &doc="none") const
Declare the named property.
Definition: Service.h:215
MetaDataSvc::~MetaDataSvc ( )

Definition at line 75 of file MetaDataSvc.cpp.

75  {
76 }

Member Function Documentation

StatusCode MetaDataSvc::collectData ( )

Definition at line 83 of file MetaDataSvc.cpp.

84 {
85  std::string temp;
86  bool first{false};
87 
88  auto appMgr = service<IProperty>("ApplicationMgr");
89  if( appMgr.isValid() ) {
90  const std::vector<Property*> properties = appMgr->getProperties();
91  for( int i= 0; i< (signed)properties.size(); i++ ){
92  temp="ApplicationMgr." + properties[i]->name();
93  m_metadata[temp]=properties[i]->toString();
94  }
95  }
96  auto mSvc = service<IProperty>("MessageSvc");
97  if( mSvc.isValid() ) {
98  const std::vector<Property*> properties2 = mSvc->getProperties();
99  for( int i= 0; i< (signed)properties2.size(); i++ ){
100  temp="MessageSvc." + properties2[i]->name();
101  m_metadata[temp]=properties2[i]->toString();
102  }
103  }
104 
105  auto nSvc = service<IProperty>("NTupleSvc");
106  if( nSvc.isValid() ) {
107  const std::vector<Property*> properties5 = nSvc->getProperties();
108  for( int i= 0; i< (signed)properties5.size(); i++ ){
109  temp="NTupleSvc." + properties5[i]->name();
110  m_metadata[temp]=properties5[i]->toString();
111  }
112  }
113 
114  /*
115  * TOOLS
116  * */
117  SmartIF<IToolSvc> tSvc(serviceLocator()->service("ToolSvc"));
118  if(tSvc.isValid() ) {
119  std::vector<std::string> TSvcs = tSvc->getInstances("");
120  temp="";
121  for( int i= 0; i< (signed)TSvcs.size(); i++ ){
122  temp += TSvcs[i];
123  if (i!=(signed)TSvcs.size()-1)temp+=", ";
124  }
125  m_metadata["ToolSvc"]=temp;
126  }
127 
128  /*
129  * SERVICES
130  * */
131  auto Svcs = serviceLocator()->getServices();
132  temp = "";
133  first = true;
134  for (auto svc: Svcs) {
135  if (!first)
136  temp += ", ";
137  else
138  first = false;
139  temp += svc->name();
140  }
141  m_metadata["ISvcLocator.Services"]=temp;
142 
143  /*
144  * ALGORITHMS
145  * */
147  auto allAlgs = algMan->getAlgorithms();
148  temp = "";
149  first = true;
150  for(auto alg: allAlgs) {
151  if (!first)
152  temp += ", ";
153  else
154  first = false;
155  temp += alg->name();
156  }
157  m_metadata["IAlgManager.Algorithms"] = temp;
158 
159  /*
160  * JOB OPTIONS SERVICE
161  * */
162  auto joSvc = service<IProperty>("JobOptionsSvc");
163  if( !joSvc.isValid() ) { return StatusCode::FAILURE ;}
164  const std::vector<Property*> properties7 = joSvc->getProperties();
165  for( int i= 0; i< (signed)properties7.size(); i++ ){
166  temp="JobOptionsSvc." + properties7[i]->name();
167  m_metadata[temp]=properties7[i]->toString();
168  }
169 
170  if (msgLevel(MSG::DEBUG)) {
171  std::stringstream ss_metadata;
172  for(auto item: m_metadata) {
173  ss_metadata << item.first
174  << ':'
175  << item.second
176  << '\n';
177  }
178  debug() << "Metadata collected:\n" << ss_metadata.str() << endmsg;
179  }
180 
181  return StatusCode::SUCCESS;
182 }
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: Service.cpp:324
STL class.
T str(T...args)
T size(T...args)
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
tuple item
print s1,s2
Definition: ana.py:146
tuple appMgr
Definition: IOTest.py:83
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.
Definition: Service.h:144
virtual const std::list< IService * > & getServices() const =0
Get a reference to a service and create it if it does not exists.
MSG::Level msgLevel() const
get the output level from the embedded MsgStream
list i
Definition: ana.py:128
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
std::map< std::string, std::string > m_metadata
Definition: MetaDataSvc.h:35
MetaData * MetaDataSvc::getMetaData ( )

Definition at line 77 of file MetaDataSvc.cpp.

77  {
78  return new MetaData(m_metadata);
79 }
std::map< std::string, std::string > m_metadata
Definition: MetaDataSvc.h:35
std::map< std::string, std::string > MetaDataSvc::getMetaDataMap ( )

Definition at line 80 of file MetaDataSvc.cpp.

80  {
81  return m_metadata;
82 }
std::map< std::string, std::string > m_metadata
Definition: MetaDataSvc.h:35
StatusCode MetaDataSvc::initialize ( )

Definition at line 63 of file MetaDataSvc.cpp.

63  {
65  if ( sc.isFailure() ) return sc;
66  return sc;
67 }
StatusCode initialize() override
Definition: Service.cpp:68
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
bool MetaDataSvc::isEnabled ( ) const

Definition at line 68 of file MetaDataSvc.cpp.

68  {
69  return m_isEnabled;
70 }
StatusCode MetaDataSvc::start ( )

Definition at line 71 of file MetaDataSvc.cpp.

71  {
72  if (msgLevel(MSG::DEBUG)) debug() << "started" << endmsg;
73  return collectData();
74 }
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
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 collectData()
Definition: MetaDataSvc.cpp:83

Member Data Documentation

bool Gaudi::MetaDataSvc::m_isEnabled
private

Definition at line 34 of file MetaDataSvc.h.

std::map<std::string, std::string> Gaudi::MetaDataSvc::m_metadata
private

Definition at line 35 of file MetaDataSvc.h.


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