CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/FWCore/Framework/interface/LuminosityBlock.h

Go to the documentation of this file.
00001 #ifndef Framework_LuminosityBlock_h
00002 #define Framework_LuminosityBlock_h
00003 
00004 // -*- C++ -*-
00005 //
00006 // Package:     Framework
00007 // Class  :     LuminosityBlock
00008 //
00017 /*----------------------------------------------------------------------
00018 
00019 ----------------------------------------------------------------------*/
00020 
00021 #include "FWCore/Common/interface/LuminosityBlockBase.h"
00022 #include "FWCore/Framework/interface/Frameworkfwd.h"
00023 #include "FWCore/Framework/interface/PrincipalGetAdapter.h"
00024 
00025 #include "boost/shared_ptr.hpp"
00026 
00027 #include <memory>
00028 #include <set>
00029 #include <string>
00030 #include <typeinfo>
00031 #include <vector>
00032 
00033 namespace edm {
00034 
00035   class LuminosityBlock : public LuminosityBlockBase {
00036   public:
00037     LuminosityBlock(LuminosityBlockPrincipal& lbp, ModuleDescription const& md);
00038     ~LuminosityBlock();
00039 
00040     // AUX functions are defined in LuminosityBlockBase
00041     LuminosityBlockAuxiliary const& luminosityBlockAuxiliary() const {return aux_;}
00042 
00043     template <typename PROD>
00044     bool
00045     get(SelectorBase const&, Handle<PROD>& result) const;
00046 
00047     template <typename PROD>
00048     bool
00049     getByLabel(std::string const& label, Handle<PROD>& result) const;
00050 
00051     template <typename PROD>
00052     bool
00053     getByLabel(std::string const& label,
00054                std::string const& productInstanceName,
00055                Handle<PROD>& result) const;
00056 
00058     template <typename PROD>
00059     bool
00060     getByLabel(InputTag const& tag, Handle<PROD>& result) const;
00061 
00062     template <typename PROD>
00063     void
00064     getMany(SelectorBase const&, std::vector<Handle<PROD> >& results) const;
00065 
00066     template <typename PROD>
00067     bool
00068     getByType(Handle<PROD>& result) const;
00069 
00070     template <typename PROD>
00071     void
00072     getManyByType(std::vector<Handle<PROD> >& results) const;
00073 
00074     Run const&
00075     getRun() const {
00076       return *run_;
00077     }
00078 
00080     template <typename PROD>
00081     void
00082     put(std::auto_ptr<PROD> product) {put<PROD>(product, std::string());}
00083 
00085     template <typename PROD>
00086     void
00087     put(std::auto_ptr<PROD> product, std::string const& productInstanceName);
00088 
00089     Provenance
00090     getProvenance(BranchID const& theID) const;
00091 
00092     void
00093     getAllProvenance(std::vector<Provenance const*>& provenances) const;
00094 
00095     ProcessHistory const&
00096     processHistory() const;
00097 
00098   private:
00099     LuminosityBlockPrincipal const&
00100     luminosityBlockPrincipal() const;
00101 
00102     LuminosityBlockPrincipal&
00103     luminosityBlockPrincipal();
00104 
00105     // Override version from LuminosityBlockBase class
00106     virtual BasicHandle getByLabelImpl(std::type_info const& iWrapperType, std::type_info const& iProductType, InputTag const& iTag) const;
00107 
00108     typedef std::vector<std::pair<EDProduct*, ConstBranchDescription const*> > ProductPtrVec;
00109     ProductPtrVec& putProducts() {return putProducts_;}
00110     ProductPtrVec const& putProducts() const {return putProducts_;}
00111 
00112     // commit_() is called to complete the transaction represented by
00113     // this PrincipalGetAdapter. The friendships required seems gross, but any
00114     // alternative is not great either.  Putting it into the
00115     // public interface is asking for trouble
00116     friend class ConfigurableInputSource;
00117     friend class InputSource;
00118     friend class DaqSource;
00119     friend class RawInputSource;
00120     friend class EDFilter;
00121     friend class EDProducer;
00122 
00123     void commit_();
00124     void addToGotBranchIDs(Provenance const& prov) const;
00125 
00126     PrincipalGetAdapter provRecorder_;
00127     ProductPtrVec putProducts_;
00128     LuminosityBlockAuxiliary const& aux_;
00129     boost::shared_ptr<Run const> const run_;
00130     typedef std::set<BranchID> BranchIDSet;
00131     mutable BranchIDSet gotBranchIDs_;
00132   };
00133 
00134   template <typename PROD>
00135   void
00136   LuminosityBlock::put(std::auto_ptr<PROD> product, std::string const& productInstanceName) {
00137     if (product.get() == 0) {                // null pointer is illegal
00138       TypeID typeID(typeid(PROD));
00139       principal_get_adapter_detail::throwOnPutOfNullProduct("LuminosityBlock", typeID, productInstanceName);
00140     }
00141 
00142     // The following will call post_insert if T has such a function,
00143     // and do nothing if T has no such function.
00144     typename boost::mpl::if_c<detail::has_postinsert<PROD>::value,
00145       DoPostInsert<PROD>,
00146       DoNotPostInsert<PROD> >::type maybe_inserter;
00147     maybe_inserter(product.get());
00148 
00149     ConstBranchDescription const& desc =
00150       provRecorder_.getBranchDescription(TypeID(*product), productInstanceName);
00151 
00152     Wrapper<PROD> *wp(new Wrapper<PROD>(product));
00153 
00154     putProducts().push_back(std::make_pair(wp, &desc));
00155 
00156     // product.release(); // The object has been copied into the Wrapper.
00157     // The old copy must be deleted, so we cannot release ownership.
00158   }
00159 
00160   template <typename PROD>
00161   bool
00162   LuminosityBlock::get(SelectorBase const& sel, Handle<PROD>& result) const {
00163     return provRecorder_.get(sel,result);
00164   }
00165 
00166   template <typename PROD>
00167   bool
00168   LuminosityBlock::getByLabel(std::string const& label, Handle<PROD>& result) const {
00169     return provRecorder_.getByLabel(label,result);
00170   }
00171 
00172   template <typename PROD>
00173   bool
00174   LuminosityBlock::getByLabel(std::string const& label,
00175                   std::string const& productInstanceName,
00176                   Handle<PROD>& result) const {
00177     return provRecorder_.getByLabel(label,productInstanceName,result);
00178   }
00179 
00181   template <typename PROD>
00182   bool
00183   LuminosityBlock::getByLabel(InputTag const& tag, Handle<PROD>& result) const {
00184     return provRecorder_.getByLabel(tag,result);
00185   }
00186 
00187   template <typename PROD>
00188   void
00189   LuminosityBlock::getMany(SelectorBase const& sel, std::vector<Handle<PROD> >& results) const {
00190     return provRecorder_.getMany(sel,results);
00191   }
00192 
00193   template <typename PROD>
00194   bool
00195   LuminosityBlock::getByType(Handle<PROD>& result) const {
00196     return provRecorder_.getByType(result);
00197   }
00198 
00199   template <typename PROD>
00200   void
00201   LuminosityBlock::getManyByType(std::vector<Handle<PROD> >& results) const {
00202     return provRecorder_.getManyByType(results);
00203   }
00204 
00205 }
00206 #endif