CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DataProxy.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Framework
4 // Class : DataProxy
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Author: Chris Jones
10 // Created: Thu Mar 31 12:49:19 EST 2005
11 //
12 
13 // system include files
14 
15 // user include files
20 
21 
22 //
23 // constants, enums and typedefs
24 //
25 namespace edm {
26  namespace eventsetup {
27 //
28 // static data member definitions
29 //
30 static
31 const ComponentDescription*
33 {
34  static ComponentDescription s_desc;
35  return &s_desc;
36 }
37 //
38 // constructors and destructor
39 //
41  cache_(nullptr),
42  cacheIsValid_(false),
43  nonTransientAccessRequested_(false),
44  description_(dummyDescription())
45 {
46 }
47 
48 // DataProxy::DataProxy(const DataProxy& rhs)
49 // {
50 // // do actual copying here;
51 // }
52 
54 {
55 }
56 
57 //
58 // assignment operators
59 //
60 // const DataProxy& DataProxy::operator=(const DataProxy& rhs)
61 // {
62 // //An exception safe implementation is
63 // DataProxy temp(rhs);
64 // swap(rhs);
65 //
66 // return *this;
67 // }
68 
69 //
70 // member functions
71 //
72 void
73 DataProxy::setCacheIsValidAndAccessType(bool iTransientAccessOnly) const {
74  cacheIsValid_ = true;
75  if(!iTransientAccessOnly) {
77  }
78 }
79 
81  cacheIsValid_ = false;
83  cache_ = 0;
84 }
85 
86 void
91  }
92 }
93 
94 void
97 }
98 //
99 // const member functions
100 //
101 namespace {
102  void throwMakeException(const EventSetupRecord& iRecord,
103  const DataKey& iKey) {
104  throw MakeDataException(iRecord.key(),iKey);
105  }
106 }
107 
108 
109 const void*
110 DataProxy::get(const EventSetupRecord& iRecord, const DataKey& iKey, bool iTransiently) const
111 {
112  if(!cacheIsValid()) {
113  cache_ = const_cast<DataProxy*>(this)->getImpl(iRecord, iKey);
114  }
115  //It is safe to always set cache to valid.
116  //We need to set the AccessType for each request so this can't be called in the if block above.
117  //This also must be before the cache_ check since we want to setCacheIsValid before a possible
118  // exception throw. If we don't, 'getImpl' will be called again on a second request for the data.
119  setCacheIsValidAndAccessType(iTransiently);
120  if(0 == cache_) {
121  throwMakeException(iRecord, iKey);
122  }
123  return cache_;
124 }
125 
126 void DataProxy::doGet(const EventSetupRecord& iRecord, const DataKey& iKey, bool iTransiently) const {
127  get(iRecord, iKey, iTransiently);
128 }
129 
130 
131 //
132 // static member functions
133 //
134  }
135 }
bool cacheIsValid() const
Definition: DataProxy.h:40
virtual EventSetupRecordKey key() const =0
#define nullptr
virtual void invalidateTransientCache()
Definition: DataProxy.cc:95
void const * get(EventSetupRecord const &, DataKey const &iKey, bool iTransiently) const
Definition: DataProxy.cc:110
void setCacheIsValidAndAccessType(bool iTransientAccessOnly) const
Definition: DataProxy.cc:73
void doGet(EventSetupRecord const &iRecord, DataKey const &iKey, bool iTransiently) const
Definition: DataProxy.cc:126
volatile std::atomic< bool > shutdown_flag false
static const ComponentDescription * dummyDescription()
Definition: DataProxy.cc:32
virtual void invalidateCache()=0
virtual void const * getImpl(EventSetupRecord const &, DataKey const &iKey)=0