CMS 3D CMS Logo

ESWatcher.h
Go to the documentation of this file.
1 #ifndef Framework_ESWatcher_h
2 #define Framework_ESWatcher_h
3 // -*- C++ -*-
4 //
5 // Package: Framework
6 // Class : ESWatcher
7 //
16 //
17 // Original Author: Chris Jones
18 // Created: Fri Sep 22 18:19:24 EDT 2006
19 //
20 
21 // system include files
22 #include <functional>
23 
24 // user include files
26 
27 // forward declarations
28 
29 namespace edm {
30  template <class T>
31  class ESWatcher {
32  public:
33  struct NullFunction {
34  void operator()(const T&) {}
35  };
36 
37  ESWatcher() : callback_(NullFunction()), cacheId_(0) {}
38 
39  template <class TFunc>
40  ESWatcher(TFunc iFunctor) : callback_(iFunctor), cacheId_(0) {}
41 
42  template <class TObj, class TMemFunc>
43  ESWatcher(TObj const& iObj, TMemFunc iFunc)
44  : callback_(std::bind(iFunc, iObj, std::placeholders::_1)), cacheId_(0) {}
45  //virtual ~ESWatcher();
46 
47  // ---------- const member functions ---------------------
48 
49  // ---------- static member functions --------------------
50 
51  // ---------- member functions ---------------------------
52  bool check(const edm::EventSetup& iSetup) {
53  const T& record = iSetup.template get<T>();
54  bool result = cacheId_ != record.cacheIdentifier();
55  if (result) {
56  callback_(record);
57  }
58  cacheId_ = record.cacheIdentifier();
59  return result;
60  }
61 
62  private:
63  ESWatcher(const ESWatcher&) = delete; // stop default
64 
65  const ESWatcher& operator=(const ESWatcher&) = delete; // stop default
66 
67  // ---------- member data --------------------------------
68  std::function<void(const T&)> callback_;
69  unsigned long long cacheId_;
70  };
71 } // namespace edm
72 
73 #endif
const ESWatcher & operator=(const ESWatcher &)=delete
JetCorrectorParameters::Record record
Definition: classes.h:7
ESWatcher(TFunc iFunctor)
Definition: ESWatcher.h:40
ESWatcher(TObj const &iObj, TMemFunc iFunc)
Definition: ESWatcher.h:43
unsigned long long cacheId_
Definition: ESWatcher.h:69
std::function< void(const T &)> callback_
Definition: ESWatcher.h:68
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:52
HLT enums.
void operator()(const T &)
Definition: ESWatcher.h:34
long double T