CMS 3D CMS Logo

ESProductResolverProvider.h
Go to the documentation of this file.
1 #ifndef FWCore_Framework_ESProductResolverProvider_h
2 #define FWCore_Framework_ESProductResolverProvider_h
3 // -*- C++ -*-
4 //
5 // Package: Framework
6 // Class : ESProductResolverProvider
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 ESProductResolver;
63 
65  public:
69  virtual ~ESProductResolverProvider() noexcept(false);
70 
72 
74  public:
75  KeyedResolvers(ESProductResolverContainer*, 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<ESProductResolver>>>&&,
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_; }
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 KeyedResolver {
105  };
107 
108  private:
110  Iterator(std::vector<DataKey>::iterator dataKeysIter,
111  std::vector<edm::propagate_const<std::shared_ptr<ESProductResolver>>>::iterator productResolversIter);
112 
113  std::vector<DataKey>::iterator dataKeysIter_;
114  std::vector<edm::propagate_const<std::shared_ptr<ESProductResolver>>>::iterator productResolversIter_;
115  };
116 
117  Iterator begin();
118  Iterator end();
119 
120  private:
122  unsigned int recordIndex_;
124  };
125 
126  struct PerRecordInfo {
128  bool operator<(const PerRecordInfo& right) const { return recordKey_ < right.recordKey_; }
129  bool operator==(const PerRecordInfo& right) const { return recordKey_ == right.recordKey_; }
130 
132  unsigned int nDataKeys_ = 0;
133  unsigned int indexToDataKeys_;
134  unsigned int nIOVs_ = 0;
135  unsigned int indexToKeyedResolvers_ = 0;
136  };
137 
139  public:
141  bool isUsingRecord(const EventSetupRecordKey&) const;
142  std::set<EventSetupRecordKey> usingRecords() const;
143  void fillRecordsNotAllowingConcurrentIOVs(std::set<EventSetupRecordKey>& recordsNotAllowingConcurrentIOVs) const;
144 
146  void createKeyedResolvers(EventSetupRecordKey const& key, unsigned int nConcurrentIOVs);
147 
148  KeyedResolvers& keyedResolvers(const EventSetupRecordKey& iRecordKey, unsigned int iovIndex);
149 
150  private:
152 
153  std::vector<PerRecordInfo> perRecordInfos_;
154  std::vector<KeyedResolvers> keyedResolversCollection_;
155  std::vector<DataKey> dataKeys_;
156  std::vector<edm::propagate_const<std::shared_ptr<ESProductResolver>>> productResolvers_;
157  };
158 
160  std::set<EventSetupRecordKey> usingRecords() const { return productResolverContainer_.usingRecords(); }
161  void fillRecordsNotAllowingConcurrentIOVs(std::set<EventSetupRecordKey>& recordsNotAllowingConcurrentIOVs) const {
162  productResolverContainer_.fillRecordsNotAllowingConcurrentIOVs(recordsNotAllowingConcurrentIOVs);
163  }
164 
165  virtual void initConcurrentIOVs(EventSetupRecordKey const& key, unsigned int nConcurrentIOVs) {}
166 
167  void createKeyedResolvers(EventSetupRecordKey const& key, unsigned int nConcurrentIOVs) {
169  initConcurrentIOVs(key, nConcurrentIOVs);
170  }
171 
172  const ComponentDescription& description() const { return description_; }
173 
174  virtual void updateLookup(ESRecordsToProductResolverIndices const&);
175 
176  void setDescription(const ComponentDescription& iDescription) { description_ = iDescription; }
177 
182 
183  KeyedResolvers& keyedResolvers(const EventSetupRecordKey& iRecordKey, unsigned int iovIndex = 0);
184 
188 
189  protected:
190  template <class T>
191  void usingRecord() {
192  usingRecordWithKey(EventSetupRecordKey::makeKey<T>());
193  }
194 
196 
197  using KeyedResolversVector = std::vector<std::pair<DataKey, std::shared_ptr<ESProductResolver>>>;
198  virtual KeyedResolversVector registerResolvers(const EventSetupRecordKey&, unsigned int iovIndex) = 0;
199 
200  private:
201  // ---------- member data --------------------------------
205  };
206 
207  } // namespace eventsetup
208 } // namespace edm
209 #endif
void createKeyedResolvers(EventSetupRecordKey const &key, unsigned int nConcurrentIOVs)
std::set< EventSetupRecordKey > usingRecords() const
const ComponentDescription & description() const
void fillRecordsNotAllowingConcurrentIOVs(std::set< EventSetupRecordKey > &recordsNotAllowingConcurrentIOVs) const
void usingRecordWithKey(const EventSetupRecordKey &key)
std::vector< edm::propagate_const< std::shared_ptr< ESProductResolver > > >::iterator productResolversIter_
virtual void initConcurrentIOVs(EventSetupRecordKey const &key, unsigned int nConcurrentIOVs)
void setDescription(const ComponentDescription &iDescription)
Iterator(std::vector< DataKey >::iterator dataKeysIter, std::vector< edm::propagate_const< std::shared_ptr< ESProductResolver >>>::iterator productResolversIter)
KeyedResolvers & keyedResolvers(const EventSetupRecordKey &iRecordKey, unsigned int iovIndex)
edm::propagate_const< ESProductResolverContainer * > productResolverContainer_
virtual KeyedResolversVector registerResolvers(const EventSetupRecordKey &, unsigned int iovIndex)=0
void insert(std::vector< std::pair< DataKey, std::shared_ptr< ESProductResolver >>> &&, std::string const &appendToDataLabel)
void fillRecordsNotAllowingConcurrentIOVs(std::set< EventSetupRecordKey > &recordsNotAllowingConcurrentIOVs) const
virtual void updateLookup(ESRecordsToProductResolverIndices const &)
void createKeyedResolvers(EventSetupRecordKey const &key, unsigned int nConcurrentIOVs)
KeyedResolvers(ESProductResolverContainer *, unsigned int recordIndex)
void setAppendToDataLabel(const edm::ParameterSet &)
std::vector< std::pair< DataKey, std::shared_ptr< ESProductResolver > >> KeyedResolversVector
HLT enums.
bool isUsingRecord(const EventSetupRecordKey &key) const
static void prevalidate(ConfigurationDescriptions &)
KeyedResolvers & keyedResolvers(const EventSetupRecordKey &iRecordKey, unsigned int iovIndex=0)
const ESProductResolverProvider & operator=(const ESProductResolverProvider &)=delete
std::vector< edm::propagate_const< std::shared_ptr< ESProductResolver > > > productResolvers_