| The Gaudi Framework v28r2-patches (bc4ad17a)

- 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 216 of file ControlFlow.py.

## Constructor & Destructor Documentation

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

Definition at line 217 of file ControlFlow.py.

217 def __init__(self):
218 self.nodes = []
219 self.edges = []
220 self.number = 0
221 self.stack = []
222 self.ids = {}
223
GaudiConfig.ControlFlow.DotVisitor.stack
stack
Definition: ControlFlow.py:221
GaudiConfig.ControlFlow.DotVisitor.edges
edges
Definition: ControlFlow.py:219
GaudiConfig.ControlFlow.DotVisitor.number
number
Definition: ControlFlow.py:220
GaudiConfig.ControlFlow.DotVisitor.ids
ids
Definition: ControlFlow.py:222
GaudiConfig.ControlFlow.DotVisitor.__init__
def __init__(self)
Definition: ControlFlow.py:217
GaudiConfig.ControlFlow.DotVisitor.nodes
nodes
Definition: ControlFlow.py:218

## 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 259 of file ControlFlow.py.

259 def collapse_identical_ancestors(self, thetype):
260 '''
261 If AND nodes are inside AND nodes, the graph could be simplified
262 to not contain those (same true for OR and ordered)
263 '''
264 counter = 0
265 if len(self.stack) != 0:
266 mother = self.stack[-1][1]
267 for entry in self.stack[::-1]:
268 if type(entry[0]) != thetype:
269 break
270 mother = entry[1]
271 return mother
272 return None
273
GaudiConfig.ControlFlow.DotVisitor.stack
stack
Definition: ControlFlow.py:221
GaudiConfig.ControlFlow.DotVisitor.collapse_identical_ancestors
def collapse_identical_ancestors(self, thetype)
Definition: ControlFlow.py:259
gaudirun.type
type
Definition: gaudirun.py:125

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

Definition at line 224 of file ControlFlow.py.

224 def enter(self, visitee):
225 if visitee not in self.ids:
226 self.number += 1
227 dot_id = self.ids[visitee] = 'T%s' % self.number
228 dot_id = self.ids[visitee]
229 mother = None
230 if self.is_needed(visitee):
231 if isinstance(visitee, ControlFlowLeaf):
232 entry = '%s [label="%s", shape=box]' % (dot_id, visitee.name())
233 elif isinstance(visitee, OrNode):
234 entry = '%s [label="OR", shape=invhouse]' % dot_id
235 elif isinstance(visitee, AndNode):
236 entry = '%s [label="AND", shape=invhouse]' % dot_id
237 elif isinstance(visitee, OrderedNode):
238 entry = '%s [label=">>", shape=point]' % dot_id
239 elif isinstance(visitee, InvertNode):
240 entry = '%s [label="NOT", shape=circle, color=red]' % dot_id
241 elif isinstance(visitee, par):
242 entry = '%s [label="PAR", shape=circle]' % dot_id
243 elif isinstance(visitee, seq):
244 entry = '%s [label="SEQ", shape=circle]' % dot_id
245 else:
246 entry = '%s [label="%s", shape=circle]' % (dot_id, type(visitee))
247 self.nodes.append(entry)
248 if len(self.stack) != 0:
249 mother = self.collapse_identical_ancestors(type(self.stack[-1][0]))
250 if not mother:
251 mother = self.stack[-1][1]
252 edge = "%s->%s" % (dot_id, mother)
253 self.edges.append(edge)
254 self.stack.append((visitee, dot_id))
255
GaudiConfig.ControlFlow.DotVisitor.stack
stack
Definition: ControlFlow.py:221
GaudiConfig.ControlFlow.DotVisitor.number
number
Definition: ControlFlow.py:220
GaudiConfig.ControlFlow.DotVisitor.collapse_identical_ancestors
def collapse_identical_ancestors(self, thetype)
Definition: ControlFlow.py:259
GaudiConfig.ControlFlow.DotVisitor.ids
ids
Definition: ControlFlow.py:222
GaudiConfig.ControlFlow.DotVisitor.enter
def enter(self, visitee)
Definition: ControlFlow.py:224
gaudirun.type
type
Definition: gaudirun.py:125
GaudiConfig.ControlFlow.DotVisitor.is_needed
def is_needed(self, visitee)
Definition: ControlFlow.py:274

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

    Check whether this node is actually needed

Definition at line 274 of file ControlFlow.py.

274 def is_needed(self, visitee):
275 '''
276 Check whether this node is actually needed
277 '''
278 if len(self.stack) != 0:
279 return not isinstance(visitee, type(self.stack[-1][0]))
280 return True
281
GaudiConfig.ControlFlow.DotVisitor.stack
stack
Definition: ControlFlow.py:221
gaudirun.type
type
Definition: gaudirun.py:125
GaudiConfig.ControlFlow.DotVisitor.is_needed
def is_needed(self, visitee)
Definition: ControlFlow.py:274

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

Definition at line 256 of file ControlFlow.py.

256 def leave(self, visitee):
257 self.stack.pop()
258
GaudiConfig.ControlFlow.DotVisitor.leave
def leave(self, visitee)
Definition: ControlFlow.py:256

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

Definition at line 282 of file ControlFlow.py.

282 def write(self, filename):
283 output = """
284 digraph graphname {
285 rankdir=LR
286
287 %s
288
289 %s
290
291 }
292 """ % ("\n".join(self.nodes), "\n".join(self.edges))
293
294 with open(filename, "w") as outfile:
295 outfile.write(output)
296
297
GaudiConfig.ControlFlow.DotVisitor.edges
edges
Definition: ControlFlow.py:219
GaudiConfig.ControlFlow.DotVisitor.write
def write(self, filename)
Definition: ControlFlow.py:282
GaudiConfig.ControlFlow.DotVisitor.nodes
nodes
Definition: ControlFlow.py:218

## Member Data Documentation

GaudiConfig.ControlFlow.DotVisitor.edges

Definition at line 219 of file ControlFlow.py.

GaudiConfig.ControlFlow.DotVisitor.ids

Definition at line 222 of file ControlFlow.py.

GaudiConfig.ControlFlow.DotVisitor.nodes

Definition at line 218 of file ControlFlow.py.

GaudiConfig.ControlFlow.DotVisitor.number

Definition at line 220 of file ControlFlow.py.

GaudiConfig.ControlFlow.DotVisitor.stack

Definition at line 221 of file ControlFlow.py.

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

- GaudiKernel/python/GaudiConfig/ControlFlow.py