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

template<typename PROD >
bool get (SelectorBase const &, Handle< PROD > &result) const
BasicHandle get_ (TypeID const &tid, SelectorBase const &) const
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, InputTag const &tag) const
BasicHandle getByLabel_ (TypeID const &tid, std::string const &label, std::string const &productInstanceName, std::string const &processName) const
template<typename PROD >
bool getByType (Handle< PROD > &result) const
BasicHandle getByType_ (TypeID const &tid) const
template<typename PROD >
void getMany (SelectorBase const &, std::vector< Handle< PROD > > &results) const
void getMany_ (TypeID const &tid, SelectorBase const &sel, BasicHandleVec &results) const
template<typename PROD >
void getManyByType (std::vector< Handle< PROD > > &results) const
void getManyByType_ (TypeID const &tid, BasicHandleVec &results) const
int getMatchingSequence_ (TypeID const &typeID, SelectorBase const &selector, BasicHandle &result) const
int getMatchingSequenceByLabel_ (TypeID const &typeID, std::string const &label, std::string const &productInstanceName, BasicHandle &result) 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 162 of file PrincipalGetAdapter.h.


Constructor & Destructor Documentation

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

Definition at line 15 of file PrincipalGetAdapter.cc.

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

Definition at line 22 of file PrincipalGetAdapter.cc.

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

Member Function Documentation

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

Definition at line 48 of file PrincipalGetAdapter.cc.

                                        {
    return principal_.branchType();
  }
template<typename PROD >
bool PrincipalGetAdapter::get ( SelectorBase const &  sel,
Handle< PROD > &  result 
) const [inline]

Definition at line 317 of file PrincipalGetAdapter.h.

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

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

                                                {
    result.clear();
    BasicHandle bh = this->get_(TypeID(typeid(PROD)),sel);
    convert_handle(bh, result);  // throws on conversion error
    if (bh.failedToGet()) {
      return false;
    }
    return true;
  }
BasicHandle PrincipalGetAdapter::get_ ( TypeID const &  tid,
SelectorBase const &  sel 
) const

Definition at line 53 of file PrincipalGetAdapter.cc.

Referenced by get().

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

Definition at line 138 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 ( InputTag const &  tag,
Handle< PROD > &  result 
) const [inline]

same as above, but using the InputTag class

Definition at line 340 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;
  }
template<typename PROD >
bool PrincipalGetAdapter::getByLabel ( std::string const &  label,
Handle< PROD > &  result 
) const [inline]

Definition at line 331 of file PrincipalGetAdapter.h.

References edm::HandleBase::clear().

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

                                                       {
    result.clear();
    return getByLabel(label, std::string(), result);
  }
template<typename PROD >
bool PrincipalGetAdapter::getByLabel ( std::string const &  label,
std::string const &  productInstanceName,
Handle< PROD > &  result 
) const [inline]

Definition at line 353 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)), label, productInstanceName, std::string());
    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 65 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 75 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 >
bool PrincipalGetAdapter::getByType ( Handle< PROD > &  result) const [inline]

Definition at line 402 of file PrincipalGetAdapter.h.

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

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

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

Definition at line 83 of file PrincipalGetAdapter.cc.

Referenced by getByType().

                                                         {
    return principal_.getByType(tid);
  }
template<typename PROD >
void PrincipalGetAdapter::getMany ( SelectorBase const &  sel,
std::vector< Handle< PROD > > &  results 
) const [inline]

Definition at line 368 of file PrincipalGetAdapter.h.

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

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

                                                                 { 
    BasicHandleVec bhv;
    this->getMany_(TypeID(typeid(PROD)), sel, 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::getMany_ ( TypeID const &  tid,
SelectorBase const &  sel,
BasicHandleVec results 
) const

Definition at line 58 of file PrincipalGetAdapter.cc.

Referenced by getMany().

                                                 {
    principal_.getMany(tid, sel, results);
  }
template<typename PROD >
void PrincipalGetAdapter::getManyByType ( std::vector< Handle< PROD > > &  results) const [inline]

Definition at line 415 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 88 of file PrincipalGetAdapter.cc.

Referenced by getManyByType().

                                                 {
    principal_.getManyByType(tid, results);
  }
int PrincipalGetAdapter::getMatchingSequence_ ( TypeID const &  typeID,
SelectorBase const &  selector,
BasicHandle result 
) const

Definition at line 94 of file PrincipalGetAdapter.cc.

                                                                {
    return principal_.getMatchingSequence(typeID,
                                    selector,
                                    result);
  }
int PrincipalGetAdapter::getMatchingSequenceByLabel_ ( TypeID const &  typeID,
std::string const &  label,
std::string const &  productInstanceName,
BasicHandle result 
) const

Definition at line 103 of file PrincipalGetAdapter.cc.

References n, and runTheMatrix::sel.

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

                                                                       {
    Selector sel(ModuleLabelSelector(label) &&
                 ProductInstanceNameSelector(productInstanceName));

    int n = principal_.getMatchingSequence(typeID,
                                     sel,
                                     result);
    return n;
  }
int PrincipalGetAdapter::getMatchingSequenceByLabel_ ( TypeID const &  typeID,
std::string const &  label,
std::string const &  productInstanceName,
std::string const &  processName,
BasicHandle result 
) const

Definition at line 117 of file PrincipalGetAdapter.cc.

References n, and runTheMatrix::sel.

                                                                       {
    Selector sel(ModuleLabelSelector(label) &&
                 ProductInstanceNameSelector(productInstanceName) &&
                 ProcessNameSelector(processName));

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

Definition at line 157 of file PrincipalGetAdapter.h.

References principal_.

{return principal_;}
ProcessHistory const & PrincipalGetAdapter::processHistory ( ) const

Definition at line 133 of file PrincipalGetAdapter.cc.

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

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

Definition at line 176 of file PrincipalGetAdapter.cc.

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

                                       {
    return principal_.prodGetter();
  }

Member Data Documentation

Definition at line 237 of file PrincipalGetAdapter.h.

Definition at line 233 of file PrincipalGetAdapter.h.

Referenced by principal().