CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
SequenceTypes._MutatingSequenceVisitor Class Reference
Inheritance diagram for SequenceTypes._MutatingSequenceVisitor:
SequenceTypes._CopyAndExcludeSequenceVisitor SequenceTypes._CopyAndRemoveFirstSequenceVisitor SequenceTypes._CopyAndReplaceSequenceVisitor

Public Member Functions

def __init__ (self, operator)
 
def enter (self, visitee)
 
def leave (self, visitee)
 
def result (self, visitedContainer)
 

Private Member Functions

def _didApply (self)
 

Private Attributes

 __didApply
 
 __levelInModifiedNonLeaf
 
 __operator
 
 __stack
 

Detailed Description

Traverses a Sequence and constructs a new sequence by applying the operator to each element of the sequence

Definition at line 1038 of file SequenceTypes.py.

Constructor & Destructor Documentation

def SequenceTypes._MutatingSequenceVisitor.__init__ (   self,
  operator 
)

Definition at line 1088 of file SequenceTypes.py.

1088  def __init__(self,operator):
1089  self.__operator = operator
1090  # You add a list to the __stack when entering any non-Leaf object
1091  # and pop the last element when leaving any non-Leaf object
1092  self.__stack = list()
1093  self.__stack.append(list())
1094  self.__didApply = False
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run

Member Function Documentation

def SequenceTypes._MutatingSequenceVisitor._didApply (   self)
private
def SequenceTypes._MutatingSequenceVisitor.enter (   self,
  visitee 
)

Definition at line 1096 of file SequenceTypes.py.

References SequenceTypes._MutatingSequenceVisitor.__didApply, SequenceTypes._MutatingSequenceVisitor.__levelInModifiedNonLeaf, SequenceTypes._MutatingSequenceVisitor.__operator, SequenceTypes._CopyAndExcludeSequenceVisitorOld.__stack, SequenceTypes._MutatingSequenceVisitor.__stack, mps_setup.append, and list().

1096  def enter(self,visitee):
1097  # Ignore the content of replaced or removed Sequences,
1098  # Tasks, and operators.
1099  if self.__levelInModifiedNonLeaf > 0:
1100  if not visitee.isLeaf():
1101  self.__levelInModifiedNonLeaf += 1
1102  return
1103 
1104  # Just a sanity check
1105  if not len(self.__stack) > 0:
1106  raise RuntimeError("LogicError Empty stack in MutatingSequenceVisitor.\n"
1107  "This should never happen. Contact a Framework developer.")
1108 
1109  # The most important part.
1110  # Apply the operator that might change things, The rest
1111  # of the class is just dealing with side effects of these changes.
1112  v = self.__operator(visitee)
1113 
1114  if v is visitee:
1115  # the operator did not change the visitee
1116  # The 3 element list being appended has the following contents
1117  # element 0 - either the unmodified object, the modified object, or
1118  # a sequence collection when it is a Sequence whose contents have
1119  # been modified.
1120  # element 1 - Indicates whether the object was modified.
1121  # element 2 - None or a list of tasks for a Sequence
1122  # whose contents have been modified.
1123  self.__stack[-1].append([visitee, False, None])
1124  if not visitee.isLeaf():
1125  # need to add a list to keep track of the contents
1126  # of the Sequence, Task, or operator we just entered.
1127  self.__stack.append(list())
1128  else:
1129  # the operator changed the visitee
1130  self.__didApply = True
1131  self.__stack[-1].append([v, True, None])
1132  if not visitee.isLeaf():
1133  # Set flag to indicate modified Sequence, Task, or operator
1134  self.__levelInModifiedNonLeaf = 1
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run
def SequenceTypes._MutatingSequenceVisitor.leave (   self,
  visitee 
)

Definition at line 1135 of file SequenceTypes.py.

References SequenceTypes._MutatingSequenceVisitor.__levelInModifiedNonLeaf, SequenceTypes._CopyAndExcludeSequenceVisitorOld.__stack, SequenceTypes._MutatingSequenceVisitor.__stack, and list().

1135  def leave(self,visitee):
1136 
1137  # nothing to do for leaf types because they do not have contents
1138  if visitee.isLeaf():
1139  return
1140 
1141  # Ignore if this visitee is inside something that was already removed
1142  # or replaced.
1143  if self.__levelInModifiedNonLeaf > 0:
1144  self.__levelInModifiedNonLeaf -= 1
1145  return
1146 
1147  # Deal with visitees which have contents (Sequence, Task, _SequenceIgnore,
1148  # or _SequenceNegation) and although we know the visitee itself did not get
1149  # changed by the operator, the contents of the visitee might have been changed.
1150 
1151  # did any object inside the visitee change?
1152  contents = self.__stack[-1]
1153  changed = False
1154  allNull = True
1155  for c in contents:
1156  if c[1] == True:
1157  changed = True
1158  if c[0] is not None:
1159  allNull = False
1160  if changed:
1161  if allNull:
1162  self.__stack[-2][-1] = [None, True, None]
1163 
1164  elif isinstance(visitee, _UnarySequenceOperator):
1165  node = visitee.__new__(type(visitee))
1166  node.__init__(contents[0][0])
1167  self.__stack[-2][-1] = [node, True, None]
1168 
1169  elif isinstance(visitee, Task):
1170  nonNull = []
1171  for c in contents:
1172  if c[0] is not None:
1173  nonNull.append(c[0])
1174  self.__stack[-2][-1] = [Task(*nonNull), True, None]
1175  elif isinstance(visitee, Sequence):
1176  seq = _SequenceCollection()
1177  tasks = list()
1178  for c in contents:
1179  if c[0] is None:
1180  continue
1181  if isinstance(c[0], Task):
1182  tasks.append(c[0])
1183  else:
1184  seq = seq + c[0]
1185  if c[2] is not None:
1186  tasks.extend(c[2])
1187 
1188  self.__stack[-2][-1] = [seq, True, tasks]
1189 
1190  # When you exit the Sequence, Task, or operator,
1191  # drop the list which holds information about
1192  # its contents.
1193  if not visitee.isLeaf():
1194  self.__stack = self.__stack[:-1]
1195 
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run
def SequenceTypes._MutatingSequenceVisitor.result (   self,
  visitedContainer 
)

Definition at line 1196 of file SequenceTypes.py.

References SequenceTypes._CopyAndExcludeSequenceVisitorOld.__stack, SequenceTypes._MutatingSequenceVisitor.__stack, and list().

1196  def result(self, visitedContainer):
1197 
1198  if isinstance(visitedContainer, Task):
1199  result = list()
1200  for n in (x[0] for x in self.__stack[0]):
1201  if n is not None:
1202  result.append(n)
1203  return result
1204 
1205  seq = _SequenceCollection()
1206  tasks = list()
1207  for c in self.__stack[0]:
1208  if c[0] is None:
1209  continue
1210  if isinstance(c[0], Task):
1211  tasks.append(c[0])
1212  else:
1213  seq = seq + c[0]
1214  if c[2] is not None:
1215  tasks.extend(c[2])
1216  return [seq, tasks]
1217 
def result(self, visitedContainer)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run

Member Data Documentation

SequenceTypes._MutatingSequenceVisitor.__didApply
private
SequenceTypes._MutatingSequenceVisitor.__levelInModifiedNonLeaf
private
SequenceTypes._MutatingSequenceVisitor.__operator
private

Definition at line 1089 of file SequenceTypes.py.

Referenced by SequenceTypes._MutatingSequenceVisitor.enter().

SequenceTypes._MutatingSequenceVisitor.__stack
private