CMS 3D CMS Logo

IterateNTimesLooper.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Modules
4 // Class : IterateNTimesLooper
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author: Chris Jones
10 // Created: Tue Jul 11 11:16:14 EDT 2006
11 //
12 
13 // system include files
14 
15 // user include files
19 
20 namespace edm {
21 
22  class IterateNTimesLooper : public EDLooper {
23  public:
25  ~IterateNTimesLooper() override;
26 
27  // ---------- const member functions ---------------------
28 
29  // ---------- static member functions --------------------
30 
31  // ---------- member functions ---------------------------
32  void startingNewLoop(unsigned int) override;
33  Status duringLoop(Event const&, EventSetup const&) override;
34  Status endOfLoop(EventSetup const&, unsigned int) override;
35 
36  private:
37  IterateNTimesLooper(IterateNTimesLooper const&) = delete; // stop default
38 
39  IterateNTimesLooper const& operator=(IterateNTimesLooper const&) = delete; // stop default
40 
41  // ---------- member data --------------------------------
42  unsigned int max_;
43  unsigned int times_;
45  };
46 
47  //
48  //
49  // constructors and destructor
50  //
52  : max_(iConfig.getParameter<unsigned int>("nTimes")), times_(0), shouldStop_(false) {}
53 
54  // IterateNTimesLooper::IterateNTimesLooper(IterateNTimesLooper const& rhs) {
55  // // do actual copying here;
56  // }
57 
59 
60  //
61  // assignment operators
62  //
63  // IterateNTimesLooper const& IterateNTimesLooper::operator=(IterateNTimesLooper const& rhs) {
64  // //An exception safe implementation is
65  // IterateNTimesLooper temp(rhs);
66  // swap(rhs);
67  //
68  // return *this;
69  // }
70 
71  //
72  // member functions
73  //
74  void IterateNTimesLooper::startingNewLoop(unsigned int iIteration) {
75  times_ = iIteration;
76  if (iIteration >= max_) {
77  shouldStop_ = true;
78  }
79  }
80 
82  return shouldStop_ ? kStop : kContinue;
83  }
84 
85  EDLooper::Status IterateNTimesLooper::endOfLoop(EventSetup const&, unsigned int /*iCounter*/) {
86  ++times_;
87  return (times_ < max_) ? kContinue : kStop;
88  }
89 } // namespace edm
90 
void startingNewLoop(unsigned int) override
IterateNTimesLooper(ParameterSet const &)
#define DEFINE_FWK_LOOPER(type)
Status duringLoop(Event const &, EventSetup const &) override
Status endOfLoop(EventSetup const &, unsigned int) override
HLT enums.
IterateNTimesLooper const & operator=(IterateNTimesLooper const &)=delete