CMS 3D CMS Logo

Public Types | Public Member Functions | Private Member Functions | Private Attributes

edm::PrincipalGetAdapter Class Reference

#include <PrincipalGetAdapter.h>

List of all members.

Public Types

typedef std::vector< BasicHandleBasicHandleVec

Public Member Functions

ConstBranchDescription const & getBranchDescription (TypeID const &type, std::string const &productInstanceName) const
template<typename PROD >
bool getByLabel (std::string const &label, Handle< PROD > &result) const
template<typename PROD >
bool getByLabel (std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
template<typename PROD >
bool getByLabel (InputTag const &tag, Handle< PROD > &result) const
 same as above, but using the InputTag class
BasicHandle getByLabel_ (TypeID const &tid, std::string const &label, std::string const &productInstanceName, std::string const &processName) const
BasicHandle getByLabel_ (TypeID const &tid, InputTag const &tag) const
template<typename PROD >
void getManyByType (std::vector< Handle< PROD > > &results) const
void getManyByType_ (TypeID const &tid, BasicHandleVec &results) const
int getMatchingSequenceByLabel_ (TypeID const &typeID, std::string const &label, std::string const &productInstanceName, std::string const &processName, BasicHandle &result) const
Principal const & principal () const
Principalprincipal ()
 PrincipalGetAdapter (Principal &pcpl, ModuleDescription const &md)
ProcessHistory const & processHistory () const
EDProductGetter const * prodGetter () const
 ~PrincipalGetAdapter ()

Private Member Functions

BranchType const & branchType () const
PrincipalGetAdapter const & operator= (PrincipalGetAdapter const &)
 PrincipalGetAdapter (PrincipalGetAdapter const &)

Private Attributes

ModuleDescription const & md_
Principalprincipal_

Detailed Description

Definition at line 113 of file PrincipalGetAdapter.h.


Member Typedef Documentation

Definition at line 150 of file PrincipalGetAdapter.h.


Constructor & Destructor Documentation

PrincipalGetAdapter::PrincipalGetAdapter ( Principal pcpl,
ModuleDescription const &  md 
)

Definition at line 14 of file PrincipalGetAdapter.cc.

                                      :
    //putProducts_(),
    principal_(pcpl),
    md_(md) {
  }
PrincipalGetAdapter::~PrincipalGetAdapter ( )

Definition at line 21 of file PrincipalGetAdapter.cc.

                                            {
  }
edm::PrincipalGetAdapter::PrincipalGetAdapter ( PrincipalGetAdapter const &  ) [private]

Member Function Documentation

BranchType const & PrincipalGetAdapter::branchType ( ) const [private]

Definition at line 47 of file PrincipalGetAdapter.cc.

                                        {
    return principal_.branchType();
  }
ConstBranchDescription const & PrincipalGetAdapter::getBranchDescription ( TypeID const &  type,
std::string const &  productInstanceName 
) const

Definition at line 95 of file PrincipalGetAdapter.cc.

References revisionDML::branchType(), edm::TransientProductLookupMap::equal_range(), Exception, edm::TypeID::friendlyClassName(), and edm::errors::InsertFailure.

Referenced by edm::Event::getRefBeforePut(), edm::Event::put(), edm::LuminosityBlock::put(), and edm::Run::put().

                                                                                 {
    TransientProductLookupMap const& tplm = principal_.productRegistry().productLookup();
    std::pair<TransientProductLookupMap::const_iterator, TransientProductLookupMap::const_iterator> range = 
     tplm.equal_range(TypeInBranchType(type,branchType()),md_.moduleLabel(),productInstanceName);
   
    //NOTE: getBranchDescription should only be called by a EDProducer and therefore the processName should
    // match the first one returned by equal_range since they are ordered by time. However, there is one test
    // which violates this rule (FWCore/Framework/test/Event_t.cpp.  I do not see a go way to 'fix' it so
    // I'll allow the same behavior it depends upon
    bool foundMatch = false;
    if(range.first != range.second) {
       foundMatch = true;
       while(md_.processName() != range.first->branchDescription()->processName()) {
          ++range.first;
          if(range.first == range.second || range.first->isFirst()) {
             foundMatch = false;
             break;
          }
       }
    }
    if(!foundMatch) {
      throw edm::Exception(edm::errors::InsertFailure)
        << "Illegal attempt to 'put' an unregistered product.\n"
        << "No product is registered for\n"
        << "  process name:                '" << md_.processName() << "'\n"
        << "  module label:                '" << md_.moduleLabel() << "'\n"
        << "  product friendly class name: '" << type.friendlyClassName() << "'\n"
        << "  product instance name:       '" << productInstanceName << "'\n"

        << "The ProductRegistry contains:\n"
        << principal_.productRegistry()
        << '\n';
    }
    return *(range.first->branchDescription());
  }
template<typename PROD >
bool PrincipalGetAdapter::getByLabel ( std::string const &  label,
Handle< PROD > &  result 
) const [inline]
template<typename PROD >
bool PrincipalGetAdapter::getByLabel ( std::string const &  label,
std::string const &  productInstanceName,
Handle< PROD > &  result 
) const [inline]

Definition at line 305 of file PrincipalGetAdapter.h.

References edm::HandleBase::clear(), edm::convert_handle(), edm::BasicHandle::failedToGet(), getByLabel_(), PROD, and AlCaHLTBitMon_QueryRunRegistry::string.

                                                       {
    result.clear();
    BasicHandle bh = this->getByLabel_(TypeID(typeid(PROD)), label, productInstanceName, std::string());
    convert_handle(bh, result);  // throws on conversion error
    if (bh.failedToGet()) {
      return false;
    }
    return true;
  }
template<typename PROD >
bool PrincipalGetAdapter::getByLabel ( InputTag const &  tag,
Handle< PROD > &  result 
) const [inline]

same as above, but using the InputTag class

Definition at line 292 of file PrincipalGetAdapter.h.

References edm::HandleBase::clear(), edm::convert_handle(), edm::BasicHandle::failedToGet(), getByLabel_(), and PROD.

                                                                                 {
    result.clear();
    BasicHandle bh = this->getByLabel_(TypeID(typeid(PROD)), tag);
    convert_handle(bh, result);  // throws on conversion error
    if (bh.failedToGet()) {
      return false;
    }
    return true;
  }
BasicHandle PrincipalGetAdapter::getByLabel_ ( TypeID const &  tid,
std::string const &  label,
std::string const &  productInstanceName,
std::string const &  processName 
) const

Definition at line 52 of file PrincipalGetAdapter.cc.

Referenced by getByLabel(), edm::Event::getByLabelImpl(), edm::LuminosityBlock::getByLabelImpl(), and edm::Run::getByLabelImpl().

                                                         {
    size_t cachedOffset = 0;
    int fillCount = -1;
    return principal_.getByLabel(tid, label, productInstanceName, processName, cachedOffset, fillCount);
  }
BasicHandle PrincipalGetAdapter::getByLabel_ ( TypeID const &  tid,
InputTag const &  tag 
) const

Definition at line 62 of file PrincipalGetAdapter.cc.

References edm::InputTag::cachedOffset(), edm::InputTag::fillCount(), edm::InputTag::instance(), edm::InputTag::label(), and edm::InputTag::process().

                                                {

    principal_.maybeFlushCache(tid, tag);
    return principal_.getByLabel(tid, tag.label(), tag.instance(), tag.process(), tag.cachedOffset(), tag.fillCount());
  }
template<typename PROD >
void PrincipalGetAdapter::getManyByType ( std::vector< Handle< PROD > > &  results) const [inline]

Definition at line 320 of file PrincipalGetAdapter.h.

References edm::convert_handle(), end, getManyByType_(), PROD, edm::es::products(), query::result, and python::entryComment::results.

Referenced by edm::Run::getManyByType(), edm::LuminosityBlock::getManyByType(), and edm::Event::getManyByType().

                                                                            { 
    BasicHandleVec bhv;
    this->getManyByType_(TypeID(typeid(PROD)), bhv);
    
    // Go through the returned handles; for each element,
    //   1. create a Handle<PROD> and
    //
    // This function presents an exception safety difficulty. If an
    // exception is thrown when converting a handle, the "got
    // products" record will be wrong.
    //
    // Since EDProducers are not allowed to use this function,
    // the problem does not seem too severe.
    //
    // Question: do we even need to keep track of the "got products"
    // for this function, since it is *not* to be used by EDProducers?
    std::vector<Handle<PROD> > products;

    typename BasicHandleVec::const_iterator it = bhv.begin();
    typename BasicHandleVec::const_iterator end = bhv.end();

    while (it != end) {
      Handle<PROD> result;
      convert_handle(*it, result);  // throws on conversion error
      products.push_back(result);
      ++it;
    }
    results.swap(products);
  }
void PrincipalGetAdapter::getManyByType_ ( TypeID const &  tid,
BasicHandleVec results 
) const

Definition at line 70 of file PrincipalGetAdapter.cc.

Referenced by getManyByType().

                                                 {
    principal_.getManyByType(tid, results);
  }
int PrincipalGetAdapter::getMatchingSequenceByLabel_ ( TypeID const &  typeID,
std::string const &  label,
std::string const &  productInstanceName,
std::string const &  processName,
BasicHandle result 
) const

Definition at line 76 of file PrincipalGetAdapter.cc.

Referenced by edm::Event::getByLabel().

                                                                              {

    return principal_.getMatchingSequence(typeID,
                                          label,
                                          productInstanceName,
                                          processName,
                                          result);
  }
PrincipalGetAdapter const& edm::PrincipalGetAdapter::operator= ( PrincipalGetAdapter const &  ) [private]
Principal const& edm::PrincipalGetAdapter::principal ( ) const [inline]

Definition at line 145 of file PrincipalGetAdapter.h.

References principal_.

{return principal_;}
Principal& edm::PrincipalGetAdapter::principal ( ) [inline]
ProcessHistory const & PrincipalGetAdapter::processHistory ( ) const

Definition at line 90 of file PrincipalGetAdapter.cc.

Referenced by edm::LuminosityBlock::processHistory(), edm::Event::processHistory(), and edm::Run::processHistory().

                                            {
    return principal_.processHistory();
  }
EDProductGetter const * PrincipalGetAdapter::prodGetter ( ) const

Definition at line 133 of file PrincipalGetAdapter.cc.

Referenced by edm::Event::getRefBeforePut().

                                       {
    return principal_.prodGetter();
  }

Member Data Documentation

Definition at line 203 of file PrincipalGetAdapter.h.

Definition at line 199 of file PrincipalGetAdapter.h.

Referenced by principal().