9 from __future__
import with_statement
11 __version__ =
"$Revision: 1.12 $"
12 __author__ =
"Sebastien Binet <binet@cern.ch>"
14 simple interface to the rootmap files to easily locate reflex dictionaries \
24 from PyUtils
import Dso
as _Dso
25 from PyUtils.Dso
import _aliases
29 import RootUtils.PyROOTFixes
44 The repository of 'rootmap' files (location, content,...) and a set of
45 operations one can apply on them (load dict, query dicts,...)
48 super(DsoDb, self).
__init__(
'AthenaDsoDb')
49 import AthenaCommon.Logging
50 self.
msg = AthenaCommon.Logging.logging.getLogger(
"AthenaDsoDb")
54 for k,v
in _aliases.iteritems():
56 self.db[k] = self.db[v]
58 self.
msg.
info(
"could not install alias [%s] -> [%s]", k,v)
67 if typename
in _cpp_builtins:
70 typename = self._to_rootmap_name (typename)
71 return self.db.has_key (typename)
or \
72 self.pf.has_key (typename)
76 if not(rflx_type
is None):
77 rflx_name = rflx_type.Name(RflxEnums.DICTSCOPE)
83 _rootmap_name = self._to_rootmap_name (typename)
84 _rflx_name = self._to_rflx_name (typename)
85 self.
msg.
verbose(
"------- loading type [%s]...", typename)
88 if typename
in _cpp_builtins:
92 if not self.
has_type (_rootmap_name):
93 self.
msg.
verbose(
" ==> [err] (no '%s')",_rootmap_name)
95 libs = (self.db.
get(_rootmap_name)
or
96 self.pf.
get(_rootmap_name))
97 if libs
is None or len(libs) <= 0:
99 from ctypes
import cdll
100 _load = cdll.LoadLibrary
101 from cppyy
import loadDict
as _load
104 _load (os.path.basename(lib.strip()))
111 if rflx_type.Name() !=
'':
116 def visit(self, typename, visitor=None, ctx=None):
120 if isinstance (typename, str):
122 typename = rflx_type.Name (RflxEnums.DICTSCOPE)
127 self.
msg.
verbose(
"**warning** no dict for [%s] !!", typename)
134 if rflx_type.IsClass()
or rflx_type.IsStruct():
135 for i
in range(rflx_type.BaseSize()):
136 itype = rflx_type.BaseAt(i).ToType()
137 itype_name = itype.Name(RflxEnums.DICTSCOPE)
138 if itype_name !=
'' and not (itype_name
in ctx):
141 ctx.update (self.
visit (itype, visitor, ctx))
143 for i
in range(rflx_type.DataMemberSize()):
144 itype = rflx_type.DataMemberAt (i).TypeOf()
145 itype = itype.RawType()
if itype.IsPointer()
else itype
146 itype_name = itype.Name(RflxEnums.DICTSCOPE)
147 if itype_name !=
'' and not (itype_name
in ctx):
151 itype = rflx_type.DataMemberAt (i).TypeOf()
152 itype_name = itype.Name(RflxEnums.DICTSCOPE)
153 ctx.update (self.
visit (itype, visitor, ctx))
159 registry = _Dso.DsoDb()