Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:53:04

0001 // -*- C++ -*-
0002 //
0003 // Package:     EDProduct
0004 // Class  :     EDProductGetter
0005 //
0006 // Implementation:
0007 //     <Notes on implementation>
0008 //
0009 // Original Author:  Chris Jones
0010 //         Created:  Tue Nov  1 15:06:41 EST 2005
0011 //
0012 
0013 // system include files
0014 
0015 // user include files
0016 #include "DataFormats/Common/interface/EDProductGetter.h"
0017 #include "DataFormats/Provenance/interface/ProductID.h"
0018 #include "FWCore/Utilities/interface/EDMException.h"
0019 
0020 namespace edm {
0021   //
0022   // constants, enums and typedefs
0023   //
0024 
0025   //
0026   // static data member definitions
0027   //
0028 
0029   //
0030   // constructors and destructor
0031   //
0032   EDProductGetter::EDProductGetter() {}
0033 
0034   // EDProductGetter::EDProductGetter(EDProductGetter const& rhs)
0035   // {
0036   //    // do actual copying here;
0037   // }
0038 
0039   EDProductGetter::~EDProductGetter() {}
0040 
0041   //
0042   // assignment operators
0043   //
0044   // EDProductGetter const& EDProductGetter::operator=(EDProductGetter const& rhs)
0045   // {
0046   //   //An exception safe implementation is
0047   //   EDProductGetter temp(rhs);
0048   //   swap(rhs);
0049   //
0050   //   return *this;
0051   // }
0052 
0053   //
0054   // member functions
0055   //
0056 
0057   //
0058   // const member functions
0059   //
0060 
0061   //
0062   // static member functions
0063   //
0064 
0065   EDProductGetter const* mustBeNonZero(EDProductGetter const* prodGetter,
0066                                        std::string refType,
0067                                        ProductID const& productID) {
0068     if (prodGetter != nullptr)
0069       return prodGetter;
0070     throw Exception(errors::InvalidReference, refType)
0071         << "Attempt to construct a " << refType << " with ProductID " << productID << "\n"
0072         << "but with a null pointer to a product getter.\n"
0073         << "The product getter pointer passed to the constructor must refer\n"
0074         << "to a real getter, such as an EventPrincipal.\n";
0075   }
0076 
0077   thread_local EDProductGetter const* s_productGetter = nullptr;
0078   EDProductGetter const* EDProductGetter::switchProductGetter(EDProductGetter const* iNew) {
0079     //std::cout <<"switch from "<<s_productGetter<<" to "<<iNew<<std::endl;
0080     EDProductGetter const* old = s_productGetter;
0081     s_productGetter = iNew;
0082     return old;
0083   }
0084   void EDProductGetter::assignEDProductGetter(EDProductGetter const*& iGetter) {
0085     //std::cout <<"assign "<<s_productGetter<<std::endl;
0086 
0087     iGetter = s_productGetter;
0088   }
0089 
0090 }  // namespace edm