| The Gaudi Framework v30r0 (c919700c)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

MetaDataSvc.cpp
Go to the documentation of this file.
1 /*
2 * MetaDataSvc.cpp
3 *
4 * Created on: Mar 24, 2015
5 * Author: Ana Trisovic
6 */
7
8 // Framework include files
9 #include "GaudiKernel/xtoa.h"
10
11 #include "GaudiKernel/DataObject.h"
12 #include "GaudiKernel/GenericAddress.h"
13 #include "GaudiKernel/ObjectFactory.h"
14
15 #include "GaudiKernel/ConversionSvc.h"
16 #include "GaudiKernel/DataSelectionAgent.h"
17 #include "GaudiKernel/MetaData.h"
18 #include "GaudiKernel/MsgStream.h"
19 #include "GaudiKernel/NTupleImplementation.h"
20 #include "GaudiKernel/Property.h"
21 #include "GaudiKernel/Selector.h"
22
23 #include "GaudiKernel/Bootstrap.h"
24
25 #include "GaudiKernel/PropertyHolder.h"
26 #include "GaudiKernel/Service.h"
27 #include "GaudiKernel/SmartIF.h"
28
29 #include "GaudiKernel/DataObject.h"
30 #include "GaudiKernel/GaudiException.h"
31
32 #include "GaudiKernel/DataIncident.h"
33 #include "GaudiKernel/DataSvc.h"
34 #include "GaudiKernel/IAlgManager.h"
35 #include "GaudiKernel/IAlgTool.h"
36 #include "GaudiKernel/IAlgorithm.h"
37 #include "GaudiKernel/IConversionSvc.h"
38 #include "GaudiKernel/IConverter.h"
39 #include "GaudiKernel/IDataSelector.h"
40 #include "GaudiKernel/IJobOptionsSvc.h"
41 #include "GaudiKernel/IMessageSvc.h"
42 #include "GaudiKernel/IOpaqueAddress.h"
43 #include "GaudiKernel/IProperty.h"
44 #include "GaudiKernel/ISvcLocator.h"
45 #include "GaudiKernel/IToolSvc.h"
46
47 #include "MetaDataSvc.h"
48
49 using Gaudi::MetaDataSvc;
50
51 DECLARE_COMPONENT( MetaDataSvc )
52
53 StatusCode MetaDataSvc::start()
54 {
55 if ( msgLevel( MSG::DEBUG ) ) debug() << "started" << endmsg;
56 return collectData();
57 }
58 MetaData* MetaDataSvc::getMetaData() { return new MetaData( m_metadata ); }
59 std::map<std::string, std::string> MetaDataSvc::getMetaDataMap() { return m_metadata; }
60 StatusCode MetaDataSvc::collectData()
61 {
62 std::string temp;
63 bool first{false};
64
65 auto appMgr = service<IProperty>( "ApplicationMgr" );
66 if ( appMgr.isValid() ) {
67 const std::vector<Gaudi::Details::PropertyBase*> properties = appMgr->getProperties();
68 for ( int i = 0; i < (signed)properties.size(); i++ ) {
69 temp = "ApplicationMgr." + properties[i]->name();
70 m_metadata[temp] = properties[i]->toString();
71 }
72 }
73 auto mSvc = service<IProperty>( "MessageSvc" );
74 if ( mSvc.isValid() ) {
75 const std::vector<Gaudi::Details::PropertyBase*> properties2 = mSvc->getProperties();
76 for ( int i = 0; i < (signed)properties2.size(); i++ ) {
77 temp = "MessageSvc." + properties2[i]->name();
78 m_metadata[temp] = properties2[i]->toString();
79 }
80 }
81
82 auto nSvc = service<IProperty>( "NTupleSvc" );
83 if ( nSvc.isValid() ) {
84 const std::vector<Gaudi::Details::PropertyBase*> properties5 = nSvc->getProperties();
85 for ( int i = 0; i < (signed)properties5.size(); i++ ) {
86 temp = "NTupleSvc." + properties5[i]->name();
87 m_metadata[temp] = properties5[i]->toString();
88 }
89 }
90
91 /*
92 * TOOLS
93 * */
94 SmartIF<IToolSvc> tSvc( serviceLocator()->service( "ToolSvc" ) );
95 if ( tSvc.isValid() ) {
96 std::vector<std::string> TSvcs = tSvc->getInstances( "" );
97 temp = "";
98 for ( int i = 0; i < (signed)TSvcs.size(); i++ ) {
99 temp += TSvcs[i];
100 if ( i != (signed)TSvcs.size() - 1 ) temp += ", ";
101 }
102 m_metadata["ToolSvc"] = temp;
103 }
104
105 /*
106 * SERVICES
107 * */
108 auto Svcs = serviceLocator()->getServices();
109 temp = "";
110 first = true;
111 for ( auto svc : Svcs ) {
112 if ( !first )
113 temp += ", ";
114 else
115 first = false;
116 temp += svc->name();
117 }
118 m_metadata["ISvcLocator.Services"] = temp;
119
120 /*
121 * ALGORITHMS
122 * */
123 SmartIF<IAlgManager> algMan( serviceLocator() );
124 auto allAlgs = algMan->getAlgorithms();
125 temp = "";
126 first = true;
127 for ( auto alg : allAlgs ) {
128 if ( !first )
129 temp += ", ";
130 else
131 first = false;
132 temp += alg->name();
133 }
134 m_metadata["IAlgManager.Algorithms"] = temp;
135
136 /*
137 * JOB OPTIONS SERVICE
138 * */
139 auto joSvc = service<IProperty>( "JobOptionsSvc" );
140 if ( !joSvc.isValid() ) {
141 return StatusCode::FAILURE;
142 }
143 const std::vector<Gaudi::Details::PropertyBase*> properties7 = joSvc->getProperties();
144 for ( int i = 0; i < (signed)properties7.size(); i++ ) {
145 temp = "JobOptionsSvc." + properties7[i]->name();
146 m_metadata[temp] = properties7[i]->toString();
147 }
148
149 if ( msgLevel( MSG::DEBUG ) ) {
150 std::stringstream ss_metadata;
151 for ( auto item : m_metadata ) {
152 ss_metadata << item.first << ':' << item.second << '\n';
153 }
154 debug() << "Metadata collected:\n" << ss_metadata.str() << endmsg;
155 }
156
157 return StatusCode::SUCCESS;
158 }
IDataSelector.h
PropertyHolder.h
StatusCode::SUCCESS
Definition: StatusCode.h:29
SmartIF< IToolSvc >
NTupleImplementation.h
MsgStream.h
ConversionSvc.h
IAlgorithm.h
MSG::DEBUG
Definition: IMessageSvc.h:16
ObjectFactory.h
Bootstrap.h
MetaData.h
IToolSvc.h
std::map< std::string, std::string >
std::stringstream
STL class.
DECLARE_COMPONENT
#define DECLARE_COMPONENT(type)
Definition: PluginService.h:33
std::string
STL class.
Service.h
DataSvc.h
xtoa.h
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
GaudiException.h
SmartIF.h
IAlgTool.h
IOTest.start
start
Definition: IOTest.py:99
std::stringstream::str
T str(T...args)
IMessageSvc.h
Gaudi::MetaDataSvc
Definition: MetaDataSvc.h:15
IOpaqueAddress.h
GaudiSvc.getMetaData
def getMetaData(path)
Definition: __init__.py:1
std::vector::size
T size(T...args)
IProperty.h
std::vector< Gaudi::Details::PropertyBase * >
gaudiComponentHelp.properties
properties
Definition: gaudiComponentHelp.py:41
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:115
IConversionSvc.h
SmartIF::isValid
bool isValid() const
Allow for check if smart pointer is valid.
Definition: SmartIF.h:68
Property.h
Gaudi::MetaDataSvc::getMetaDataMap
std::map< std::string, std::string > getMetaDataMap() override
Definition: MetaDataSvc.cpp:59
IOTest.appMgr
appMgr
Definition: IOTest.py:94
ISvcLocator::getServices
virtual const std::list< IService * > & getServices() const =0
Get a reference to a service and create it if it does not exists.
IAlgManager.h
IToolSvc::getInstances
virtual std::vector< std::string > getInstances(const std::string &toolType)=0
Get the names of all instances of tools of a given type.
Service::service
StatusCode service(const std::string &name, const T *&psvc, bool createIf=true) const
Access a service by name, creating it if it doesn&#39;t already exist.
Definition: Service.h:85
IAlgManager::getAlgorithms
virtual const std::vector< IAlgorithm * > & getAlgorithms() const =0
Return the list of Algorithms.
StatusCode::FAILURE
Definition: StatusCode.h:29
DataSelectionAgent.h
MetaData
Definition: MetaData.h:21
Selector.h
DataIncident.h
CommonMessagingBase::msgLevel
MSG::Level msgLevel() const
get the cached level (originally extracted from the embedded MsgStream)
Definition: CommonMessaging.h:124
IConverter.h
GenericAddress.h
ISvcLocator.h
Service::serviceLocator
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: Service.cpp:292
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
Gaudi::MetaDataSvc::collectData
StatusCode collectData()
Definition: MetaDataSvc.cpp:60
MetaDataSvc.h
DataObject.h
Gaudi::MetaDataSvc::m_metadata
std::map< std::string, std::string > m_metadata
Definition: MetaDataSvc.h:33
IJobOptionsSvc.h