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