CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2/src/FWCore/Framework/src/UnscheduledHandler.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:     Framework
00004 // Class  :     UnscheduledHandler
00005 //
00006 // Implementation:
00007 //     <Notes on implementation>
00008 //
00009 // Original Author:  Chris Jones
00010 //         Created:  Mon Oct 13 13:58:07 CEST 2008
00011 //
00012 
00013 // system include files
00014 #include <cassert>
00015 #include <iostream>
00016 
00017 // user include files
00018 #include "FWCore/Framework/interface/UnscheduledHandler.h"
00019 #include "FWCore/Framework/interface/CurrentProcessingContext.h"
00020 
00021 
00022 namespace edm {
00023   //
00024   // constants, enums and typedefs
00025   //
00026 
00027   //
00028   // static data member definitions
00029   //
00030 
00031   //
00032   // constructors and destructor
00033   //
00034   //UnscheduledHandler::UnscheduledHandler() {
00035   //}
00036 
00037   // UnscheduledHandler::UnscheduledHandler(UnscheduledHandler const& rhs)  {
00038   //    // do actual copying here;
00039   // }
00040 
00041   UnscheduledHandler::~UnscheduledHandler() {
00042   }
00043 
00044   //
00045   // assignment operators
00046   //
00047   // UnscheduledHandler const& UnscheduledHandler::operator=(UnscheduledHandler const& rhs) {
00048   //   //An exception safe implementation is
00049   //   UnscheduledHandler temp(rhs);
00050   //   swap(rhs);
00051   //
00052   //   return *this;
00053   // }
00054 
00055   //
00056   // member functions
00057   //
00058   CurrentProcessingContext const*
00059   UnscheduledHandler::setCurrentProcessingContext(CurrentProcessingContext const* iContext) {
00060      CurrentProcessingContext const* old = m_context;
00061      m_context = iContext;
00062      return old;
00063   }
00064 
00065   /*
00066   void
00067   UnscheduledHandler::popCurrentProcessingContext() {
00068   }
00069   */
00070 
00071   bool
00072   UnscheduledHandler::tryToFill(std::string const& label,
00073                                 EventPrincipal& iEvent) {
00074      assert(m_setup);
00075      CurrentProcessingContext const* chosen = m_context;
00076      CurrentProcessingContext temp;
00077      if(0 != m_context) {
00078         temp = *m_context;
00079         temp.setUnscheduledDepth(m_context->unscheduledDepth());
00080         chosen = &temp;
00081      }
00082      UnscheduledHandlerSentry sentry(this, chosen);
00083      return tryToFillImpl(label, iEvent, *m_setup, chosen);
00084   }
00085 
00086   //
00087   // const member functions
00088   //
00089 
00090   //
00091   // static member functions
00092   //
00093 //-------------
00094 
00095    UnscheduledHandlerSentry::UnscheduledHandlerSentry(UnscheduledHandler* iHandler,
00096                                CurrentProcessingContext const* iContext) :
00097    m_handler(iHandler),
00098    m_old(0) {
00099       if(m_handler) {
00100           m_old = iHandler->setCurrentProcessingContext(iContext);
00101       }
00102    }
00103 
00104    UnscheduledHandlerSentry::~UnscheduledHandlerSentry() {
00105       if(m_handler) {
00106          m_handler->setCurrentProcessingContext(m_old);
00107       }
00108    }
00109 }