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) {
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 --------------------------------
69  unsigned long long cacheId_;
70  };
71 } // namespace edm
72 
73 #endif
edm::ESWatcher::check
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:52
edm::ESWatcher::ESWatcher
ESWatcher(TFunc iFunctor)
Definition: ESWatcher.h:40
edm::ESWatcher
Definition: ESWatcher.h:31
edm
HLT enums.
Definition: AlignableModifier.h:19
GlobalPosition_Frontier_DevDB_cff.record
record
Definition: GlobalPosition_Frontier_DevDB_cff.py:10
edm::ESWatcher::NullFunction::operator()
void operator()(const T &)
Definition: ESWatcher.h:34
edm::ESWatcher::ESWatcher
ESWatcher()
Definition: ESWatcher.h:37
edm::ESWatcher::NullFunction
Definition: ESWatcher.h:33
edm::ESWatcher::ESWatcher
ESWatcher(TObj const &iObj, TMemFunc iFunc)
Definition: ESWatcher.h:43
edm::EventSetup
Definition: EventSetup.h:57
std
Definition: JetResolutionObject.h:76
T
long double T
Definition: Basic3DVectorLD.h:48
edm::ESWatcher::callback_
std::function< void(const T &)> callback_
Definition: ESWatcher.h:68
HiBiasedCentrality_cfi.function
function
Definition: HiBiasedCentrality_cfi.py:4
EventSetup.h
edm::ESWatcher::operator=
const ESWatcher & operator=(const ESWatcher &)=delete
funct::void
TEMPL(T2) struct Divides void
Definition: Factorize.h:29
mps_fire.result
result
Definition: mps_fire.py:303
edm::ESWatcher::cacheId_
unsigned long long cacheId_
Definition: ESWatcher.h:69