Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-24 09:53:11

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       : componentDescription_(componentDescription), parent_(), state_(State::kInvalid) {}
0012 
0013   ESModuleCallingContext::ESModuleCallingContext(edm::eventsetup::ComponentDescription const* componentDescription,
0014                                                  State state,
0015                                                  ESParentContext const& parent)
0016       : componentDescription_(componentDescription), parent_(parent), state_(state) {}
0017 
0018   void ESModuleCallingContext::setContext(State state, ESParentContext const& parent) {
0019     state_ = state;
0020     parent_ = parent;
0021   }
0022 
0023   ModuleCallingContext const* ESModuleCallingContext::getTopModuleCallingContext() const {
0024     ESModuleCallingContext const* mcc = this;
0025     while (mcc->type() == ESParentContext::Type::kESModule) {
0026       mcc = mcc->esmoduleCallingContext();
0027     }
0028     return mcc->moduleCallingContext()->getTopModuleCallingContext();
0029   }
0030 
0031   unsigned ESModuleCallingContext::depth() const {
0032     unsigned depth = 0;
0033     ESModuleCallingContext const* mcc = this;
0034     while (mcc->type() == ESParentContext::Type::kESModule) {
0035       ++depth;
0036       mcc = mcc->esmoduleCallingContext();
0037     }
0038     return depth + mcc->moduleCallingContext()->depth();
0039   }
0040 
0041 }  // namespace edm