Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:29:08

0001 #include "FWCore/ServiceRegistry/interface/ProcessContext.h"
0002 #include "FWCore/Utilities/interface/EDMException.h"
0003 
0004 #include <ostream>
0005 
0006 namespace edm {
0007 
0008   ProcessContext::ProcessContext() : processConfiguration_(nullptr), parentProcessContext_(nullptr) {}
0009 
0010   ProcessContext const& ProcessContext::parentProcessContext() const {
0011     if (!isSubProcess()) {
0012       throw Exception(errors::LogicError)
0013           << "ProcessContext::parentProcessContext This function should only be called for SubProcesses.\n"
0014           << "If necessary, you can check this by calling isSubProcess first.\n";
0015     }
0016     return *parentProcessContext_;
0017   }
0018 
0019   void ProcessContext::setProcessConfiguration(ProcessConfiguration const* processConfiguration) {
0020     processConfiguration_ = processConfiguration;
0021   }
0022 
0023   void ProcessContext::setParentProcessContext(ProcessContext const* parentProcessContext) {
0024     parentProcessContext_ = parentProcessContext;
0025   }
0026 
0027   std::ostream& operator<<(std::ostream& os, ProcessContext const& pc) {
0028     os << "ProcessContext: ";
0029     if (pc.processConfiguration()) {
0030       os << pc.processConfiguration()->processName() << " " << pc.processConfiguration()->parameterSetID() << "\n";
0031     } else {
0032       os << "invalid\n";
0033       return os;
0034     }
0035     if (pc.isSubProcess()) {
0036       os << "    parent " << pc.parentProcessContext();
0037     }
0038     return os;
0039   }
0040 }  // namespace edm