| The Gaudi Framework v28r2-patches (bc4ad17a)

- 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/ISvcLocator.h"
46 #include "GaudiKernel/IToolSvc.h"
47
48 #include "MetaDataSvc.h"
49
50 using Gaudi::MetaDataSvc;
51
52 DECLARE_COMPONENT( MetaDataSvc )
53
54 StatusCode MetaDataSvc::start()
55 {
56 if ( msgLevel( MSG::DEBUG ) ) debug() << "started" << endmsg;
57 return collectData();
58 }
59 MetaData* MetaDataSvc::getMetaData() { return new MetaData( m_metadata ); }
60 std::map<std::string, std::string> MetaDataSvc::getMetaDataMap() { return m_metadata; }
61 StatusCode MetaDataSvc::collectData()
62 {
63 std::string temp;
64 bool first{false};
65
66 auto appMgr = service<IProperty>( "ApplicationMgr" );
67 if ( appMgr.isValid() ) {
68 const std::vector<Gaudi::Details::PropertyBase*> properties = appMgr->getProperties();
69 for ( int i = 0; i < (signed)properties.size(); i++ ) {
70 temp = "ApplicationMgr." + properties[i]->name();
71 m_metadata[temp] = properties[i]->toString();
72 }
73 }
74 auto mSvc = service<IProperty>( "MessageSvc" );
75 if ( mSvc.isValid() ) {
76 const std::vector<Gaudi::Details::PropertyBase*> properties2 = mSvc->getProperties();
77 for ( int i = 0; i < (signed)properties2.size(); i++ ) {
78 temp = "MessageSvc." + properties2[i]->name();
79 m_metadata[temp] = properties2[i]->toString();
80 }
81 }
82
83 auto nSvc = service<IProperty>( "NTupleSvc" );
84 if ( nSvc.isValid() ) {
85 const std::vector<Gaudi::Details::PropertyBase*> properties5 = nSvc->getProperties();
86 for ( int i = 0; i < (signed)properties5.size(); i++ ) {
87 temp = "NTupleSvc." + properties5[i]->name();
88 m_metadata[temp] = properties5[i]->toString();
89 }
90 }
91
92 /*
93 * TOOLS
94 * */
95 SmartIF<IToolSvc> tSvc( serviceLocator()->service( "ToolSvc" ) );
96 if ( tSvc.isValid() ) {
97 std::vector<std::string> TSvcs = tSvc->getInstances( "" );
98 temp = "";
99 for ( int i = 0; i < (signed)TSvcs.size(); i++ ) {
100 temp += TSvcs[i];
101 if ( i != (signed)TSvcs.size() - 1 ) temp += ", ";
102 }
103 m_metadata["ToolSvc"] = temp;
104 }
105
106 /*
107 * SERVICES
108 * */
109 auto Svcs = serviceLocator()->getServices();
110 temp = "";
111 first = true;
112 for ( auto svc : Svcs ) {
113 if ( !first )
114 temp += ", ";
115 else
116 first = false;
117 temp += svc->name();
118 }
119 m_metadata["ISvcLocator.Services"] = temp;
120
121 /*
122 * ALGORITHMS
123 * */
124 SmartIF<IAlgManager> algMan( serviceLocator() );
125 auto allAlgs = algMan->getAlgorithms();
126 temp = "";
127 first = true;
128 for ( auto alg : allAlgs ) {
129 if ( !first )
130 temp += ", ";
131 else
132 first = false;
133 temp += alg->name();
134 }
135 m_metadata["IAlgManager.Algorithms"] = temp;
136
137 /*
138 * JOB OPTIONS SERVICE
139 * */
140 auto joSvc = service<IProperty>( "JobOptionsSvc" );
141 if ( !joSvc.isValid() ) {
142 return StatusCode::FAILURE;
143 }
144 const std::vector<Gaudi::Details::PropertyBase*> properties7 = joSvc->getProperties();
145 for ( int i = 0; i < (signed)properties7.size(); i++ ) {
146 temp = "JobOptionsSvc." + properties7[i]->name();
147 m_metadata[temp] = properties7[i]->toString();
148 }
149
150 if ( msgLevel( MSG::DEBUG ) ) {
151 std::stringstream ss_metadata;
152 for ( auto item : m_metadata ) {
153 ss_metadata << item.first << ':' << item.second << '\n';
154 }
155 debug() << "Metadata collected:\n" << ss_metadata.str() << endmsg;
156 }
157
158 return StatusCode::SUCCESS;
159 }
IDataSelector.h
PropertyHolder.h
StatusCode::SUCCESS
Definition: StatusCode.h:30
SmartIF< IToolSvc >
NTupleImplementation.h
StatusCode::FAILURE
Definition: StatusCode.h:29
MsgStream.h
ConversionSvc.h
IAlgorithm.h
MSG::DEBUG
Definition: IMessageSvc.h:18
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:36
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:88
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:37
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:126
IConversionSvc.h
SmartIF::isValid
bool isValid() const
Allow for check if smart pointer is valid.
Definition: SmartIF.h:62
Property.h
Gaudi::MetaDataSvc::getMetaDataMap
std::map< std::string, std::string > getMetaDataMap() override
Definition: MetaDataSvc.cpp:60
IOTest.appMgr
appMgr
Definition: IOTest.py:83
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.
DataSelectionAgent.h
MetaData
Definition: MetaData.h:21
Selector.h
DataIncident.h
CommonMessagingBase::msgLevel
MSG::Level msgLevel() const
get the output level from the embedded MsgStream
Definition: CommonMessaging.h:135
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:244
Gaudi::MetaDataSvc::collectData
StatusCode collectData()
Definition: MetaDataSvc.cpp:61
MetaDataSvc.h
DataObject.h
Gaudi::MetaDataSvc::m_metadata
std::map< std::string, std::string > m_metadata
Definition: MetaDataSvc.h:33
IJobOptionsSvc.h