CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 }
39 
40 // DataProxyProvider::DataProxyProvider(const DataProxyProvider& rhs)
41 // {
42 // // do actual copying here;
43 // }
44 
46 {
47 }
48 
49 //
50 // assignment operators
51 //
52 // const DataProxyProvider& DataProxyProvider::operator=(const DataProxyProvider& rhs)
53 // {
54 // //An exception safe implementation is
55 // DataProxyProvider temp(rhs);
56 // swap(rhs);
57 //
58 // return *this;
59 // }
60 
61 //
62 // member functions
63 //
64 void
66 {
67  recordProxies_[iKey];
68  //keys_.push_back(iKey);
69 }
70 
71 void
73 {
74  KeyedProxies& proxyList((*(recordProxies_.find(iRecordKey))).second) ;
75  KeyedProxies::iterator finished(proxyList.end()) ;
76  for (KeyedProxies::iterator keyedProxy(proxyList.begin()) ;
77  keyedProxy != finished ;
78  ++keyedProxy) {
79  (*((*keyedProxy).second)).invalidate() ;
80  }
81 
82 }
83 
84 void
86 {
87  invalidateProxies(iRecordKey);
88 }
89 
90 void
92 {
93  KeyedProxies& proxyList((*(recordProxies_.find(iRecordKey))).second) ;
94  KeyedProxies::iterator finished(proxyList.end()) ;
95  for (KeyedProxies::iterator keyedProxy(proxyList.begin()) ;
96  keyedProxy != finished ;
97  ++keyedProxy) {
98  (*((*keyedProxy).second)).resetIfTransient() ;
99  }
100 
101 }
102 
103 void
105 {
106  std::string oldValue( appendToDataLabel_);
107  //this can only be changed once and the default value is the empty string
108  assert(0 == oldValue.size());
109 
110  const std::string kParamName("appendToDataLabel");
111  if(iToAppend.exists(kParamName) ) {
112  appendToDataLabel_ = iToAppend.getParameter<std::string>(kParamName);
113  }
114 }
115 //
116 // const member functions
117 //
118 bool
120 {
121  return recordProxies_.end() != recordProxies_.find(iKey);
122 }
123 
124 std::set<EventSetupRecordKey>
126 {
127  std::set<EventSetupRecordKey> returnValue;
128  for(RecordProxies::const_iterator itRecProxies = recordProxies_.begin(),
129  itRecProxiesEnd = recordProxies_.end();
130  itRecProxies != itRecProxiesEnd;
131  ++itRecProxies) {
132  returnValue.insert(returnValue.end(), itRecProxies->first);
133  }
134  //copy_all(keys_, std::inserter(returnValue, returnValue.end()));
135  return returnValue;
136 }
137 
140 {
141  RecordProxies::const_iterator itFind = recordProxies_.find(iRecordKey);
142  assert(itFind != recordProxies_.end());
143 
144  if(itFind->second.empty()) {
145  //delayed registration
146  KeyedProxies& proxies = const_cast<KeyedProxies&>(itFind->second);
147  const_cast<DataProxyProvider*>(this)->registerProxies(iRecordKey,
148  proxies);
149 
150  bool mustChangeLabels = (0 != appendToDataLabel_.size());
151  for(KeyedProxies::iterator itProxy = proxies.begin(), itProxyEnd = proxies.end();
152  itProxy != itProxyEnd;
153  ++itProxy) {
154  itProxy->second->setProviderDescription(&description());
155  if( mustChangeLabels ) {
156  //Using swap is fine since
157  // 1) the data structure is not a map and so we have not sorted on the keys
158  // 2) this is the first time filling this so no outside agency has yet seen
159  // the label and therefore can not be dependent upon its value
160  std::string temp(std::string(itProxy->first.name().value())+appendToDataLabel_);
161  DataKey newKey(itProxy->first.type(),temp.c_str());
162  swap(itProxy->first,newKey);
163  }
164  }
165  }
166 
167  return itFind->second;
168 }
169 
170 //
171 // static member functions
172 //
173 static const std::string kAppendToDataLabel("appendToDataLabel");
174 
175 void
177 {
178  if(iDesc.defaultDescription()) {
181  }
182  }
183  for(auto& v: iDesc) {
184  if (v.second.isLabelUnused(kAppendToDataLabel)) {
185  v.second.add<std::string>(kAppendToDataLabel, std::string(""));
186  }
187  }
188 }
189 
190  }
191 }
192 
T getParameter(std::string const &) const
void resetProxiesIfTransient(const EventSetupRecordKey &iRecordType)
const KeyedProxies & keyedProxies(const EventSetupRecordKey &iRecordKey) const
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.
void invalidateProxies(const EventSetupRecordKey &iRecordKey)
static void prevalidate(ConfigurationDescriptions &)
std::vector< std::pair< DataKey, boost::shared_ptr< DataProxy > > > KeyedProxies
void resetProxies(const EventSetupRecordKey &iRecordType)
const ComponentDescription & description() const
void swap(DataKey &a, DataKey &b)
Definition: DataKey.h:99
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
void setAppendToDataLabel(const edm::ParameterSet &)