CMS 3D CMS Logo

EventSetupRecord.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Framework
4 // Class : EventSetupRecord
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Author: Chris Jones
10 // Created: Sat Mar 26 18:06:32 EST 2005
11 //
12 
13 // system include files
14 #include <cassert>
15 #include <string>
16 #include <exception>
17 
18 // user include files
24 
27 
28 namespace edm {
29  namespace eventsetup {
30  //
31  // constants, enums and typedefs
32  //
33  typedef std::map<DataKey, const DataProxy*> Proxies;
34  //
35  // static data member definitions
36  //
37 
38  //
39  // constructors and destructor
40  //
42 
43  // EventSetupRecord::EventSetupRecord(const EventSetupRecord& rhs)
44  // {
45  // // do actual copying here;
46  // }
47 
49 
50  //
51  // assignment operators
52  //
53  // const EventSetupRecord& EventSetupRecord::operator=(const EventSetupRecord& rhs)
54  // {
55  // //An exception safe implementation is
56  // EventSetupRecord temp(rhs);
57  // swap(rhs);
58  //
59  // return *this;
60  // }
61 
62  //
63  // member functions
64  //
65  //
66  // const member functions
67  //
68 
69  bool EventSetupRecord::doGet(const DataKey& aKey, bool aGetTransiently) const {
70  return impl_->doGet(aKey, aGetTransiently);
71  }
72 
73  bool EventSetupRecord::wasGotten(const DataKey& aKey) const { return impl_->wasGotten(aKey); }
74 
76  return impl_->providerDescription(aKey);
77  }
78 
79  void EventSetupRecord::validate(const ComponentDescription* iDesc, const ESInputTag& iTag) const {
80  if (iDesc && !iTag.module().empty()) {
81  bool matched = false;
82  if (iDesc->label_.empty()) {
83  matched = iDesc->type_ == iTag.module();
84  } else {
85  matched = iDesc->label_ == iTag.module();
86  }
87  if (!matched) {
88  throw cms::Exception("EventSetupWrongModule")
89  << "EventSetup data was retrieved using an ESInputTag with the values\n"
90  << " moduleLabel = '" << iTag.module() << "'\n"
91  << " dataLabel = '" << iTag.data() << "'\n"
92  << "but the data matching the C++ class type and dataLabel comes from module type=" << iDesc->type_
93  << " label='" << iDesc->label_ << "'.\n Please either change the ESInputTag's 'module' label to be "
94  << (iDesc->label_.empty() ? iDesc->type_ : iDesc->label_) << "\n or add the EventSetup module "
95  << iTag.module() << " to the configuration.";
96  }
97  }
98  }
99 
101  const char* iName,
102  const ComponentDescription* iDescription,
103  const DataKey& iKey) const {
104  std::ostringstream ost;
105  ost << "Using EventSetup component " << iDescription->type_ << "/'" << iDescription->label_ << "' to make data "
106  << iKey.type().name() << "/'" << iName << "' in record " << this->key().type().name();
107  iException.addContext(ost.str());
108  }
109 
111  TypeTag const& iDataKey) {
112  cms::Exception ex("InvalidESGetToken");
113  ex << "Attempted to get data using an invalid token of type ESGetToken<" << iDataKey.name() << ","
114  << iRecordKey.name()
115  << ">.\n"
116  "Please call consumes to properly initialize the token.";
117  return std::make_exception_ptr(ex);
118  }
119 
120  //
121  // static member functions
122  //
123  } // namespace eventsetup
124 } // namespace edm
virtual EventSetupRecordKey key() const =0
bool wasGotten(DataKey const &aKey) const
void addTraceInfoToCmsException(cms::Exception &iException, char const *iName, ComponentDescription const *, DataKey const &) const
ComponentDescription const * providerDescription(DataKey const &aKey) const
ComponentDescription const * providerDescription(DataKey const &aKey) const
bool wasGotten(DataKey const &aKey) const
const std::string & data() const
Definition: ESInputTag.h:104
const TypeTag & type() const
Definition: DataKey.h:52
void addContext(std::string const &context)
Definition: Exception.cc:165
HLT enums.
std::map< DataKey, const DataProxy * > Proxies
void validate(ComponentDescription const *, ESInputTag const &) const
bool doGet(DataKey const &aKey, bool aGetTransiently=false) const
returns false if no data available for key
const std::string & module() const
Definition: ESInputTag.h:99
EventSetupRecordImpl const * impl_
static std::exception_ptr makeInvalidTokenException(EventSetupRecordKey const &, TypeTag const &)
bool doGet(DataKey const &aKey, bool aGetTransiently=false) const
returns false if no data available for key