ATLAS Offline Software
Public Member Functions | Public Attributes | List of all members
StreamerInfoGenerator.StreamerInfoGenerator Class Reference
Collaboration diagram for StreamerInfoGenerator.StreamerInfoGenerator:

Public Member Functions

def __init__ (self)
 
def inspect (self, typename)
 
def streamers (self)
 

Public Attributes

 debug
 
 classlist
 
 problemclasses
 
 blacklist
 
 type
 

Detailed Description

Definition at line 7 of file StreamerInfoGenerator.py.

Constructor & Destructor Documentation

◆ __init__()

def StreamerInfoGenerator.StreamerInfoGenerator.__init__ (   self)

Definition at line 8 of file StreamerInfoGenerator.py.

8  def __init__(self):
9  self.debug = False
10  print("StreamerInfoGenerator v1.0.0")
11  self.classlist = []
12  self.problemclasses = []
13  #MN: ROOT6 strips std:: from types, so we need to check the names
14  self.blacklist = ['std::', 'vector<', 'map<', 'queue<', 'list<']
15  self.type = cppyy.gbl.RootType
16  self.type.EnableCintex()
17  cppyy.load_library('libAtlasSTLAddReflexDict')
18  #MN: switch off auto dict generation - god knows what that can mess up
19  ROOT.gROOT.ProcessLine(".autodict")
20 
21 

Member Function Documentation

◆ inspect()

def StreamerInfoGenerator.StreamerInfoGenerator.inspect (   self,
  typename 
)

Definition at line 22 of file StreamerInfoGenerator.py.

22  def inspect(self, typename):
23  if self.debug: print('inspecting ', typename)
24 
25  dontAdd = False
26 
27  for b in self.blacklist:
28  if typename.find(b) == 0:
29  if self.debug: print('blacklisted ', typename)
30  dontAdd = True
31 
32  # print self.classlist
33  if typename in self.classlist:
34  if self.debug: print('seen before ', typename)
35  dontAdd = True
36 
37  try:
38  t = self.type.ByName(typename)
39  if self.debug: print(type(t))
40  if t.IsFundamental():
41  if self.debug: print(typename, ' is fundamental')
42  return
43  if t.IsAbstract():
44  dontAdd = True
45  except Exception:
46  pass
47 
48  # can't handle anonymous types
49  exceptions = ["string::(anonymous)","string::(unnamed)"]
50  try:
51  # This doesn't work in ROOT 6.22 anymore
52  # cl = cppyy.makeClass(typename)
53  #
54  bind_name = typename
55  # If it's a type with template argument, replace outermost <...> with ['...']
56  bind_name = bind_name.replace("<", "['", 1)[::-1].replace(">", "]'", 1)[::-1]
57  # Replace "::" with "." to set namespace, for the base type
58  base_and_arg = bind_name.split("[")
59  base_and_arg[0] = base_and_arg[0].replace("::", ".")
60  bind_name = "[".join(base_and_arg)
61  bind_name = "ROOT." + bind_name
62  if self.debug:
63  print("Making class {} -> {}".format(typename, bind_name))
64  print("cl = " + bind_name)
65  exec("cl = " + bind_name, globals())
66  if self.debug: print(cl) # noqa: F821
67  if not dontAdd:
68  self.classlist.append(typename)
69  if self.debug: print("appended type to the classlist")
70  except Exception as ex:
71  if self.debug: print('Cannot create class of {}: {}'.format(typename, ex))
72  if typename not in exceptions:
73  raise ex
74 
75  t = self.type.ByName(typename)
76 
77  if t.IsComplete():
78  if self.debug: print(typename, 'is complete')
79  else:
80  if self.debug: print(typename, ' isn\'t complete')
81 
82  if t.IsPointer():
83  if self.debug: print(typename, ' is a pointer')
84  elif t.IsTypedef():
85  if self.debug: print(typename, ' is typedef')
86  underlying = t.ToType()
87  if (underlying):
88  self.inspect(underlying.Name(7))
89  elif t.IsArray():
90  if self.debug: print(typename,' is an array')
91  elif t.IsTemplateInstance():
92  if self.debug: print(typename, ' is template')
93  if typename.find('std::')==0:
94  if self.debug: print('std::business removed')
95  try:
96  self.classlist.remove(typename)
97  except Exception:
98  pass
99  for i in range(t.TemplateArgumentSize()):
100  tt = t.TemplateArgumentAt(i)
101  ttname = tt.Name(7)
102  if tt.IsPointer() or tt.IsArray() or tt.IsTypedef():
103  ttname = tt.ToType().Name(7)
104  self.inspect(ttname)
105  elif t.IsClass():
106  if self.debug: print(typename, ' is a class')
107  cname = t.Name(7)
108  if self.debug: print(cname)
109 
110  for i in range(t.DataMemberSize()):
111  d = t.DataMemberAt(i)
112  dname = d.Name()
113  dtype = d.TypeOf().Name(7)
114  if self.debug:
115  print('DataMember: ', dname, ' ', dtype, ' transient=', d.IsTransient())
116  if not d.IsTransient():
117  self.inspect(dtype)
118 
119  else:
120  print('what to do about ', typename,'?')
121  self.problemclasses.append( typename )
122  return
123 
124 
125 

◆ streamers()

def StreamerInfoGenerator.StreamerInfoGenerator.streamers (   self)

Definition at line 126 of file StreamerInfoGenerator.py.

126  def streamers(self):
127  print(self.classlist)
128 
129 

Member Data Documentation

◆ blacklist

StreamerInfoGenerator.StreamerInfoGenerator.blacklist

Definition at line 14 of file StreamerInfoGenerator.py.

◆ classlist

StreamerInfoGenerator.StreamerInfoGenerator.classlist

Definition at line 11 of file StreamerInfoGenerator.py.

◆ debug

StreamerInfoGenerator.StreamerInfoGenerator.debug

Definition at line 9 of file StreamerInfoGenerator.py.

◆ problemclasses

StreamerInfoGenerator.StreamerInfoGenerator.problemclasses

Definition at line 12 of file StreamerInfoGenerator.py.

◆ type

StreamerInfoGenerator.StreamerInfoGenerator.type

Definition at line 15 of file StreamerInfoGenerator.py.


The documentation for this class was generated from the following file:
replace
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition: hcg.cxx:307
vtune_athena.format
format
Definition: vtune_athena.py:14
dumpHVPathFromNtuple.append
bool append
Definition: dumpHVPathFromNtuple.py:91
PixelModuleFeMask_create_db.remove
string remove
Definition: PixelModuleFeMask_create_db.py:83
LArG4FSStartPointFilter.exec
exec
Definition: LArG4FSStartPointFilter.py:103
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
checkTP.inspect
def inspect(self, klassName)
Definition: checkTP.py:126
TCS::join
std::string join(const std::vector< std::string > &v, const char c=',')
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/Root/StringUtils.cxx:10
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
Muon::print
std::string print(const MuPatSegment &)
Definition: MuonTrackSteering.cxx:28