ATLAS Offline Software
Loading...
Searching...
No Matches
python.Dso.DsoDb Class Reference
Inheritance diagram for python.Dso.DsoDb:
Collaboration diagram for python.Dso.DsoDb:

Public Member Functions

 __init__ (self)
 has_type (self, typename)
 load_type (self, typename)
 rflx_type (self, typename)
 visit (self, typename, visitor=None, ctx=None)

Public Attributes

 msg = AthenaCommon.Logging.logging.getLogger("AthenaDsoDb")

Protected Attributes

 _rflx_type = cppyy.gbl.RootType.ByName

Detailed Description

The repository of 'rootmap' files (location, content,...) and a set of
operations one can apply on them (load dict, query dicts,...)

Definition at line 68 of file Control/AthenaServices/python/Dso.py.

Constructor & Destructor Documentation

◆ __init__()

python.Dso.DsoDb.__init__ ( self)

Definition at line 73 of file Control/AthenaServices/python/Dso.py.

73 def __init__(self):
74 super(DsoDb, self).__init__('AthenaDsoDb')
75 import AthenaCommon.Logging
76 self.msg = AthenaCommon.Logging.logging.getLogger("AthenaDsoDb")
77 #self.msg.setLevel(AthenaCommon.Logging.logging.VERBOSE)
78
79 # inject the known aliases NOW
80 for k,v in _aliases.iteritems():
81 try:
82 self.db[k] = self.db[v]
83 except KeyError:
84 self.msg.info("could not install alias [%s] -> [%s]", k,v)
85 # make sure we'll be able to load dicts
86 import cppyy
87 #self._load_dict = cppyy.loadDict
88 self._rflx_type = cppyy.gbl.RootType.ByName
89 return
90

Member Function Documentation

◆ has_type()

python.Dso.DsoDb.has_type ( self,
typename )

Definition at line 91 of file Control/AthenaServices/python/Dso.py.

91 def has_type (self, typename):
92 if typename in _cpp_builtins:
93 return True
94 # need to massage a bit the typename to match ROOT naming convention
95 typename = self._to_rootmap_name (typename)
96 return self.db.has_key (typename) or \
97 self.pf.has_key (typename)
98

◆ load_type()

python.Dso.DsoDb.load_type ( self,
typename )

Definition at line 99 of file Control/AthenaServices/python/Dso.py.

99 def load_type (self, typename):
100 rflx_type = self.rflx_type(typename)
101 if rflx_type is not None:
102 rflx_name = rflx_type.Name(RflxEnums.DICTSCOPE)
103 if rflx_name != '':
104 return rflx_name
105 return None
106

◆ rflx_type()

python.Dso.DsoDb.rflx_type ( self,
typename )

Definition at line 107 of file Control/AthenaServices/python/Dso.py.

107 def rflx_type(self, typename):
108 _rootmap_name = self._to_rootmap_name (typename)
109 _rflx_name = self._to_rflx_name (typename)
110 self.msg.verbose("------- loading type [%s]...", typename)
111
112 if typename in _cpp_builtins:
113 self.msg.verbose(" ==> [ok] (builtin)")
114 return self._rflx_type (_rflx_name)
115
116 if not self.has_type (_rootmap_name):
117 self.msg.verbose(" ==> [err] (no '%s')",_rootmap_name)
118 return None
119 libs = (self.db.get(_rootmap_name) or
120 self.pf.get(_rootmap_name))
121 if libs is None or len(libs) <= 0:
122 return None
123 from ctypes import cdll
124 _load = cdll.LoadLibrary
125 from cppyy import loadDict as _load
126 lib = libs[0]
127 self.msg.verbose("... %s",lib)
128 _load (os.path.basename(lib.strip()))
129 self.msg.verbose("... %s [done]",lib)
130 self.msg.verbose(" ==> [ok]")
131
132 # give the non-massaged name to reflex as this is what it expects
133 # ...ROOT is sooo self-consistent...
134 rflx_type = self._rflx_type (_rflx_name)
135 if rflx_type.Name() != '':
136 return rflx_type
137 return None
138
139
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition hcg.cxx:132
bool verbose
Definition hcg.cxx:75

◆ visit()

python.Dso.DsoDb.visit ( self,
typename,
visitor = None,
ctx = None )

Definition at line 140 of file Control/AthenaServices/python/Dso.py.

140 def visit(self, typename, visitor=None, ctx=None):
141 self.msg.verbose("=== visiting %s", typename)
142 if ctx is None:
143 ctx = set()
144 if isinstance (typename, str):
145 rflx_type = self.load_type (typename)
146 typename = rflx_type.Name (RflxEnums.DICTSCOPE)
147 else:
148 rflx_type = typename
149
150 if not rflx_type:
151 self.msg.verbose("**warning** no dict for [%s] !!", typename)
152 return ctx
153
154 ctx.add (typename)
155 if visitor:
156 visitor (rflx_type)
157
158 if rflx_type.IsClass() or rflx_type.IsStruct():
159 for i in range(rflx_type.BaseSize()):
160 itype = rflx_type.BaseAt(i).ToType()
161 itype_name = itype.Name(RflxEnums.DICTSCOPE)
162 if itype_name != '' and not (itype_name in ctx):
163 self.load_type (itype_name)
164 ctx.add (itype_name)
165 ctx.update (self.visit (itype, visitor, ctx))
166
167 for i in range(rflx_type.DataMemberSize()):
168 itype = rflx_type.DataMemberAt (i).TypeOf()
169 itype = itype.RawType() if itype.IsPointer() else itype
170 itype_name = itype.Name(RflxEnums.DICTSCOPE)
171 if itype_name != '' and not (itype_name in ctx):
172 self.load_type (itype_name)
173 ctx.add (itype_name)
174 # restore original type
175 itype = rflx_type.DataMemberAt (i).TypeOf()
176 itype_name = itype.Name(RflxEnums.DICTSCOPE)
177 ctx.update (self.visit (itype, visitor, ctx))
178 return ctx
179
STL class.

Member Data Documentation

◆ _rflx_type

python.Dso.DsoDb._rflx_type = cppyy.gbl.RootType.ByName
protected

Definition at line 88 of file Control/AthenaServices/python/Dso.py.

◆ msg

python.Dso.DsoDb.msg = AthenaCommon.Logging.logging.getLogger("AthenaDsoDb")

Definition at line 76 of file Control/AthenaServices/python/Dso.py.


The documentation for this class was generated from the following file: