File indexing completed on 2024-04-06 12:13:10
0001 #ifndef FWCore_TestProcessor_ProcessBlock_h
0002 #define FWCore_TestProcessor_ProcessBlock_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021 #include <string>
0022
0023 #include "FWCore/TestProcessor/interface/TestHandle.h"
0024 #include "FWCore/Framework/interface/ProcessBlockPrincipal.h"
0025 #include "FWCore/Utilities/interface/TypeID.h"
0026
0027 namespace edm {
0028
0029 namespace test {
0030
0031 class ProcessBlock {
0032 public:
0033 ProcessBlock(ProcessBlockPrincipal const* iPrincipal, std::string iModuleLabel, std::string iProcessName);
0034
0035 template <typename T>
0036 TestHandle<T> get() const {
0037 static const std::string s_null;
0038 return get<T>(s_null);
0039 }
0040
0041 template <typename T>
0042 TestHandle<T> get(std::string const& iInstanceLabel) const {
0043 auto h = principal_->getByLabel(
0044 edm::PRODUCT_TYPE, edm::TypeID(typeid(T)), label_, iInstanceLabel, processName_, nullptr, nullptr, nullptr);
0045 if (h.failedToGet()) {
0046 return TestHandle<T>(std::move(h.whyFailedFactory()));
0047 }
0048 void const* basicWrapper = h.wrapper();
0049 assert(basicWrapper);
0050 Wrapper<T> const* wrapper = static_cast<Wrapper<T> const*>(basicWrapper);
0051 return TestHandle<T>(wrapper->product());
0052 }
0053
0054 private:
0055 ProcessBlockPrincipal const* principal_;
0056 std::string label_;
0057 std::string processName_;
0058 };
0059 }
0060 }
0061
0062 #endif