CMS 3D CMS Logo

EventSetupImpl.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Framework
4 // Module: EventSetup
5 //
6 // Description: <one line class summary>
7 //
8 // Implementation:
9 // <Notes on implementation>
10 //
11 // Author: Chris Jones
12 // Created: Thu Mar 24 16:27:10 EST 2005
13 //
14 
15 // system include files
16 #include <algorithm>
17 
18 // user include files
23 
24 namespace edm {
25 
26  EventSetupImpl::EventSetupImpl(ActivityRegistry const* activityRegistry) : activityRegistry_(activityRegistry) {}
27 
29 
31  const eventsetup::EventSetupRecordImpl* iRecord) {
32  auto lb = std::lower_bound(keysBegin_, keysEnd_, iKey);
33  if (lb == keysEnd_ || iKey != *lb) {
34  throw cms::Exception("LogicError") << "EventSetupImpl::insert Could not find key\n"
35  << "Should be impossible. Please contact Framework developer.\n";
36  }
37  auto index = std::distance(keysBegin_, lb);
38  recordImpls_[index] = iRecord;
39  }
40 
42  for (auto& ptr : recordImpls_) {
43  ptr = nullptr;
44  }
45  }
46 
47  void EventSetupImpl::add(const eventsetup::EventSetupRecordImpl& iRecord) { insert(iRecord.key(), &iRecord); }
48 
49  std::optional<eventsetup::EventSetupRecordGeneric> EventSetupImpl::find(const eventsetup::EventSetupRecordKey& iKey,
50  unsigned int iTransitionID,
51  ESProxyIndex const* getTokenIndices) const {
52  auto lb = std::lower_bound(keysBegin_, keysEnd_, iKey);
53  if (lb == keysEnd_ || iKey != *lb) {
54  return std::nullopt;
55  }
56  auto index = std::distance(keysBegin_, lb);
57  if (recordImpls_[index] == nullptr) {
58  return std::nullopt;
59  }
60  return eventsetup::EventSetupRecordGeneric(recordImpls_[index], iTransitionID, getTokenIndices);
61  }
62 
64  auto lb = std::lower_bound(keysBegin_, keysEnd_, iKey);
65  if (lb == keysEnd_ || iKey != *lb) {
66  return nullptr;
67  }
68  auto index = std::distance(keysBegin_, lb);
69  return recordImpls_[index];
70  }
71 
72  void EventSetupImpl::fillAvailableRecordKeys(std::vector<eventsetup::EventSetupRecordKey>& oToFill) const {
73  oToFill.clear();
74  oToFill.reserve(recordImpls_.size());
75 
76  for (auto const& recordImpl : recordImpls_) {
77  if (recordImpl != nullptr) {
78  oToFill.push_back(recordImpl->key());
79  }
80  }
81  }
82 
84  auto lb = std::lower_bound(keysBegin_, keysEnd_, iKey);
85  return lb != keysEnd_ && iKey == *lb;
86  }
87 
88  void EventSetupImpl::setKeyIters(std::vector<eventsetup::EventSetupRecordKey>::const_iterator const& keysBegin,
89  std::vector<eventsetup::EventSetupRecordKey>::const_iterator const& keysEnd) {
90  keysBegin_ = keysBegin;
91  keysEnd_ = keysEnd;
92  recordImpls_.resize(keysEnd_ - keysBegin_, nullptr);
93  }
94 
95 } // namespace edm
ActivityRegistry const * activityRegistry_
Definition: DataProxy.cc:118
void insert(const eventsetup::EventSetupRecordKey &, const eventsetup::EventSetupRecordImpl *)
std::vector< eventsetup::EventSetupRecordKey >::const_iterator keysBegin_
void setKeyIters(std::vector< eventsetup::EventSetupRecordKey >::const_iterator const &keysBegin, std::vector< eventsetup::EventSetupRecordKey >::const_iterator const &keysEnd)
std::vector< eventsetup::EventSetupRecordKey >::const_iterator keysEnd_
bool recordIsProvidedByAModule(eventsetup::EventSetupRecordKey const &) const
void fillAvailableRecordKeys(std::vector< eventsetup::EventSetupRecordKey > &oToFill) const
clears the oToFill vector and then fills it with the keys for all available records ...
EventSetupImpl(EventSetupImpl const &)=delete
eventsetup::EventSetupRecordImpl const * findImpl(const eventsetup::EventSetupRecordKey &) const
void add(const eventsetup::EventSetupRecordImpl &iRecord)
std::optional< eventsetup::EventSetupRecordGeneric > find(const eventsetup::EventSetupRecordKey &, unsigned int iTransitionID, ESProxyIndex const *getTokenIndices) const
HLT enums.
std::vector< eventsetup::EventSetupRecordImpl const * > recordImpls_
EventSetupRecordKey const & key() const