| The Gaudi Framework v29r1 (5cd95fa2)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Public Attributes | List of all members
GaudiConfig.ControlFlow.DotVisitor Class Reference
Inheritance diagram for GaudiConfig.ControlFlow.DotVisitor:
[legend]
Collaboration diagram for GaudiConfig.ControlFlow.DotVisitor:
[legend]

## Public Member Functions
def | __init__ (self)
def | enter (self, visitee)
def | leave (self, visitee)
def | collapse_identical_ancestors (self, thetype)
def | is_needed (self, visitee)
def | write (self, filename)

## Public Attributes
| nodes
| edges
| number
| stack
| ids

## Detailed Description

Definition at line 228 of file ControlFlow.py.

## Constructor & Destructor Documentation

def GaudiConfig.ControlFlow.DotVisitor.__init__ | ( |  | self | ) |

Definition at line 229 of file ControlFlow.py.

229 def __init__(self):
230 self.nodes = []
231 self.edges = []
232 self.number = 0
233 self.stack = []
234 self.ids = {}
235
GaudiConfig.ControlFlow.DotVisitor.stack
stack
Definition: ControlFlow.py:233
GaudiConfig.ControlFlow.DotVisitor.edges
edges
Definition: ControlFlow.py:231
GaudiConfig.ControlFlow.DotVisitor.number
number
Definition: ControlFlow.py:232
GaudiConfig.ControlFlow.DotVisitor.ids
ids
Definition: ControlFlow.py:234
GaudiConfig.ControlFlow.DotVisitor.__init__
def __init__(self)
Definition: ControlFlow.py:229
GaudiConfig.ControlFlow.DotVisitor.nodes
nodes
Definition: ControlFlow.py:230

## Member Function Documentation

def GaudiConfig.ControlFlow.DotVisitor.collapse_identical_ancestors | ( |  | self,
|  |  | thetype
| ) |  |

    If AND nodes are inside AND nodes, the graph could be simplified
    to not contain those (same true for OR and ordered)

Definition at line 273 of file ControlFlow.py.

273 def collapse_identical_ancestors(self, thetype):
274 '''
275 If AND nodes are inside AND nodes, the graph could be simplified
276 to not contain those (same true for OR and ordered)
277 '''
278 counter = 0
279 if len(self.stack) != 0:
280 mother = self.stack[-1][1]
281 for entry in self.stack[::-1]:
282 if type(entry[0]) != thetype:
283 break
284 mother = entry[1]
285 return mother
286 return None
287
GaudiConfig.ControlFlow.DotVisitor.stack
stack
Definition: ControlFlow.py:233
GaudiConfig.ControlFlow.DotVisitor.collapse_identical_ancestors
def collapse_identical_ancestors(self, thetype)
Definition: ControlFlow.py:273
gaudirun.type
type
Definition: gaudirun.py:133

def GaudiConfig.ControlFlow.DotVisitor.enter | ( |  | self,
|  |  | visitee
| ) |  |

Definition at line 236 of file ControlFlow.py.

