CGEM BOSS 6.6.5.h
BESIII Offline Software System
Loading...
Searching...
No Matches
GetPropertyValue.h
Go to the documentation of this file.
1#ifndef GET_PROPERTY_VALUE_H
2#define GET_PROPERTY_VALUE_H
3
4#include "GaudiKernel/IJobOptionsSvc.h"
5#include "GaudiKernel/Bootstrap.h"
6#include "GaudiKernel/StatusCode.h"
7#include "GaudiKernel/Parsers.h" //in "GaudiSvc/JobOptionsSvc"
8
9namespace DistBoss {
10
11template<typename T>
12StatusCode GetPropertyValue(const std::string& client, const std::string& name, T& value)
13{
14 static IJobOptionsSvc* jobSvc = 0;
15
16 StatusCode sc;
17
18 if ( jobSvc == 0 ) {
19 sc = Gaudi::svcLocator()->service("JobOptionsSvc", jobSvc);
20 if ( sc.isFailure() ) {
21 std::cout << "Can't get the JobOptionsSvc @ DistBoss::GetPropertyValue()" << std::endl;
22 return sc;
23 }
24 }
25
26 const std::vector<const Property*>* properties = jobSvc->getProperties(client);
27 if ( properties == NULL ) {
28 std::cout << "In DistBoss::GetPropertyValue(), can't get client: " << client << std::endl;
29 return StatusCode::FAILURE;
30 }
31
32 for ( unsigned int i = 0; i < properties->size(); ++i ) {
33 if ( properties->at(i)->name() == name ) {
34 return Gaudi::Parsers::parse(value, properties->at(i)->toString());
35 }
36 }
37
38 return StatusCode::FAILURE;
39}
40
41}
42
43#endif
StatusCode GetPropertyValue(const std::string &client, const std::string &name, T &value)