--- PamCut/Collections/SmartBlindCollection/SmartBlindCollection.cpp 2009/10/27 10:23:59 1.4 +++ PamCut/Collections/SmartBlindCollection/SmartBlindCollection.cpp 2010/07/08 14:00:30 1.5 @@ -12,6 +12,20 @@ int SmartBlindCollection::ApplyCut(PamLevel2 *event) { _nEv++; + + // Execute the actions placed before the cuts + unsigned int iBeforeCuts = 0; + //cout << GetName() << endl; + if (_actions.size() > 0) { + while (_actionsPositions[iBeforeCuts] == -1) { + _actions[iBeforeCuts]->OnGood(event); + iBeforeCuts++; + if (iBeforeCuts == _actions.size()) + break; + } + } + + // Apply the cuts if (_cuts.size() == 0) { _nGood++; OnGood(event); @@ -19,19 +33,30 @@ } unsigned int firstFailed = _cuts.size(); - for (unsigned int icut = 0; icut < _cuts.size(); icut++) { - if (_cuts[icut]->ApplyCut(event) != CUTOK && firstFailed == _cuts.size()) { - firstFailed = icut; + unsigned int iAction = iBeforeCuts; + for (unsigned int iCut = 0; iCut < _cuts.size(); iCut++) { + if (_cuts[iCut]->ApplyCut(event) != CUTOK && firstFailed == _cuts.size()) { + firstFailed = iCut; } - } - //Do actions - if (_actions.size() > 0) { - for (unsigned int i = 0; i < _actions.size(); i++) { - if (_actionsPositions[i] < (int)firstFailed) - _actions[i]->OnGood(event); - else - _actions[i]->OnBad(event, firstFailed); + if (iAction < _actions.size()) { + if (firstFailed == _cuts.size()) { // No cut has failed yet + while (_actionsPositions[iAction] == (int) iCut) { + _actions[iAction]->OnGood(event); + iAction++; + if (iAction == _actions.size()) + break; + } + } + else { + while (_actionsPositions[iAction] == (int) iCut) { + _actions[iAction]->OnBad(event, (int) firstFailed); + iAction++; + if (iAction == _actions.size()) + break; + } + } + } }