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 
46  ESWatcher(const ESWatcher&) = delete; // stop default
47 
48  const ESWatcher& operator=(const ESWatcher&) = delete; // stop default
49 
50  //virtual ~ESWatcher();
51 
52  // ---------- const member functions ---------------------
53 
54  // ---------- static member functions --------------------
55 
56  // ---------- member functions ---------------------------
57  bool check(const edm::EventSetup& iSetup) {
58  const T& record = iSetup.template get<T>();
59  bool result = cacheId_ != record.cacheIdentifier();
60  if (result) {
62  }
63  cacheId_ = record.cacheIdentifier();
64  return result;
65  }
66 
67  private:
68  // ---------- member data --------------------------------
69  std::function<void(const T&)> callback_;
70  unsigned long long cacheId_;
71  };
72 } // namespace edm
73 
74 #endif
const ESWatcher & operator=(const ESWatcher &)=delete
ESWatcher(TFunc iFunctor)
Definition: ESWatcher.h:40
ESWatcher(TObj const &iObj, TMemFunc iFunc)
Definition: ESWatcher.h:43
unsigned long long cacheId_
Definition: ESWatcher.h:70
std::function< void(const T &)> callback_
Definition: ESWatcher.h:69
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
HLT enums.
void operator()(const T &)
Definition: ESWatcher.h:34
long double T