Go to the documentation of this file.00001
00002
00003
00004 #include <algorithm>
00005
00006 #include "FWCore/Framework/interface/PrincipalGetAdapter.h"
00007 #include "DataFormats/Provenance/interface/ProductRegistry.h"
00008 #include "FWCore/Framework/interface/Principal.h"
00009 #include "FWCore/Utilities/interface/EDMException.h"
00010 #include "DataFormats/Provenance/interface/ModuleDescription.h"
00011
00012 namespace edm {
00013
00014 PrincipalGetAdapter::PrincipalGetAdapter(Principal & pcpl,
00015 ModuleDescription const& md) :
00016
00017 principal_(pcpl),
00018 md_(md) {
00019 }
00020
00021 PrincipalGetAdapter::~PrincipalGetAdapter() {
00022 }
00023
00024
00025 void
00026 principal_get_adapter_detail::deleter::operator()(std::pair<WrapperOwningHolder, ConstBranchDescription const*> const p) const {
00027 WrapperOwningHolder* edp = const_cast<WrapperOwningHolder*>(&p.first);
00028 edp->reset();
00029 }
00030
00031 void
00032 principal_get_adapter_detail::throwOnPutOfNullProduct(
00033 char const* principalType,
00034 TypeID const& productType,
00035 std::string const& productInstanceName) {
00036 throw Exception(errors::NullPointerError)
00037 << principalType
00038 << "::put: A null auto_ptr was passed to 'put'.\n"
00039 << "The pointer is of type "
00040 << productType
00041 << ".\nThe specified productInstanceName was '"
00042 << productInstanceName
00043 << "'.\n";
00044 }
00045
00046 BranchType const&
00047 PrincipalGetAdapter::branchType() const {
00048 return principal_.branchType();
00049 }
00050
00051 BasicHandle
00052 PrincipalGetAdapter::getByLabel_(TypeID const& tid,
00053 std::string const& label,
00054 std::string const& productInstanceName,
00055 std::string const& processName) const {
00056 size_t cachedOffset = 0;
00057 int fillCount = -1;
00058 return principal_.getByLabel(tid, label, productInstanceName, processName, cachedOffset, fillCount);
00059 }
00060
00061 BasicHandle
00062 PrincipalGetAdapter::getByLabel_(TypeID const& tid,
00063 InputTag const& tag) const {
00064
00065 principal_.maybeFlushCache(tid, tag);
00066 return principal_.getByLabel(tid, tag.label(), tag.instance(), tag.process(), tag.cachedOffset(), tag.fillCount());
00067 }
00068
00069 void
00070 PrincipalGetAdapter::getManyByType_(TypeID const& tid,
00071 BasicHandleVec& results) const {
00072 principal_.getManyByType(tid, results);
00073 }
00074
00075 int
00076 PrincipalGetAdapter::getMatchingSequenceByLabel_(TypeID const& typeID,
00077 std::string const& label,
00078 std::string const& productInstanceName,
00079 std::string const& processName,
00080 BasicHandle& result) const {
00081
00082 return principal_.getMatchingSequence(typeID,
00083 label,
00084 productInstanceName,
00085 processName,
00086 result);
00087 }
00088
00089 ProcessHistory const&
00090 PrincipalGetAdapter::processHistory() const {
00091 return principal_.processHistory();
00092 }
00093
00094 ConstBranchDescription const&
00095 PrincipalGetAdapter::getBranchDescription(TypeID const& type,
00096 std::string const& productInstanceName) const {
00097 TransientProductLookupMap const& tplm = principal_.productRegistry().productLookup();
00098 std::pair<TransientProductLookupMap::const_iterator, TransientProductLookupMap::const_iterator> range =
00099 tplm.equal_range(TypeInBranchType(type,branchType()),md_.moduleLabel(),productInstanceName);
00100
00101
00102
00103
00104
00105 bool foundMatch = false;
00106 if(range.first != range.second) {
00107 foundMatch = true;
00108 while(md_.processName() != range.first->branchDescription()->processName()) {
00109 ++range.first;
00110 if(range.first == range.second || range.first->isFirst()) {
00111 foundMatch = false;
00112 break;
00113 }
00114 }
00115 }
00116 if(!foundMatch) {
00117 throw edm::Exception(edm::errors::InsertFailure)
00118 << "Illegal attempt to 'put' an unregistered product.\n"
00119 << "No product is registered for\n"
00120 << " process name: '" << md_.processName() << "'\n"
00121 << " module label: '" << md_.moduleLabel() << "'\n"
00122 << " product friendly class name: '" << type.friendlyClassName() << "'\n"
00123 << " product instance name: '" << productInstanceName << "'\n"
00124
00125 << "The ProductRegistry contains:\n"
00126 << principal_.productRegistry()
00127 << '\n';
00128 }
00129 return *(range.first->branchDescription());
00130 }
00131
00132 EDProductGetter const*
00133 PrincipalGetAdapter::prodGetter() const{
00134 return principal_.prodGetter();
00135 }
00136 }