CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 <boost/bind.hpp>
23 #include <boost/function.hpp>
24 
25 // user include files
27 
28 // forward declarations
29 
30 namespace edm {
31  template <class T>
32  class ESWatcher
33  {
34 
35  public:
36 
37  struct NullFunction {
38  void operator()(const T& ) {}
39  };
40 
41  ESWatcher() :callback_(NullFunction()), cacheId_(0) {}
42 
43  template <class TFunc>
44  ESWatcher(TFunc iFunctor):callback_(iFunctor),cacheId_(0) {}
45 
46  template <class TObj, class TMemFunc>
47  ESWatcher(TObj const& iObj, TMemFunc iFunc):
48  callback_(boost::bind(iFunc,iObj,_1)),
49  cacheId_(0)
50  {}
51  //virtual ~ESWatcher();
52 
53  // ---------- const member functions ---------------------
54 
55  // ---------- static member functions --------------------
56 
57  // ---------- member functions ---------------------------
58  bool check(const edm::EventSetup& iSetup) {
59  const T& record = iSetup.template get<T>();
60  bool result = cacheId_ != record.cacheIdentifier();
61  if(result) {
62  callback_(record);
63  }
64  cacheId_ = record.cacheIdentifier();
65  return result;
66  }
67  private:
68  ESWatcher(const ESWatcher&); // stop default
69 
70  const ESWatcher& operator=(const ESWatcher&); // stop default
71 
72  // ---------- member data --------------------------------
73  boost::function<void (const T&)> callback_;
74  unsigned long long cacheId_;
75 };
76 }
77 
78 #endif
boost::function< void(const T &)> callback_
Definition: ESWatcher.h:73
ESWatcher(TFunc iFunctor)
Definition: ESWatcher.h:44
ESWatcher(TObj const &iObj, TMemFunc iFunc)
Definition: ESWatcher.h:47
unsigned long long cacheId_
Definition: ESWatcher.h:74
tuple result
Definition: query.py:137
const ESWatcher & operator=(const ESWatcher &)
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:58
void operator()(const T &)
Definition: ESWatcher.h:38
long double T