Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef FWCore_TestProcessor_Event_h
0002 #define FWCore_TestProcessor_Event_h
0003 // -*- C++ -*-
0004 //
0005 // Package:     FWCore/TestProcessor
0006 // Class  :     Event
0007 //
0008 /**\class Event Event.h "Event.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/EventPrincipal.h"
0027 #include "FWCore/Utilities/interface/TypeID.h"
0028 
0029 // forward declarations
0030 
0031 namespace edm {
0032   class EventPrincipal;
0033 
0034   namespace test {
0035 
0036     class Event {
0037     public:
0038       Event(EventPrincipal const& iPrincipal, std::string iModuleLabel, std::string iProcessName, bool modulePassed);
0039 
0040       // ---------- const member functions ---------------------
0041       template <typename T>
0042       TestHandle<T> get() const {
0043         static const std::string s_null;
0044         return get<T>(s_null);
0045       }
0046 
0047       template <typename T>
0048       TestHandle<T> get(std::string const& iInstanceLabel) const {
0049         auto h = principal_->getByLabel(
0050             edm::PRODUCT_TYPE, edm::TypeID(typeid(T)), label_, iInstanceLabel, processName_, nullptr, nullptr, nullptr);
0051         if (h.failedToGet()) {
0052           return TestHandle<T>(std::move(h.whyFailedFactory()));
0053         }
0054         void const* basicWrapper = h.wrapper();
0055         assert(basicWrapper);
0056         Wrapper<T> const* wrapper = static_cast<Wrapper<T> const*>(basicWrapper);
0057         return TestHandle<T>(wrapper->product());
0058       }
0059 
0060       bool modulePassed() const { return modulePassed_; }
0061       // ---------- static member functions --------------------
0062 
0063       // ---------- member functions ---------------------------
0064 
0065     private:
0066       // ---------- member data --------------------------------
0067       EventPrincipal const* principal_;
0068       std::string label_;
0069       std::string processName_;
0070       bool modulePassed_;
0071     };
0072   }  // namespace test
0073 }  // namespace edm
0074 
0075 #endif