/[PAMELA software]/PamCut/Collections/SmartBlindCollection/SmartBlindCollection.cpp
ViewVC logotype

Diff of /PamCut/Collections/SmartBlindCollection/SmartBlindCollection.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by pam-fi, Fri May 29 10:08:46 2009 UTC revision 1.4.2.1 by pam-fi, Mon Jun 7 11:16:52 2010 UTC
# Line 5  Line 5 
5   *      Author: Nicola Mori   *      Author: Nicola Mori
6   */   */
7    
8  /*! @file SmartCollection.cpp The SmartCollection class implementation file */  /*! @file SmartCollection.cpp The SmartBlindCollection class implementation file */
9    
10  #include "SmartBlindCollection.h"  #include "SmartBlindCollection.h"
11    
12  void SmartBlindCollection::AddAction(CollectionAction& action) {  int SmartBlindCollection::ApplyCut(PamLevel2 *event) {
   _actions.push_back(&action);  
 }  
   
 CollectionAction *SmartBlindCollection::GetAction(unsigned int iAction) {  
   if (_actions.size() == 0)  
     return NULL;  
   if (iAction < 0 || iAction > _actions.size() - 1)  
     return NULL;  
   else  
     return _actions[iAction];  
 }  
13    
14  void SmartBlindCollection::Setup(PamLevel2 *events){    _nEv++;
   BlindCutCollection::Setup(events);  
15    
16    for (unsigned int i = 0; i < _actions.size(); i++){    // Execute the actions placed before the cuts
17      _actions[i]->Setup(events);    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    }    }
 }  
   
 void SmartBlindCollection::Finalize(){  
   BlindCutCollection::Finalize();  
27    
28    for (unsigned int i = 0; i < _actions.size(); i++){    // Apply the cuts
29      _actions[i]->Finalize();    if (_cuts.size() == 0) {
30        _nGood++;
31        OnGood(event);
32        return CUTOK;
33    }    }
 }  
34    
35  void SmartBlindCollection::OnGood(PamLevel2 *event){    unsigned int firstFailed = _cuts.size();
36    BlindCutCollection::OnGood(event);    unsigned int iAction = iBeforeCuts;
37      for (unsigned int iCut = 0; iCut < _cuts.size(); iCut++) {
38        if (_cuts[iCut]->ApplyCut(event) != CUTOK && firstFailed == _cuts.size()) {
39          firstFailed = iCut;
40        }
41    
42        if (iAction < _actions.size()) {
43          if (firstFailed == _cuts.size()) { // No cut has failed yet
44            while (_actionsPositions[iAction] == (int) iCut) {
45              _actions[iAction]->OnGood(event);
46              iAction++;
47              if (iAction == _actions.size())
48                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    for (unsigned int i = 0; i < _actions.size(); i++){      }
     _actions[i]->OnGood(event);  
61    }    }
 }  
   
 void SmartBlindCollection::OnBad(PamLevel2 *event, int selectionResult){  
   BlindCutCollection::OnBad(event, selectionResult);  
62    
63    for (unsigned int i = 0; i < _actions.size(); i++){    if (firstFailed == _cuts.size()) {
64      _actions[i]->OnBad(event, selectionResult);      _nGood++;
65        OnGood(event);
66        return CUTOK;
67    }    }
68      else {
69        OnBad(event, firstFailed);
70        return firstFailed;
71      }
72    
73  }  }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.4.2.1

  ViewVC Help
Powered by ViewVC 1.1.23