10 __version__ =
"$Revision: 1.12 $"
11 __author__ =
"Sebastien Binet <binet@cern.ch>"
13 simple interface to the rootmap files to easily locate reflex dictionaries \
23 from PyUtils
import Dso
as _Dso
24 from PyUtils.Dso
import _aliases
28 import RootUtils.PyROOTFixes
43 The repository of 'rootmap' files (location, content,...) and a set of
44 operations one can apply on them (load dict, query dicts,...)
47 super(DsoDb, self).
__init__(
'AthenaDsoDb')
48 import AthenaCommon.Logging
49 self.
msg = AthenaCommon.Logging.logging.getLogger(
"AthenaDsoDb")
53 for k,v
in _aliases.iteritems():
55 self.db[k] = self.db[v]
57 self.
msg.
info(
"could not install alias [%s] -> [%s]", k,v)
66 if typename
in _cpp_builtins:
69 typename = self._to_rootmap_name (typename)
70 return self.db.has_key (typename)
or \
71 self.pf.has_key (typename)
75 if not(rflx_type
is None):
76 rflx_name = rflx_type.Name(RflxEnums.DICTSCOPE)
82 _rootmap_name = self._to_rootmap_name (typename)
83 _rflx_name = self._to_rflx_name (typename)
84 self.
msg.
verbose(
"------- loading type [%s]...", typename)
87 if typename
in _cpp_builtins:
91 if not self.
has_type (_rootmap_name):
92 self.
msg.
verbose(
" ==> [err] (no '%s')",_rootmap_name)
94 libs = (self.db.
get(_rootmap_name)
or
95 self.pf.
get(_rootmap_name))
96 if libs
is None or len(libs) <= 0:
98 from ctypes
import cdll
99 _load = cdll.LoadLibrary
100 from cppyy
import loadDict
as _load
103 _load (os.path.basename(lib.strip()))
110 if rflx_type.Name() !=
'':
115 def visit(self, typename, visitor=None, ctx=None):
119 if isinstance (typename, str):
121 typename = rflx_type.Name (RflxEnums.DICTSCOPE)
126 self.
msg.
verbose(
"**warning** no dict for [%s] !!", typename)
133 if rflx_type.IsClass()
or rflx_type.IsStruct():
134 for i
in range(rflx_type.BaseSize()):
135 itype = rflx_type.BaseAt(i).ToType()
136 itype_name = itype.Name(RflxEnums.DICTSCOPE)
137 if itype_name !=
'' and not (itype_name
in ctx):
140 ctx.update (self.
visit (itype, visitor, ctx))
142 for i
in range(rflx_type.DataMemberSize()):
143 itype = rflx_type.DataMemberAt (i).TypeOf()
144 itype = itype.RawType()
if itype.IsPointer()
else itype
145 itype_name = itype.Name(RflxEnums.DICTSCOPE)
146 if itype_name !=
'' and not (itype_name
in ctx):
150 itype = rflx_type.DataMemberAt (i).TypeOf()
151 itype_name = itype.Name(RflxEnums.DICTSCOPE)
152 ctx.update (self.
visit (itype, visitor, ctx))
158 registry = _Dso.DsoDb()