CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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(IterateNTimesLooper const&) = delete; // stop default
26  IterateNTimesLooper const& operator=(IterateNTimesLooper const&) = delete; // stop default
27  ~IterateNTimesLooper() override;
28 
29  // ---------- const member functions ---------------------
30 
31  // ---------- static member functions --------------------
32 
33  // ---------- member functions ---------------------------
34  void startingNewLoop(unsigned int) override;
35  Status duringLoop(Event const&, EventSetup const&) override;
36  Status endOfLoop(EventSetup const&, unsigned int) override;
37 
38  private:
39  // ---------- member data --------------------------------
40  unsigned int max_;
41  unsigned int times_;
43  };
44 
45  //
46  //
47  // constructors and destructor
48  //
50  : max_(iConfig.getParameter<unsigned int>("nTimes")), times_(0), shouldStop_(false) {}
51 
52  // IterateNTimesLooper::IterateNTimesLooper(IterateNTimesLooper const& rhs) {
53  // // do actual copying here;
54  // }
55 
57 
58  //
59  // assignment operators
60  //
61  // IterateNTimesLooper const& IterateNTimesLooper::operator=(IterateNTimesLooper const& rhs) {
62  // //An exception safe implementation is
63  // IterateNTimesLooper temp(rhs);
64  // swap(rhs);
65  //
66  // return *this;
67  // }
68 
69  //
70  // member functions
71  //
72  void IterateNTimesLooper::startingNewLoop(unsigned int iIteration) {
73  times_ = iIteration;
74  if (iIteration >= max_) {
75  shouldStop_ = true;
76  }
77  }
78 
80  return shouldStop_ ? kStop : kContinue;
81  }
82 
83  EDLooper::Status IterateNTimesLooper::endOfLoop(EventSetup const&, unsigned int /*iCounter*/) {
84  ++times_;
85  return (times_ < max_) ? kContinue : kStop;
86  }
87 } // namespace edm
88 
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
IterateNTimesLooper const & operator=(IterateNTimesLooper const &)=delete