CMS 3D CMS Logo

DataProxyProvider.h
Go to the documentation of this file.
1 #ifndef FWCore_Framework_DataProxyProvider_h
2 #define FWCore_Framework_DataProxyProvider_h
3 // -*- C++ -*-
4 //
5 // Package: Framework
6 // Class : DataProxyProvider
7 //
38 //
39 // Author: Chris Jones
40 // Created: Mon Mar 28 14:21:58 EST 2005
41 //
42 
43 // system include files
44 #include <memory>
45 #include <set>
46 #include <string>
47 #include <vector>
48 
49 // user include files
54 
55 // forward declarations
56 namespace edm {
58  class ParameterSet;
59 
60  namespace eventsetup {
61  class DataProxy;
63 
65  public:
67  DataProxyProvider(const DataProxyProvider&) = delete;
68  const DataProxyProvider& operator=(const DataProxyProvider&) = delete;
69  virtual ~DataProxyProvider() noexcept(false);
70 
71  class DataProxyContainer;
72 
73  class KeyedProxies {
74  public:
75  KeyedProxies(DataProxyContainer*, unsigned int recordIndex);
76 
77  bool unInitialized() const;
78 
79  EventSetupRecordKey const& recordKey() const;
80 
81  void insert(std::vector<std::pair<DataKey, std::shared_ptr<DataProxy>>>&&,
83 
84  bool contains(DataKey const& dataKey) const;
85 
86  unsigned int size() const;
87 
88  // Not an STL iterator and cannot be used as one
89  class Iterator {
90  public:
91  DataKey& dataKey() { return *dataKeysIter_; }
92  DataProxy* dataProxy() { return dataProxiesIter_->get(); }
94 
95  bool operator!=(Iterator const& right) const { return dataKeysIter_ != right.dataKeysIter_; }
96 
97  // Warning: dereference operator does not return a reference to an element in a container.
98  // The return type is nonstandard because the iteration is simultaneous over 2 containers.
99  // This return type is used in "ranged-based for" loops.
100  struct KeyedProxy {
104  };
106 
107  private:
108  friend KeyedProxies;
109  Iterator(std::vector<DataKey>::iterator dataKeysIter,
110  std::vector<edm::propagate_const<std::shared_ptr<DataProxy>>>::iterator dataProxiesIter);
111 
112  std::vector<DataKey>::iterator dataKeysIter_;
113  std::vector<edm::propagate_const<std::shared_ptr<DataProxy>>>::iterator dataProxiesIter_;
114  };
115 
116  Iterator begin();
117  Iterator end();
118 
119  private:
121  unsigned int recordIndex_;
122  unsigned int dataProxiesIndex_;
123  };
124 
125  struct PerRecordInfo {
127  bool operator<(const PerRecordInfo& right) const { return recordKey_ < right.recordKey_; }
128  bool operator==(const PerRecordInfo& right) const { return recordKey_ == right.recordKey_; }
129 
131  unsigned int nDataKeys_ = 0;
132  unsigned int indexToDataKeys_;
133  unsigned int nIOVs_ = 0;
134  unsigned int indexToKeyedProxies_ = 0;
135  };
136 
138  public:
140  bool isUsingRecord(const EventSetupRecordKey&) const;
141  std::set<EventSetupRecordKey> usingRecords() const;
142  void fillRecordsNotAllowingConcurrentIOVs(std::set<EventSetupRecordKey>& recordsNotAllowingConcurrentIOVs) const;
143 
145  void createKeyedProxies(EventSetupRecordKey const& key, unsigned int nConcurrentIOVs);
146 
147  KeyedProxies& keyedProxies(const EventSetupRecordKey& iRecordKey, unsigned int iovIndex);
148 
149  private:
150  friend KeyedProxies;
151 
152  std::vector<PerRecordInfo> perRecordInfos_;
153  std::vector<KeyedProxies> keyedProxiesCollection_;
154  std::vector<DataKey> dataKeys_;
155  std::vector<edm::propagate_const<std::shared_ptr<DataProxy>>> dataProxies_;
156  };
157 
159  std::set<EventSetupRecordKey> usingRecords() const { return dataProxyContainer_.usingRecords(); }
160  void fillRecordsNotAllowingConcurrentIOVs(std::set<EventSetupRecordKey>& recordsNotAllowingConcurrentIOVs) const {
161  dataProxyContainer_.fillRecordsNotAllowingConcurrentIOVs(recordsNotAllowingConcurrentIOVs);
162  }
163 
164  virtual void initConcurrentIOVs(EventSetupRecordKey const& key, unsigned int nConcurrentIOVs) {}
165 
166  void createKeyedProxies(EventSetupRecordKey const& key, unsigned int nConcurrentIOVs) {
167  dataProxyContainer_.createKeyedProxies(key, nConcurrentIOVs);
168  initConcurrentIOVs(key, nConcurrentIOVs);
169  }
170 
171  const ComponentDescription& description() const { return description_; }
172 
173  virtual void updateLookup(ESRecordsToProxyIndices const&);
174 
175  void setDescription(const ComponentDescription& iDescription) { description_ = iDescription; }
176 
181 
182  KeyedProxies& keyedProxies(const EventSetupRecordKey& iRecordKey, unsigned int iovIndex = 0);
183 
187 
188  protected:
189  template <class T>
190  void usingRecord() {
191  usingRecordWithKey(EventSetupRecordKey::makeKey<T>());
192  }
193 
195 
196  using KeyedProxiesVector = std::vector<std::pair<DataKey, std::shared_ptr<DataProxy>>>;
197  virtual KeyedProxiesVector registerProxies(const EventSetupRecordKey&, unsigned int iovIndex) = 0;
198 
199  private:
200  // ---------- member data --------------------------------
204  };
205 
206  } // namespace eventsetup
207 } // namespace edm
208 #endif
edm::eventsetup::DataProxyProvider
Definition: DataProxyProvider.h:64
edm::eventsetup::DataProxyProvider::registerProxies
virtual KeyedProxiesVector registerProxies(const EventSetupRecordKey &, unsigned int iovIndex)=0
edm::eventsetup::DataProxyProvider::KeyedProxies::contains
bool contains(DataKey const &dataKey) const
Definition: DataProxyProvider.cc:76
edm::eventsetup::DataProxyProvider::PerRecordInfo::indexToDataKeys_
unsigned int indexToDataKeys_
Definition: DataProxyProvider.h:132
edm::eventsetup::DataProxyProvider::PerRecordInfo::indexToKeyedProxies_
unsigned int indexToKeyedProxies_
Definition: DataProxyProvider.h:134
edm::eventsetup::ESRecordsToProxyIndices
Definition: ESRecordsToProxyIndices.h:35
edm::eventsetup::DataProxyProvider::KeyedProxies::Iterator::Iterator
Iterator(std::vector< DataKey >::iterator dataKeysIter, std::vector< edm::propagate_const< std::shared_ptr< DataProxy >>>::iterator dataProxiesIter)
Definition: DataProxyProvider.cc:98
edm::eventsetup::DataProxyProvider::KeyedProxies::Iterator::dataProxy
DataProxy * dataProxy()
Definition: DataProxyProvider.h:92
propagate_const.h
edm::eventsetup::DataProxyProvider::DataProxyContainer::dataProxies_
std::vector< edm::propagate_const< std::shared_ptr< DataProxy > > > dataProxies_
Definition: DataProxyProvider.h:155
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::eventsetup::DataProxyProvider::KeyedProxies::Iterator::KeyedProxy
Definition: DataProxyProvider.h:100
edm::eventsetup::DataProxyProvider::KeyedProxies::Iterator
Definition: DataProxyProvider.h:89
edm::eventsetup::DataProxyProvider::KeyedProxies::insert
void insert(std::vector< std::pair< DataKey, std::shared_ptr< DataProxy >>> &&, std::string const &appendToDataLabel)
Definition: DataProxyProvider.cc:44
ComponentDescription.h
edm::eventsetup::DataProxyProvider::DataProxyContainer::perRecordInfos_
std::vector< PerRecordInfo > perRecordInfos_
Definition: DataProxyProvider.h:152
edm::eventsetup::DataProxyProvider::KeyedProxies::unInitialized
bool unInitialized() const
Definition: DataProxyProvider.cc:38
edm::eventsetup::DataProxyProvider::KeyedProxies::Iterator::KeyedProxy::KeyedProxy
KeyedProxy(DataKey &dataKey, DataProxy *dataProxy)
Definition: DataProxyProvider.h:101
edm::eventsetup::DataKey
Definition: DataKey.h:29
edm::eventsetup::DataProxyProvider::KeyedProxies
Definition: DataProxyProvider.h:73
edm::eventsetup::DataProxyProvider::DataProxyContainer::KeyedProxies
friend KeyedProxies
Definition: DataProxyProvider.h:150
edm::eventsetup::DataProxyProvider::KeyedProxies::size
unsigned int size() const
Definition: DataProxyProvider.cc:88
edm::eventsetup::DataProxyProvider::DataProxyContainer::isUsingRecord
bool isUsingRecord(const EventSetupRecordKey &) const
Definition: DataProxyProvider.cc:124
edm::eventsetup::DataProxyProvider::DataProxyContainer::createKeyedProxies
void createKeyedProxies(EventSetupRecordKey const &key, unsigned int nConcurrentIOVs)
Definition: DataProxyProvider.cc:152
edm::eventsetup::EventSetupRecordKey
Definition: EventSetupRecordKey.h:30
edm::eventsetup::DataProxyProvider::KeyedProxies::Iterator::dataKeysIter_
std::vector< DataKey >::iterator dataKeysIter_
Definition: DataProxyProvider.h:112
edm::eventsetup::DataProxyProvider::KeyedProxies::recordKey
EventSetupRecordKey const & recordKey() const
Definition: DataProxyProvider.cc:40
edm::eventsetup::DataProxyProvider::KeyedProxies::Iterator::dataKey
DataKey & dataKey()
Definition: DataProxyProvider.h:91
edm::eventsetup::DataProxyProvider::DataProxyContainer::keyedProxiesCollection_
std::vector< KeyedProxies > keyedProxiesCollection_
Definition: DataProxyProvider.h:153
edm::eventsetup::DataProxyProvider::PerRecordInfo::operator==
bool operator==(const PerRecordInfo &right) const
Definition: DataProxyProvider.h:128
edm::propagate_const
Definition: propagate_const.h:32
edm::eventsetup::DataProxyProvider::KeyedProxies::Iterator::KeyedProxy::dataKey_
DataKey & dataKey_
Definition: DataProxyProvider.h:102
edm::eventsetup::DataProxyProvider::setAppendToDataLabel
void setAppendToDataLabel(const edm::ParameterSet &)
Definition: DataProxyProvider.cc:180
edm::eventsetup::DataProxyProvider::KeyedProxies::recordIndex_
unsigned int recordIndex_
Definition: DataProxyProvider.h:121
edm::eventsetup::DataProxyProvider::KeyedProxies::Iterator::KeyedProxies
friend KeyedProxies
Definition: DataProxyProvider.h:108
edm::eventsetup::DataProxyProvider::isUsingRecord
bool isUsingRecord(const EventSetupRecordKey &key) const
Definition: DataProxyProvider.h:158
edm::eventsetup::DataProxyProvider::operator=
const DataProxyProvider & operator=(const DataProxyProvider &)=delete
edm::eventsetup::DataProxyProvider::keyedProxies
KeyedProxies & keyedProxies(const EventSetupRecordKey &iRecordKey, unsigned int iovIndex=0)
Definition: DataProxyProvider.cc:191
edm::eventsetup::DataProxyProvider::KeyedProxies::KeyedProxies
KeyedProxies(DataProxyContainer *, unsigned int recordIndex)
Definition: DataProxyProvider.cc:35
edm::eventsetup::DataProxyProvider::DataProxyProvider
DataProxyProvider()
Definition: DataProxyProvider.cc:31
edm::eventsetup::DataProxyProvider::PerRecordInfo::recordKey_
EventSetupRecordKey recordKey_
Definition: DataProxyProvider.h:130
edm::eventsetup::DataProxyProvider::description_
ComponentDescription description_
Definition: DataProxyProvider.h:202
edm::eventsetup::DataProxyProvider::PerRecordInfo::nIOVs_
unsigned int nIOVs_
Definition: DataProxyProvider.h:133
edm::eventsetup::DataProxyProvider::PerRecordInfo::operator<
bool operator<(const PerRecordInfo &right) const
Definition: DataProxyProvider.h:127
edm::eventsetup::DataProxyProvider::updateLookup
virtual void updateLookup(ESRecordsToProxyIndices const &)
Definition: DataProxyProvider.cc:178
edm::eventsetup::DataProxyProvider::setDescription
void setDescription(const ComponentDescription &iDescription)
Definition: DataProxyProvider.h:175
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
edm::eventsetup::DataProxyProvider::usingRecords
std::set< EventSetupRecordKey > usingRecords() const
Definition: DataProxyProvider.h:159
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::eventsetup::ComponentDescription
Definition: ComponentDescription.h:30
DataProxy
Definition: DataProxy.h:26
edm::eventsetup::DataProxyProvider::PerRecordInfo
Definition: DataProxyProvider.h:125
edm::eventsetup::DataProxyProvider::DataProxyContainer::fillRecordsNotAllowingConcurrentIOVs
void fillRecordsNotAllowingConcurrentIOVs(std::set< EventSetupRecordKey > &recordsNotAllowingConcurrentIOVs) const
Definition: DataProxyProvider.cc:137
edm::eventsetup::DataProxyProvider::DataProxyContainer::usingRecordWithKey
void usingRecordWithKey(const EventSetupRecordKey &)
Definition: DataProxyProvider.cc:119
edm::ParameterSet
Definition: ParameterSet.h:36
ParameterSet
Definition: Functions.h:16
edm::eventsetup::DataProxyProvider::PerRecordInfo::nDataKeys_
unsigned int nDataKeys_
Definition: DataProxyProvider.h:131
DataKey.h
ESRecordsToProxyIndices
edm::eventsetup::DataProxyProvider::fillRecordsNotAllowingConcurrentIOVs
void fillRecordsNotAllowingConcurrentIOVs(std::set< EventSetupRecordKey > &recordsNotAllowingConcurrentIOVs) const
Definition: DataProxyProvider.h:160
fakeAlignmentProducer_cfi.appendToDataLabel
appendToDataLabel
Definition: fakeAlignmentProducer_cfi.py:4
edm::eventsetup::DataProxyProvider::usingRecord
void usingRecord()
Definition: DataProxyProvider.h:190
edm::eventsetup::DataProxyProvider::KeyedProxies::Iterator::operator*
KeyedProxy operator*()
Definition: DataProxyProvider.h:105
edm::eventsetup::DataProxyProvider::DataProxyContainer
Definition: DataProxyProvider.h:137
edm::eventsetup::DataProxyProvider::initConcurrentIOVs
virtual void initConcurrentIOVs(EventSetupRecordKey const &key, unsigned int nConcurrentIOVs)
Definition: DataProxyProvider.h:164
edm::eventsetup::DataProxyProvider::KeyedProxiesVector
std::vector< std::pair< DataKey, std::shared_ptr< DataProxy > >> KeyedProxiesVector
Definition: DataProxyProvider.h:196
edm::eventsetup::DataProxyProvider::dataProxyContainer_
DataProxyContainer dataProxyContainer_
Definition: DataProxyProvider.h:201
edm::eventsetup::DataProxy
Definition: DataProxy.h:38
edm::eventsetup::DataProxyProvider::prevalidate
static void prevalidate(ConfigurationDescriptions &)
Definition: DataProxyProvider.cc:220
edm::eventsetup::DataProxyProvider::usingRecordWithKey
void usingRecordWithKey(const EventSetupRecordKey &key)
Definition: DataProxyProvider.h:194
edm::eventsetup::DataProxyProvider::KeyedProxies::Iterator::operator!=
bool operator!=(Iterator const &right) const
Definition: DataProxyProvider.h:95
ConfigurationDescriptions
edm::eventsetup::DataProxyProvider::KeyedProxies::Iterator::operator++
Iterator & operator++()
Definition: DataProxyProvider.cc:92
edm::eventsetup::DataProxyProvider::appendToDataLabel_
std::string appendToDataLabel_
Definition: DataProxyProvider.h:203
edm::eventsetup::DataProxyProvider::createKeyedProxies
void createKeyedProxies(EventSetupRecordKey const &key, unsigned int nConcurrentIOVs)
Definition: DataProxyProvider.h:166
edm::eventsetup::DataProxyProvider::KeyedProxies::end
Iterator end()
Definition: DataProxyProvider.cc:109
edm::eventsetup::DataProxyProvider::description
const ComponentDescription & description() const
Definition: DataProxyProvider.h:171
edm::eventsetup::DataProxyProvider::DataProxyContainer::sortEventSetupRecordKeys
void sortEventSetupRecordKeys()
Definition: DataProxyProvider.cc:147
edm::eventsetup::DataProxyProvider::KeyedProxies::dataProxyContainer_
edm::propagate_const< DataProxyContainer * > dataProxyContainer_
Definition: DataProxyProvider.h:120
edm::eventsetup::DataProxyProvider::KeyedProxies::Iterator::KeyedProxy::dataProxy_
DataProxy * dataProxy_
Definition: DataProxyProvider.h:103
edm::eventsetup::DataProxyProvider::DataProxyContainer::usingRecords
std::set< EventSetupRecordKey > usingRecords() const
Definition: DataProxyProvider.cc:129
edm::eventsetup::DataProxyProvider::PerRecordInfo::PerRecordInfo
PerRecordInfo(const EventSetupRecordKey &)
Definition: DataProxyProvider.cc:116
edm::eventsetup::DataProxyProvider::KeyedProxies::begin
Iterator begin()
Definition: DataProxyProvider.cc:103
edm::eventsetup::DataProxyProvider::DataProxyContainer::keyedProxies
KeyedProxies & keyedProxies(const EventSetupRecordKey &iRecordKey, unsigned int iovIndex)
Definition: DataProxyProvider.cc:170
EventSetupRecordKey.h
edm::eventsetup::DataProxyProvider::DataProxyContainer::dataKeys_
std::vector< DataKey > dataKeys_
Definition: DataProxyProvider.h:154
crabWrapper.key
key
Definition: crabWrapper.py:19
edm::eventsetup::DataProxyProvider::KeyedProxies::Iterator::dataProxiesIter_
std::vector< edm::propagate_const< std::shared_ptr< DataProxy > > >::iterator dataProxiesIter_
Definition: DataProxyProvider.h:113
edm::eventsetup::DataProxyProvider::KeyedProxies::dataProxiesIndex_
unsigned int dataProxiesIndex_
Definition: DataProxyProvider.h:122
edm::eventsetup::DataProxyProvider::~DataProxyProvider
virtual ~DataProxyProvider() noexcept(false)
Definition: DataProxyProvider.cc:33