CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 {
101  KeyedProxy(DataKey& dataKey, DataProxy* dataProxy) : dataKey_(dataKey), dataProxy_(dataProxy) {}
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
void usingRecordWithKey(const EventSetupRecordKey &key)
void setDescription(const ComponentDescription &iDescription)
EventSetupRecordKey const & recordKey() const
bool operator==(const PerRecordInfo &right) const
virtual KeyedProxiesVector registerProxies(const EventSetupRecordKey &, unsigned int iovIndex)=0
std::set< EventSetupRecordKey > usingRecords() const
bool isUsingRecord(const EventSetupRecordKey &key) const
bool operator<(const PerRecordInfo &right) const
tuple key
prepare the HTCondor submission files and eventually submit them
std::vector< edm::propagate_const< std::shared_ptr< DataProxy > > > dataProxies_
KeyedProxies & keyedProxies(const EventSetupRecordKey &iRecordKey, unsigned int iovIndex)
const ComponentDescription & description() const
virtual void updateLookup(ESRecordsToProxyIndices const &)
bool contains(DataKey const &dataKey) const
edm::propagate_const< DataProxyContainer * > dataProxyContainer_
static void prevalidate(ConfigurationDescriptions &)
bool isUsingRecord(const EventSetupRecordKey &) const
std::vector< std::pair< DataKey, std::shared_ptr< DataProxy >>> KeyedProxiesVector
void setAppendToDataLabel(const edm::ParameterSet &)
void fillRecordsNotAllowingConcurrentIOVs(std::set< EventSetupRecordKey > &recordsNotAllowingConcurrentIOVs) const
std::vector< edm::propagate_const< std::shared_ptr< DataProxy > > >::iterator dataProxiesIter_
void insert(std::vector< std::pair< DataKey, std::shared_ptr< DataProxy >>> &&, std::string const &appendToDataLabel)
KeyedProxies & keyedProxies(const EventSetupRecordKey &iRecordKey, unsigned int iovIndex=0)
void createKeyedProxies(EventSetupRecordKey const &key, unsigned int nConcurrentIOVs)
const DataProxyProvider & operator=(const DataProxyProvider &)=delete
void fillRecordsNotAllowingConcurrentIOVs(std::set< EventSetupRecordKey > &recordsNotAllowingConcurrentIOVs) const
Iterator(std::vector< DataKey >::iterator dataKeysIter, std::vector< edm::propagate_const< std::shared_ptr< DataProxy >>>::iterator dataProxiesIter)
std::set< EventSetupRecordKey > usingRecords() const
virtual void initConcurrentIOVs(EventSetupRecordKey const &key, unsigned int nConcurrentIOVs)
virtual ~DataProxyProvider() noexcept(false)
void createKeyedProxies(EventSetupRecordKey const &key, unsigned int nConcurrentIOVs)
KeyedProxies(DataProxyContainer *, unsigned int recordIndex)