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 
22 namespace edm {
23  namespace eventsetup {
24 //
25 // constants, enums and typedefs
26 //
27 
28 //
29 // static data member definitions
30 //
31 
32 //
33 // constructors and destructor
34 //
35 DataProxyProvider::DataProxyProvider() : recordProxies_(), description_()
36 {
37 }
38 
39 // DataProxyProvider::DataProxyProvider(const DataProxyProvider& rhs)
40 // {
41 // // do actual copying here;
42 // }
43 
45 {
46 }
47 
48 //
49 // assignment operators
50 //
51 // const DataProxyProvider& DataProxyProvider::operator=(const DataProxyProvider& rhs)
52 // {
53 // //An exception safe implementation is
54 // DataProxyProvider temp(rhs);
55 // swap(rhs);
56 //
57 // return *this;
58 // }
59 
60 //
61 // member functions
62 //
63 void
65 {
66  recordProxies_[iKey];
67  //keys_.push_back(iKey);
68 }
69 
70 void
72 {
73  KeyedProxies& proxyList((*(recordProxies_.find(iRecordKey))).second) ;
74  KeyedProxies::iterator finished(proxyList.end()) ;
75  for (KeyedProxies::iterator keyedProxy(proxyList.begin()) ;
76  keyedProxy != finished ;
77  ++keyedProxy) {
78  (*((*keyedProxy).second)).invalidate() ;
79  }
80 
81 }
82 
83 void
85 {
86  invalidateProxies(iRecordKey);
87 }
88 
89 void
91 {
92  KeyedProxies& proxyList((*(recordProxies_.find(iRecordKey))).second) ;
93  KeyedProxies::iterator finished(proxyList.end()) ;
94  for (KeyedProxies::iterator keyedProxy(proxyList.begin()) ;
95  keyedProxy != finished ;
96  ++keyedProxy) {
97  (*((*keyedProxy).second)).resetIfTransient() ;
98  }
99 
100 }
101 
102 void
104 {
105  std::string oldValue( appendToDataLabel_);
106  //this can only be changed once and the default value is the empty string
107  assert(0 == oldValue.size());
108 
109  const std::string kParamName("appendToDataLabel");
110  if(iToAppend.exists(kParamName) ) {
111  appendToDataLabel_ = iToAppend.getParameter<std::string>(kParamName);
112  }
113 }
114 //
115 // const member functions
116 //
117 bool
119 {
120  return recordProxies_.end() != recordProxies_.find(iKey);
121 }
122 
123 std::set<EventSetupRecordKey>
125 {
126  std::set<EventSetupRecordKey> returnValue;
127  for(RecordProxies::const_iterator itRecProxies = recordProxies_.begin(),
128  itRecProxiesEnd = recordProxies_.end();
129  itRecProxies != itRecProxiesEnd;
130  ++itRecProxies) {
131  returnValue.insert(returnValue.end(), itRecProxies->first);
132  }
133  //copy_all(keys_, std::inserter(returnValue, returnValue.end()));
134  return returnValue;
135 }
136 
139 {
140  RecordProxies::const_iterator itFind = recordProxies_.find(iRecordKey);
141  assert(itFind != recordProxies_.end());
142 
143  if(itFind->second.empty()) {
144  //delayed registration
145  KeyedProxies& proxies = const_cast<KeyedProxies&>(itFind->second);
146  const_cast<DataProxyProvider*>(this)->registerProxies(iRecordKey,
147  proxies);
148 
149  bool mustChangeLabels = (0 != appendToDataLabel_.size());
150  for(KeyedProxies::iterator itProxy = proxies.begin(), itProxyEnd = proxies.end();
151  itProxy != itProxyEnd;
152  ++itProxy) {
153  itProxy->second->setProviderDescription(&description());
154  if( mustChangeLabels ) {
155  //Using swap is fine since
156  // 1) the data structure is not a map and so we have not sorted on the keys
157  // 2) this is the first time filling this so no outside agency has yet seen
158  // the label and therefore can not be dependent upon its value
159  std::string temp(std::string(itProxy->first.name().value())+appendToDataLabel_);
160  DataKey newKey(itProxy->first.type(),temp.c_str());
161  swap(itProxy->first,newKey);
162  }
163  }
164  }
165 
166  return itFind->second;
167 }
168 
169 //
170 // static member functions
171 //
172 static const std::string kAppendToDataLabel("appendToDataLabel");
173 
174 void
176 {
177  if(iDesc.defaultDescription()) {
179  iDesc.defaultDescription()->add<std::string>(kAppendToDataLabel, std::string(""));
180  }
181  }
182  for(auto& v: iDesc) {
183  if (v.second.isLabelUnused(kAppendToDataLabel)) {
184  v.second.add<std::string>(kAppendToDataLabel, std::string(""));
185  }
186  }
187 }
188 
189  }
190 }
191 
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 &)
mathSSE::Vec4< T > v