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