CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EDProductGetter.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: EDProduct
4 // Class : EDProductGetter
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author: Chris Jones
10 // Created: Tue Nov 1 15:06:41 EST 2005
11 //
12 
13 // system include files
14 
15 // user include files
18 
19 namespace edm {
20  //
21  // constants, enums and typedefs
22  //
23 
24  //
25  // static data member definitions
26  //
27 
28  //
29  // constructors and destructor
30  //
32  {
33  }
34 
35  // EDProductGetter::EDProductGetter(EDProductGetter const& rhs)
36  // {
37  // // do actual copying here;
38  // }
39 
41  {
42  }
43 
44  //
45  // assignment operators
46  //
47  // EDProductGetter const& EDProductGetter::operator=(EDProductGetter const& rhs)
48  // {
49  // //An exception safe implementation is
50  // EDProductGetter temp(rhs);
51  // swap(rhs);
52  //
53  // return *this;
54  // }
55 
56  //
57  // member functions
58  //
59 
60  //
61  // const member functions
62  //
63 
64  //
65  // static member functions
66  //
67 
68  EDProductGetter const*
69  mustBeNonZero(EDProductGetter const* prodGetter, std::string refType, ProductID const& productID) {
70  if (prodGetter != nullptr) return prodGetter;
71  throw Exception(errors::InvalidReference, refType)
72  << "Attempt to construct a " << refType << " with ProductID " << productID << "\n"
73  << "but with a null pointer to a product getter.\n"
74  << "The product getter pointer passed to the constructor must refer\n"
75  << "to a real getter, such as an EventPrincipal.\n";
76  }
77 
78  thread_local EDProductGetter const* s_productGetter = nullptr;
79  EDProductGetter const*
81  {
82  //std::cout <<"switch from "<<s_productGetter<<" to "<<iNew<<std::endl;
83  EDProductGetter const* old = s_productGetter;
84  s_productGetter = iNew;
85  return old;
86  }
87  void
89  {
90  //std::cout <<"assign "<<s_productGetter<<std::endl;
91 
92  iGetter = s_productGetter;
93  }
94 
95 
96 }
EDProductGetter const * mustBeNonZero(EDProductGetter const *prodGetter, std::string refType, ProductID const &productID)
thread_local EDProductGetter const * s_productGetter
static void assignEDProductGetter(EDProductGetter const *&)
static EDProductGetter const * switchProductGetter(EDProductGetter const *)
These can only be used internally by the framework.