Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:13:03

0001 #include "FWCore/ServiceRegistry/interface/ESModuleCallingContext.h"
0002 #include "FWCore/ServiceRegistry/interface/ParentContext.h"
0003 #include "FWCore/ServiceRegistry/interface/ModuleCallingContext.h"
0004 #include "FWCore/Utilities/interface/EDMException.h"
0005 
0006 #include <ostream>
0007 
0008 namespace edm {
0009 
0010   ESModuleCallingContext::ESModuleCallingContext(edm::eventsetup::ComponentDescription const* componentDescription,
0011                                                  std::uintptr_t id)
0012       : componentDescription_(componentDescription), parent_(), id_(id), state_(State::kInvalid) {}
0013 
0014   ESModuleCallingContext::ESModuleCallingContext(edm::eventsetup::ComponentDescription const* componentDescription,
0015                                                  std::uintptr_t id,
0016                                                  State state,
0017                                                  ESParentContext const& parent)
0018       : componentDescription_(componentDescription), parent_(parent), id_(id), state_(state) {}
0019 
0020   void ESModuleCallingContext::setContext(State state, ESParentContext const& parent) {
0021     state_ = state;
0022     parent_ = parent;
0023   }
0024 
0025   ModuleCallingContext const* ESModuleCallingContext::getTopModuleCallingContext() const {
0026     ESModuleCallingContext const* mcc = this;
0027     while (mcc->type() == ESParentContext::Type::kESModule) {
0028       mcc = mcc->esmoduleCallingContext();
0029     }
0030     return mcc->moduleCallingContext()->getTopModuleCallingContext();
0031   }
0032 
0033   unsigned ESModuleCallingContext::depth() const {
0034     unsigned depth = 0;
0035     ESModuleCallingContext const* mcc = this;
0036     while (mcc->type() == ESParentContext::Type::kESModule) {
0037       ++depth;
0038       mcc = mcc->esmoduleCallingContext();
0039     }
0040     return depth + mcc->moduleCallingContext()->depth();
0041   }
0042 
0043 }  // namespace edm