CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch1/src/FWCore/Framework/src/RunPrincipal.cc

Go to the documentation of this file.
00001 #include "FWCore/Framework/interface/RunPrincipal.h"
00002 
00003 #include "DataFormats/Common/interface/WrapperOwningHolder.h"
00004 #include "DataFormats/Provenance/interface/ProcessHistoryRegistry.h"
00005 #include "DataFormats/Provenance/interface/ProductRegistry.h"
00006 #include "FWCore/Framework/interface/DelayedReader.h"
00007 #include "FWCore/Framework/interface/Group.h"
00008 #include "FWCore/Utilities/interface/EDMException.h"
00009 
00010 namespace edm {
00011   RunPrincipal::RunPrincipal(
00012     boost::shared_ptr<RunAuxiliary> aux,
00013     boost::shared_ptr<ProductRegistry const> reg,
00014     ProcessConfiguration const& pc,
00015     HistoryAppender* historyAppender) :
00016     Base(reg, pc, InRun, historyAppender),
00017       aux_(aux) {
00018   }
00019 
00020   void
00021   RunPrincipal::fillRunPrincipal(DelayedReader* reader) {
00022 
00023     fillPrincipal(aux_->processHistoryID(), reader);
00024 
00025     for (const_iterator i = this->begin(), iEnd = this->end(); i != iEnd; ++i) {
00026       (*i)->setProcessHistoryID(processHistoryID());
00027     }
00028   }
00029 
00030   void
00031   RunPrincipal::put(
00032         ConstBranchDescription const& bd,
00033         WrapperOwningHolder const& edp) {
00034 
00035     assert(bd.produced());
00036     if(!edp.isValid()) {
00037       throw edm::Exception(edm::errors::InsertFailure,"Null Pointer")
00038         << "put: Cannot put because auto_ptr to product is null."
00039         << "\n";
00040     }
00041     Group *g = getExistingGroup(bd.branchID());
00042     assert(g);
00043     // Group assumes ownership
00044     putOrMerge(edp, g);
00045   }
00046 
00047   void
00048   RunPrincipal::readImmediate() const {
00049     for (Principal::const_iterator i = begin(), iEnd = end(); i != iEnd; ++i) {
00050       Group const& g = **i;
00051       if(!g.branchDescription().produced()) {
00052         if(!g.productUnavailable()) {
00053           resolveProductImmediate(g);
00054         }
00055       }
00056     }
00057   }
00058 
00059   void
00060   RunPrincipal::resolveProductImmediate(Group const& g) const {
00061     if(g.branchDescription().produced()) return; // nothing to do.
00062     if(!reader()) return; // nothing to do.
00063 
00064     // must attempt to load from persistent store
00065     BranchKey const bk = BranchKey(g.branchDescription());
00066     WrapperOwningHolder edp(reader()->getProduct(bk, g.productData().getInterface(), this));
00067 
00068     // Now fix up the Group
00069     if(edp.isValid()) {
00070       putOrMerge(edp, &g);
00071     }
00072   }
00073 }