CMS 3D CMS Logo

ESRecordsToProxyIndices.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Framework
4 // Class : ESRecordsToProxyIndices
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Author: Chris Jones
10 // Created: Thu Mar 31 14:31:13 EST 2005
11 //
12 
13 // system include files
14 #include <cassert>
15 #include <algorithm>
16 
17 // user include files
19 
20 //
21 // constants, enums and typedefs
22 //
23 
24 namespace edm::eventsetup {
25  ESRecordsToProxyIndices::ESRecordsToProxyIndices(std::vector<EventSetupRecordKey> iRecords)
26  : recordKeys_{std::move(iRecords)} {
27  assert(std::is_sorted(iRecords.begin(), iRecords.end()));
28  recordOffsets_.reserve(recordKeys_.size() + 1);
29  recordOffsets_.push_back(0);
30  }
31 
32  unsigned int ESRecordsToProxyIndices::dataKeysInRecord(unsigned int iRecordIndex,
33  EventSetupRecordKey const& iRecord,
34  std::vector<DataKey> const& iDataKeys,
35  std::vector<ComponentDescription const*> const& iComponents) {
36  assert(iRecord == recordKeys_[iRecordIndex]);
37  assert(iDataKeys.size() == iComponents.size());
38  assert(iRecordIndex + 1 == recordOffsets_.size());
39  dataKeys_.insert(dataKeys_.end(), iDataKeys.begin(), iDataKeys.end());
40  ++iRecordIndex;
41  components_.insert(components_.end(), iComponents.begin(), iComponents.end());
42  recordOffsets_.push_back(dataKeys_.size());
43  return iRecordIndex;
44  }
45 
46  //
47  // const member functions
48  //
50  noexcept {
51  auto it = std::lower_bound(recordKeys_.begin(), recordKeys_.end(), iRK);
52  if (it == recordKeys_.end() or *it != iRK) {
53  return missingProxyIndex();
54  }
55 
56  auto beginOffset = recordOffsets_[std::distance(recordKeys_.begin(), it)];
57  ++it;
58  auto endOffset = recordOffsets_[std::distance(recordKeys_.begin(), it)];
59 
60  auto itDK = std::lower_bound(dataKeys_.begin() + beginOffset, dataKeys_.begin() + endOffset, iDK);
61  if (itDK == dataKeys_.begin() + endOffset or *itDK != iDK) {
62  return missingProxyIndex();
63  }
64 
65  return ESProxyIndex{static_cast<int>(std::distance(dataKeys_.begin() + beginOffset, itDK))};
66  }
67 
69  auto it = std::lower_bound(recordKeys_.begin(), recordKeys_.end(), iRK);
70  if (it == recordKeys_.end() or *it != iRK) {
71  return missingRecordIndex();
72  }
73  return ESRecordIndex{static_cast<ESRecordIndex::Value_t>(it - recordKeys_.begin())};
74  }
75 
77  DataKey const& iDK) const noexcept {
78  auto it = std::lower_bound(recordKeys_.begin(), recordKeys_.end(), iRK);
79  if (it == recordKeys_.end() or *it != iRK) {
80  return nullptr;
81  }
82 
83  auto beginOffset = recordOffsets_[std::distance(recordKeys_.begin(), it)];
84  ++it;
85  auto endOffset = recordOffsets_[std::distance(recordKeys_.begin(), it)];
86 
87  auto itDK = std::lower_bound(dataKeys_.begin() + beginOffset, dataKeys_.begin() + endOffset, iDK);
88  if (itDK == dataKeys_.begin() + endOffset or *itDK != iDK) {
89  return nullptr;
90  }
91  return components_[std::distance(dataKeys_.begin(), itDK)];
92  }
93 
94 } // namespace edm::eventsetup
unsigned int Value_t
Definition: ESIndices.h:81
std::vector< EventSetupRecordKey > recordKeys_
unsigned int dataKeysInRecord(unsigned int iRecordIndex, EventSetupRecordKey const &iRecord, std::vector< DataKey > const &iDataKeys, std::vector< ComponentDescription const * > const &iComponents)
std::vector< ComponentDescription const * > components_
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
ESRecordIndex recordIndexFor(EventSetupRecordKey const &iRK) const noexcept
static constexpr ESProxyIndex missingProxyIndex() noexcept
#define noexcept
ESProxyIndex indexInRecord(EventSetupRecordKey const &iRK, DataKey const &iDK) const noexcept
If the index is not found, returns missingProxyIndex()
ComponentDescription const * component(EventSetupRecordKey const &iRK, DataKey const &iDK) const noexcept
ESRecordsToProxyIndices(std::vector< EventSetupRecordKey > iRecords)
def move(src, dest)
Definition: eostools.py:511
static constexpr ESRecordIndex missingRecordIndex() noexcept