| 12 |
int SmartBlindCollection::ApplyCut(PamLevel2 *event) { |
int SmartBlindCollection::ApplyCut(PamLevel2 *event) { |
| 13 |
|
|
| 14 |
_nEv++; |
_nEv++; |
| 15 |
|
|
| 16 |
|
// Execute the actions placed before the cuts |
| 17 |
|
unsigned int iBeforeCuts = 0; |
| 18 |
|
//cout << GetName() << endl; |
| 19 |
|
if (_actions.size() > 0) { |
| 20 |
|
while (_actionsPositions[iBeforeCuts] == -1) { |
| 21 |
|
_actions[iBeforeCuts]->OnGood(event); |
| 22 |
|
iBeforeCuts++; |
| 23 |
|
if (iBeforeCuts == _actions.size()) |
| 24 |
|
break; |
| 25 |
|
} |
| 26 |
|
} |
| 27 |
|
|
| 28 |
|
// Apply the cuts |
| 29 |
if (_cuts.size() == 0) { |
if (_cuts.size() == 0) { |
| 30 |
_nGood++; |
_nGood++; |
| 31 |
OnGood(event); |
OnGood(event); |
| 33 |
} |
} |
| 34 |
|
|
| 35 |
unsigned int firstFailed = _cuts.size(); |
unsigned int firstFailed = _cuts.size(); |
| 36 |
for (unsigned int icut = 0; icut < _cuts.size(); icut++) { |
unsigned int iAction = iBeforeCuts; |
| 37 |
if (_cuts[icut]->ApplyCut(event) != CUTOK && firstFailed == _cuts.size()) { |
for (unsigned int iCut = 0; iCut < _cuts.size(); iCut++) { |
| 38 |
firstFailed = icut; |
if (_cuts[iCut]->ApplyCut(event) != CUTOK && firstFailed == _cuts.size()) { |
| 39 |
|
firstFailed = iCut; |
| 40 |
} |
} |
|
} |
|
| 41 |
|
|
| 42 |
//Do actions |
if (iAction < _actions.size()) { |
| 43 |
if (_actions.size() > 0) { |
if (firstFailed == _cuts.size()) { // No cut has failed yet |
| 44 |
for (unsigned int i = 0; i < _actions.size(); i++) { |
while (_actionsPositions[iAction] == (int) iCut) { |
| 45 |
if (_actionsPositions[i] < (int)firstFailed) |
_actions[iAction]->OnGood(event); |
| 46 |
_actions[i]->OnGood(event); |
iAction++; |
| 47 |
else |
if (iAction == _actions.size()) |
| 48 |
_actions[i]->OnBad(event, firstFailed); |
break; |
| 49 |
|
} |
| 50 |
|
} |
| 51 |
|
else { |
| 52 |
|
while (_actionsPositions[iAction] == (int) iCut) { |
| 53 |
|
_actions[iAction]->OnBad(event, (int) firstFailed); |
| 54 |
|
iAction++; |
| 55 |
|
if (iAction == _actions.size()) |
| 56 |
|
break; |
| 57 |
|
} |
| 58 |
|
} |
| 59 |
|
|
| 60 |
} |
} |
| 61 |
} |
} |
| 62 |
|
|