CMS 3D CMS Logo

DataProxyProvider.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Framework
4 // Class : DataProxyProvider
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Author: Chris Jones
10 // Created: Mon Mar 28 15:07:54 EST 2005
11 //
12 
13 // system include files
14 #include <algorithm>
15 
16 // user include files
21 #include <cassert>
22 
23 namespace edm {
24  namespace eventsetup {
25  //
26  // constants, enums and typedefs
27  //
28 
29  //
30  // static data member definitions
31  //
32 
33  //
34  // constructors and destructor
35  //
36  DataProxyProvider::DataProxyProvider() : recordProxies_(), description_() {}
37 
38  // DataProxyProvider::DataProxyProvider(const DataProxyProvider& rhs)
39  // {
40  // // do actual copying here;
41  // }
42 
44 
45  //
46  // assignment operators
47  //
48  // const DataProxyProvider& DataProxyProvider::operator=(const DataProxyProvider& rhs)
49  // {
50  // //An exception safe implementation is
51  // DataProxyProvider temp(rhs);
52  // swap(rhs);
53  //
54  // return *this;
55  // }
56 
57  //
58  // member functions
59  //
60 
62 
64  recordProxies_[iKey];
65  //keys_.push_back(iKey);
66  }
67 
69  KeyedProxies& proxyList((*(recordProxies_.find(iRecordKey))).second);
70  KeyedProxies::iterator finished(proxyList.end());
71  for (KeyedProxies::iterator keyedProxy(proxyList.begin()); keyedProxy != finished; ++keyedProxy) {
72  (*((*keyedProxy).second)).invalidate();
73  }
74  }
75 
77 
79  KeyedProxies& proxyList((*(recordProxies_.find(iRecordKey))).second);
80  KeyedProxies::iterator finished(proxyList.end());
81  for (KeyedProxies::iterator keyedProxy(proxyList.begin()); keyedProxy != finished; ++keyedProxy) {
82  (*((*keyedProxy).second)).resetIfTransient();
83  }
84  }
85 
88  //this can only be changed once and the default value is the empty string
89  assert(oldValue.empty());
90 
91  const std::string kParamName("appendToDataLabel");
92  if (iToAppend.exists(kParamName)) {
93  appendToDataLabel_ = iToAppend.getParameter<std::string>(kParamName);
94  }
95  }
96  //
97  // const member functions
98  //
100  return recordProxies_.end() != recordProxies_.find(iKey);
101  }
102 
103  std::set<EventSetupRecordKey> DataProxyProvider::usingRecords() const {
104  std::set<EventSetupRecordKey> returnValue;
105  for (RecordProxies::const_iterator itRecProxies = recordProxies_.begin(), itRecProxiesEnd = recordProxies_.end();
106  itRecProxies != itRecProxiesEnd;
107  ++itRecProxies) {
108  returnValue.insert(returnValue.end(), itRecProxies->first);
109  }
110  //copy_all(keys_, std::inserter(returnValue, returnValue.end()));
111  return returnValue;
112  }
113 
115  RecordProxies::const_iterator itFind = recordProxies_.find(iRecordKey);
116  assert(itFind != recordProxies_.end());
117 
118  if (itFind->second.empty()) {
119  //delayed registration
120  KeyedProxies& proxies = const_cast<KeyedProxies&>(itFind->second);
121  const_cast<DataProxyProvider*>(this)->registerProxies(iRecordKey, proxies);
122 
123  bool mustChangeLabels = (!appendToDataLabel_.empty());
124  for (KeyedProxies::iterator itProxy = proxies.begin(), itProxyEnd = proxies.end(); itProxy != itProxyEnd;
125  ++itProxy) {
126  itProxy->second->setProviderDescription(&description());
127  if (mustChangeLabels) {
128  //Using swap is fine since
129  // 1) the data structure is not a map and so we have not sorted on the keys
130  // 2) this is the first time filling this so no outside agency has yet seen
131  // the label and therefore can not be dependent upon its value
132  std::string temp(std::string(itProxy->first.name().value()) + appendToDataLabel_);
133  DataKey newKey(itProxy->first.type(), temp.c_str());
134  swap(itProxy->first, newKey);
135  }
136  }
137  }
138 
139  return itFind->second;
140  }
141 
142  //
143  // static member functions
144  //
145  static const std::string kAppendToDataLabel("appendToDataLabel");
146 
148  if (iDesc.defaultDescription()) {
149  if (iDesc.defaultDescription()->isLabelUnused(kAppendToDataLabel)) {
151  }
152  }
153  for (auto& v : iDesc) {
154  if (v.second.isLabelUnused(kAppendToDataLabel)) {
155  v.second.add<std::string>(kAppendToDataLabel, std::string(""));
156  }
157  }
158  }
159 
160  } // namespace eventsetup
161 } // namespace edm
T getParameter(std::string const &) const
void resetProxiesIfTransient(const EventSetupRecordKey &iRecordType)
virtual ~DataProxyProvider() noexcept(false)
const KeyedProxies & keyedProxies(const EventSetupRecordKey &iRecordKey) const
int finished
Definition: mps_check.py:36
bool isUsingRecord(const EventSetupRecordKey &) const
virtual void registerProxies(const EventSetupRecordKey &iRecordKey, KeyedProxies &aProxyList)=0
bool exists(std::string const &parameterName) const
checks if a parameter exists
void usingRecordWithKey(const EventSetupRecordKey &)
ParameterSetDescription * defaultDescription()
Returns 0 if no default has been assigned.
std::vector< std::pair< DataKey, edm::propagate_const< std::shared_ptr< DataProxy > > > > KeyedProxies
void invalidateProxies(const EventSetupRecordKey &iRecordKey)
virtual void updateLookup(ESRecordsToProxyIndices const &)
static void prevalidate(ConfigurationDescriptions &)
void resetProxies(const EventSetupRecordKey &iRecordType)
const ComponentDescription & description() const
void swap(DataKey &a, DataKey &b)
Definition: DataKey.h:85
bool isLabelUnused(std::string const &label) const
static const std::string kAppendToDataLabel("appendToDataLabel")
ParameterDescriptionBase * add(U const &iLabel, T const &value)
std::set< EventSetupRecordKey > usingRecords() const
#define noexcept
void setAppendToDataLabel(const edm::ParameterSet &)
HLT enums.