File indexing completed on 2023-10-25 09:46:51
0001 #ifndef FWCore_Framework_ModuleContextSentry_h
0002 #define FWCore_Framework_ModuleContextSentry_h
0003
0004 #include "FWCore/ServiceRegistry/interface/CurrentModuleOnThread.h"
0005 #include "FWCore/ServiceRegistry/interface/ModuleCallingContext.h"
0006 #include "FWCore/ServiceRegistry/interface/ParentContext.h"
0007 #include "FWCore/Utilities/interface/propagate_const.h"
0008
0009 namespace edm {
0010
0011 class ModuleContextSentry {
0012 public:
0013 ModuleContextSentry(ModuleCallingContext* moduleCallingContext, ParentContext const& parentContext)
0014 : moduleCallingContext_(moduleCallingContext) {
0015 moduleCallingContext_->setContext(
0016 ModuleCallingContext::State::kRunning, parentContext, CurrentModuleOnThread::getCurrentModuleOnThread());
0017 CurrentModuleOnThread::setCurrentModuleOnThread(moduleCallingContext_);
0018 }
0019 ~ModuleContextSentry() {
0020 CurrentModuleOnThread::setCurrentModuleOnThread(moduleCallingContext_->previousModuleOnThread());
0021 moduleCallingContext_->setContext(ModuleCallingContext::State::kInvalid, ParentContext(), nullptr);
0022 }
0023
0024 private:
0025 edm::propagate_const<ModuleCallingContext*> moduleCallingContext_;
0026 };
0027 }
0028 #endif