ATLAS Offline Software
Loading...
Searching...
No Matches
ComponentFactory.py
Go to the documentation of this file.
1# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2
3import sys
4import AthenaConfiguration.AtlasSemantics # noqa: F401 (load ATLAS-specific semantics)
5from AthenaCommon.Configurable import Configurable
6from GaudiConfig2 import Configurables as cfg2
7
8
10 """Returns true if the python fragment is ComponentAccumulator-based"""
11
12 if ("AthenaCommon.Include" not in sys.modules
13 or not Configurable._useGlobalInstances):
14 return True
15 else:
16 return False
17
18
19def _getConf1(name):
20 """Return legacy Configurable class with given name"""
21 from AthenaCommon.ConfigurableDb import getConfigurable
22 return getConfigurable(name.replace("::","__"), assumeCxxClass=False)
23
24
26 """Return Configurable factory for legacy/CA jobs"""
27
28 def __getattr__(self, name):
29 """Return Configurable class with given name"""
30 if not name.startswith("__"):
31 return getattr(cfg2, name) if isComponentAccumulatorCfg() else _getConf1(name)
32
33 def getComp(self, name):
34 """Return Configurable class with given name"""
35 return cfg2.getByType(name) if isComponentAccumulatorCfg() else _getConf1(name)
36
37 def getComps(self, *names):
38 """Return list of Configurable classes with given names"""
39 return [self.getComp(name) for name in names]
40
41
42CompFactory = _compFactory()