00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "boost/thread/tss.hpp"
00016
00017
00018 #include "DataFormats/Common/interface/EDProductGetter.h"
00019 #include "FWCore/Utilities/interface/EDMException.h"
00020
00021 namespace edm {
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 EDProductGetter::EDProductGetter()
00034 {
00035 }
00036
00037
00038
00039
00040
00041
00042 EDProductGetter::~EDProductGetter()
00043 {
00044 }
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070 namespace {
00071 struct Holder {
00072 Holder(): held_(0) {}
00073 edm::EDProductGetter const* held_;
00074 };
00075 }
00076 EDProductGetter const*
00077 EDProductGetter::set(EDProductGetter const* iGetter)
00078 {
00079
00080 static boost::thread_specific_ptr<Holder> s_registry;
00081 if(0 == s_registry.get()){
00082 s_registry.reset(new Holder);
00083 }
00084 EDProductGetter const* previous = s_registry->held_;
00085 s_registry->held_= iGetter;
00086 return previous;
00087 }
00088
00089 EDProductGetter const*
00090 EDProductGetter::instance()
00091 {
00092 EDProductGetter const* returnValue = EDProductGetter::set(0);
00093 EDProductGetter::set(returnValue);
00094 return returnValue;
00095 }
00096
00097 EDProductGetter const*
00098 mustBeNonZero(EDProductGetter const* prodGetter, std::string refType, ProductID const& productID) {
00099 if (prodGetter != 0) return prodGetter;
00100 throw Exception(errors::InvalidReference, refType)
00101 << "Attempt to construct a " << refType << " with ProductID " << productID << "\n"
00102 << "but with a null pointer to a product getter.\n"
00103 << "The product getter pointer passed to the constructor must refer\n"
00104 << "to a real getter, such as an EventPrincipal.\n";
00105 }
00106 }