1 |
pam-fi |
1.1 |
/* |
2 |
|
|
* SmartBlindCollection.cpp |
3 |
|
|
* |
4 |
|
|
* Created on: 16-mag-2009 |
5 |
|
|
* Author: Nicola Mori |
6 |
|
|
*/ |
7 |
|
|
|
8 |
pam-fi |
1.2 |
/*! @file SmartCollection.cpp The SmartBlindCollection class implementation file */ |
9 |
pam-fi |
1.1 |
|
10 |
|
|
#include "SmartBlindCollection.h" |
11 |
|
|
|
12 |
pam-fi |
1.2 |
int SmartBlindCollection::ApplyCut(PamLevel2 *event) { |
13 |
pam-fi |
1.1 |
|
14 |
pam-fi |
1.2 |
_nEv++; |
15 |
|
|
if (_cuts.size() == 0) { |
16 |
|
|
_nGood++; |
17 |
|
|
OnGood(event); |
18 |
|
|
return CUTOK; |
19 |
|
|
} |
20 |
pam-fi |
1.1 |
|
21 |
pam-fi |
1.3 |
unsigned int firstFailed = _cuts.size(); |
22 |
pam-fi |
1.2 |
for (unsigned int icut = 0; icut < _cuts.size(); icut++) { |
23 |
pam-fi |
1.3 |
if (_cuts[icut]->ApplyCut(event) != CUTOK && firstFailed == _cuts.size()) { |
24 |
pam-fi |
1.2 |
firstFailed = icut; |
25 |
|
|
} |
26 |
pam-fi |
1.3 |
} |
27 |
pam-fi |
1.2 |
|
28 |
pam-fi |
1.3 |
//Do actions |
29 |
|
|
if (_actions.size() > 0) { |
30 |
|
|
for (unsigned int i = 0; i < _actions.size(); i++) { |
31 |
pam-fi |
1.4 |
if (_actionsPositions[i] < (int)firstFailed) |
32 |
pam-fi |
1.3 |
_actions[i]->OnGood(event); |
33 |
|
|
else |
34 |
|
|
_actions[i]->OnBad(event, firstFailed); |
35 |
pam-fi |
1.2 |
} |
36 |
pam-fi |
1.1 |
} |
37 |
|
|
|
38 |
pam-fi |
1.3 |
if (firstFailed == _cuts.size()) { |
39 |
pam-fi |
1.2 |
_nGood++; |
40 |
|
|
OnGood(event); |
41 |
pam-fi |
1.3 |
return CUTOK; |
42 |
pam-fi |
1.1 |
} |
43 |
pam-fi |
1.2 |
else { |
44 |
|
|
OnBad(event, firstFailed); |
45 |
pam-fi |
1.3 |
return firstFailed; |
46 |
pam-fi |
1.1 |
} |
47 |
|
|
|
48 |
|
|
} |