CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
EventSetupTestHelper.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: FWCore/TestProcessor
4 // Class : EventSetupTestHelper
5 //
6 // Implementation:
7 // [Notes on implementation]
8 //
9 // Original Author: root
10 // Created: Tue, 08 May 2018 18:33:15 GMT
11 //
12 
13 // system include files
14 
15 // user include files
18 
19 namespace edm {
20  namespace test {
21 
22  EventSetupTestHelper::EventSetupTestHelper(std::vector<ESProduceEntry> iProxies) : proxies_{std::move(iProxies)} {
23  //Deal with duplicates
24  std::set<eventsetup::EventSetupRecordKey> records;
25  for (auto const& p : proxies_) {
26  records.insert(p.recordKey_);
27  }
28  for (auto const& k : records) {
29  usingRecordWithKey(k);
30  findingRecordWithKey(k);
31  }
32  }
33 
35  const IOVSyncValue& iSync,
36  ValidityInterval& oIOV) {
37  // Note that we manually invalidate the proxies at the end of every call
38  // to test. And the beginning of the call to test is the only opportunity
39  // to reset this data, so we are not relying on the EventSetup system
40  // to manage invalidating the proxies in EventSetupTestHelper. The only
41  // reasonable thing to do is return an interval for all time so the EventSetup
42  // system does not invalidate these proxies when it shouldn't. There are two
43  // weaknesses to this:
44  //
45  // 1. If for the same record type there are DataProxies both managed
46  // by this class and also others managed by the EventSetup, then
47  // at IOV boundaries for this record this will fail. The EventSetup
48  // will invalidate all the proxies for the record after this class
49  // has set the ones it manages and they will stay invalid when they
50  // are needed.
51  //
52  // 2. TestProcessor does not support the special case where the different
53  // transitions executed in one call to test have different IOVs and different
54  // EventSetup data. That would be a pretty strange case, especially for a test.
55 
57  }
58 
60  const eventsetup::EventSetupRecordKey& iRecordKey, unsigned int iovIndex) {
61  KeyedProxiesVector keyedProxiesVector;
62  for (auto const& p : proxies_) {
63  if (p.recordKey_ == iRecordKey) {
64  keyedProxiesVector.emplace_back(p.dataKey_, p.proxy_);
65  }
66  }
67  return keyedProxiesVector;
68  }
69 
70  std::shared_ptr<eventsetup::DataProxy> EventSetupTestHelper::getProxy(unsigned int iIndex) {
71  return proxies_[iIndex].proxy_;
72  }
73 
75  for (auto const& p : proxies_) {
76  p.proxy_->invalidate();
77  }
78  }
79 
80  } // namespace test
81 } // namespace edm
void setIntervalFor(const eventsetup::EventSetupRecordKey &, const IOVSyncValue &, ValidityInterval &) final
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:82
std::pair< Time_t, Time_t > ValidityInterval
Definition: Time.h:17
static const IOVSyncValue & beginOfTime()
Definition: IOVSyncValue.cc:88
def move
Definition: eostools.py:511
KeyedProxiesVector registerProxies(const eventsetup::EventSetupRecordKey &, unsigned int iovIndex) final
EventSetupTestHelper(std::vector< ESProduceEntry >)
std::shared_ptr< eventsetup::DataProxy > getProxy(unsigned int index)
std::vector< std::pair< DataKey, std::shared_ptr< DataProxy >>> KeyedProxiesVector