Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 09:47:57

0001 #ifndef FWCore_TestProcessor_LuminosityBlock_h
0002 #define FWCore_TestProcessor_LuminosityBlock_h
0003 // -*- C++ -*-
0004 //
0005 // Package:     FWCore/TestProcessor
0006 // Class  :     LuminosityBlock
0007 //
0008 /**\class LuminosityBlock LuminosityBlock.h "LuminosityBlock.h"
0009 
0010  Description: [one line class summary]
0011 
0012  Usage:
0013     <usage>
0014 
0015 */
0016 //
0017 // Original Author:  Chris Jones
0018 //         Created:  Mon, 30 Apr 2018 18:51:27 GMT
0019 //
0020 
0021 // system include files
0022 #include <string>
0023 
0024 // user include files
0025 #include "FWCore/TestProcessor/interface/TestHandle.h"
0026 #include "FWCore/Framework/interface/LuminosityBlockPrincipal.h"
0027 #include "FWCore/Utilities/interface/TypeID.h"
0028 
0029 // forward declarations
0030 
0031 namespace edm {
0032 
0033   namespace test {
0034 
0035     class LuminosityBlock {
0036     public:
0037       LuminosityBlock(std::shared_ptr<LuminosityBlockPrincipal const> iPrincipal,
0038                       std::string iModuleLabel,
0039                       std::string iProcessName);
0040 
0041       // ---------- const member functions ---------------------
0042       template <typename T>
0043       TestHandle<T> get() const {
0044         static const std::string s_null;
0045         return get<T>(s_null);
0046       }
0047 
0048       template <typename T>
0049       TestHandle<T> get(std::string const& iInstanceLabel) const {
0050         auto h = principal_->getByLabel(
0051             edm::PRODUCT_TYPE, edm::TypeID(typeid(T)), label_, iInstanceLabel, processName_, nullptr, nullptr, nullptr);
0052         if (h.failedToGet()) {
0053           return TestHandle<T>(std::move(h.whyFailedFactory()));
0054         }
0055         void const* basicWrapper = h.wrapper();
0056         assert(basicWrapper);
0057         Wrapper<T> const* wrapper = static_cast<Wrapper<T> const*>(basicWrapper);
0058         return TestHandle<T>(wrapper->product());
0059       }
0060       // ---------- static member functions --------------------
0061 
0062       // ---------- member functions ---------------------------
0063 
0064     private:
0065       // ---------- member data --------------------------------
0066       std::shared_ptr<LuminosityBlockPrincipal const> principal_;
0067       std::string label_;
0068       std::string processName_;
0069     };
0070   }  // namespace test
0071 }  // namespace edm
0072 
0073 #endif