ATLAS Offline Software
Loading...
Searching...
No Matches
AthDictLoaderSvc_test.py
Go to the documentation of this file.
1# @file: AthenaServices/share/AthDictLoaderSvc_test.py
2# @purpose: make sure we can reliably load dictionaries with AthDictLoaderSvc
3# @author: Sebastien Binet <binet@cern.ch>
4# @date: October 2008
5
6import AthenaPython.PyAthena as PyAthena
7StatusCode = PyAthena.StatusCode
8
10 """simple algorithm to test the AthDictLoaderSvc capabilities
11 """
12
13 def __init__ (self, name="AthDictLoaderTestAlg", **kw):
14 kw['name'] = name
15 super (AthDictLoaderTestAlg, self).__init__(**kw)
16
17 self.dict_tests = kw.get(
18 'dict_tests',
19 ('std::string',
20 'std::basic_string<char>',
21 'std::vector<std::string>',
22 'std::vector<std::basic_string<char> >',
23 'std::vector<double>',
24 'egamma',
25 'egamma_p1',
26 'std::vector<std::string,std::allocator<std::string> >',
27 'std::map<int,int>',
28 'std::map<std::string,std::string>',
29 'std::map<std::string, std::string>',
30 'std::map<std::basic_string<char>,std::basic_string<char> >',
31 'std::pair<int,int>',
32 'std::pair<std::string,std::string>',
33 'std::pair<std::string, std::string>',
34 'std::pair<std::basic_string<char>,std::basic_string<char> >',
35 'std::pair<std::basic_string<char>, std::basic_string<char> >',
36 'std::set<std::string>',
37 'std::set<std::basic_string<char> >',
38 'std::set<unsigned int>',
39 'DataVector<TruthParticle>',
40 'INavigable4Momentum',
41 'INavigable4MomentumCollection',
42 'IParticleContainer',
43 'DataVector<egamma>',
44 'ElementLinkInt_p1',
45 'ElementLink_p1<unsigned int>',
46 ))
47 # handle to AthDictLoaderSvc
48 self.dict_svc = None
49 return
50
51 def initialize (self):
52 self.msg.info ('retrieving the dictionary loader svc...')
53 self.dict_svc = PyAthena.py_svc ('AthDictLoaderSvc',
54 iface='IDictLoaderSvc')
55 if self.dict_svc is None:
56 self.msg.error ('could not retrieve the dict. loader svc')
57 return StatusCode.Failure
58 return StatusCode.Success
59
60 def execute (self):
61 DICT_SCOPE = 7
62 _info = self.msg.info
63 _info ('testing loading of dictionaries...')
64 all_good = True
65 for name in self.dict_tests:
66 _info ('-'*40)
67 _info ('--> [%s]', name)
68 type_name = self.dict_svc.load_type (name).Name(DICT_SCOPE)
69 _info ('<-- [%s]', type_name)
70 if type_name == '':
71 all_good = False
72 self.msg.error ('problem loading dict for type [%s]', name)
73 if not all_good:
74 self.msg.error ('problem occured !')
75 return StatusCode.Failure
76 _info ('test of dictionary loading SUCCEEDED')
77 return StatusCode.Success
78
79 def finalize (self):
80 return StatusCode.Success
81 pass # AthDictLoaderTestAlg
82
83from AthenaCommon.AlgSequence import AlgSequence
84job = AlgSequence()
MsgStream & msg() const
__init__(self, name="AthDictLoaderTestAlg", **kw)
virtual StatusCode execute() override
virtual StatusCode finalize() override
virtual StatusCode initialize() override