236 def enter(self, visitee):
237 if visitee not in self.ids:
238 self.number += 1
239 dot_id = self.ids[visitee] = 'T%s' % self.number
240 dot_id = self.ids[visitee]
241 mother = None
242 if self.is_needed(visitee):
243 if isinstance(visitee, ControlFlowLeaf):
244 entry = '%s [label="%s", shape=box]' % (dot_id, visitee.name())
245 elif isinstance(visitee, OrNode):
246 entry = '%s [label="OR", shape=invhouse]' % dot_id
247 elif isinstance(visitee, AndNode):
248 entry = '%s [label="AND", shape=invhouse]' % dot_id
249 elif isinstance(visitee, OrderedNode):
250 entry = '%s [label=">>", shape=point]' % dot_id
251 elif isinstance(visitee, InvertNode):
252 entry = '%s [label="NOT", shape=circle, color=red]' % dot_id
253 elif isinstance(visitee, par):
254 entry = '%s [label="PAR", shape=circle]' % dot_id
255 elif isinstance(visitee, seq):
256 entry = '%s [label="SEQ", shape=circle]' % dot_id
257 else:
258 entry = '%s [label="%s", shape=circle]' % (
259 dot_id, type(visitee))
260 self.nodes.append(entry)
261 if len(self.stack) != 0:
262 mother = self.collapse_identical_ancestors(
263 type(self.stack[-1][0]))
264 if not mother:
265 mother = self.stack[-1][1]
266 edge = "%s->%s" % (dot_id, mother)
267 self.edges.append(edge)
268 self.stack.append((visitee, dot_id))
269
GaudiConfig.ControlFlow.DotVisitor.stack
stack
Definition: ControlFlow.py:233
GaudiConfig.ControlFlow.DotVisitor.number
number
Definition: ControlFlow.py:232
GaudiConfig.ControlFlow.DotVisitor.collapse_identical_ancestors
def collapse_identical_ancestors(self, thetype)
Definition: ControlFlow.py:273
GaudiConfig.ControlFlow.DotVisitor.ids
ids
Definition: ControlFlow.py:234
GaudiConfig.ControlFlow.DotVisitor.enter
def enter(self, visitee)
Definition: ControlFlow.py:236
gaudirun.type
type
Definition: gaudirun.py:133
GaudiConfig.ControlFlow.DotVisitor.is_needed
def is_needed(self, visitee)
Definition: ControlFlow.py:288

def GaudiConfig.ControlFlow.DotVisitor.is_needed | ( |  | self,
|  |  | visitee
| ) |  |

    Check whether this node is actually needed

Definition at line 288 of file ControlFlow.py.

288 def is_needed(self, visitee):
289 '''
290 Check whether this node is actually needed
291 '''
292 if len(self.stack) != 0:
293 return not isinstance(visitee, type(self.stack[-1][0]))
294 return True
295
GaudiConfig.ControlFlow.DotVisitor.stack
stack
Definition: ControlFlow.py:233
gaudirun.type
type
Definition: gaudirun.py:133
GaudiConfig.ControlFlow.DotVisitor.is_needed
def is_needed(self, visitee)
Definition: ControlFlow.py:288

def GaudiConfig.ControlFlow.DotVisitor.leave | ( |  | self,
|  |  | visitee
| ) |  |

Definition at line 270 of file ControlFlow.py.

270 def leave(self, visitee):
271 self.stack.pop()
272
GaudiConfig.ControlFlow.DotVisitor.leave
def leave(self, visitee)
Definition: ControlFlow.py:270

def GaudiConfig.ControlFlow.DotVisitor.write | ( |  | self,
|  |  | filename
| ) |  |

Definition at line 296 of file ControlFlow.py.

296 def write(self, filename):
297 output = """
298 digraph graphname {
299 rankdir=LR
300
301 %s
302
303 %s
304
305 }
306 """ % ("\n".join(self.nodes), "\n".join(self.edges))
307
308 with open(filename, "w") as outfile:
309 outfile.write(output)
310
311
GaudiConfig.ControlFlow.DotVisitor.edges
edges
Definition: ControlFlow.py:231
GaudiConfig.ControlFlow.DotVisitor.write
def write(self, filename)
Definition: ControlFlow.py:296
GaudiConfig.ControlFlow.DotVisitor.nodes
nodes
Definition: ControlFlow.py:230

## Member Data Documentation

GaudiConfig.ControlFlow.DotVisitor.edges

Definition at line 231 of file ControlFlow.py.

GaudiConfig.ControlFlow.DotVisitor.ids

Definition at line 234 of file ControlFlow.py.

GaudiConfig.ControlFlow.DotVisitor.nodes

Definition at line 230 of file ControlFlow.py.

GaudiConfig.ControlFlow.DotVisitor.number

Definition at line 232 of file ControlFlow.py.

GaudiConfig.ControlFlow.DotVisitor.stack

Definition at line 233 of file ControlFlow.py.

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

- GaudiKernel/python/GaudiConfig/ControlFlow.py