CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EDProductGetter.h
Go to the documentation of this file.
1 #ifndef DataFormats_Common_EDProductGetter_h
2 #define DataFormats_Common_EDProductGetter_h
3 // -*- C++ -*-
4 //
5 // Class : EDProductGetter
6 //
14 //
15 // Original Author: Chris Jones
16 // Created: Tue Nov 1 15:06:31 EST 2005
17 //
18 
19 // user include files
20 
21 // system include files
22 #include <string>
23 #include <vector>
24 
25 #include "boost/utility.hpp"
26 
27 // forward declarations
28 
29 namespace edm {
30 
31  class ProductID;
32  class WrapperBase;
33 
35 
36  public:
37 
39  virtual ~EDProductGetter();
40 
41  EDProductGetter(EDProductGetter const&) = delete; // stop default
42 
43  EDProductGetter const& operator=(EDProductGetter const&) = delete; // stop default
44 
45  // ---------- const member functions ---------------------
46  virtual WrapperBase const* getIt(ProductID const&) const = 0;
47 
48  // getThinnedProduct assumes getIt was already called and failed to find
49  // the product. The input key is the index of the desired element in the
50  // container identified by ProductID (which cannot be found).
51  // If the return value is not null, then the desired element was found
52  // in a thinned container and key is modified to be the index into
53  // that thinned container. If the desired element is not found, then
54  // nullptr is returned.
55  virtual WrapperBase const* getThinnedProduct(ProductID const&, unsigned int& key) const = 0;
56 
57  // getThinnedProducts assumes getIt was already called and failed to find
58  // the product. The input keys are the indexes into the container identified
59  // by ProductID (which cannot be found). On input the WrapperBase pointers
60  // must all be set to nullptr (except when the function calls itself
61  // recursively where non-null pointers mark already found elements).
62  // Thinned containers derived from the product are searched to see
63  // if they contain the desired elements. For each that is
64  // found, the corresponding WrapperBase pointer is set and the key
65  // is modified to be the key into the container where the element
66  // was found. The WrapperBase pointers might or might not all point
67  // to the same thinned container.
68  virtual void getThinnedProducts(ProductID const& pid,
69  std::vector<WrapperBase const*>& foundContainers,
70  std::vector<unsigned int>& keys) const = 0;
71 
72  unsigned int transitionIndex() const {
73  return transitionIndex_();
74  }
75 
76  // ---------- member functions ---------------------------
77 
80  static void assignEDProductGetter(EDProductGetter const*&);
81 
82 private:
83  virtual unsigned int transitionIndex_() const = 0;
84 
85  // ---------- member data --------------------------------
86 
87  };
88 
89  EDProductGetter const*
90  mustBeNonZero(EDProductGetter const* prodGetter, std::string refType, ProductID const& productID);
91 }
92 #endif
EDProductGetter const * mustBeNonZero(EDProductGetter const *prodGetter, std::string refType, ProductID const &productID)
virtual void getThinnedProducts(ProductID const &pid, std::vector< WrapperBase const * > &foundContainers, std::vector< unsigned int > &keys) const =0
virtual WrapperBase const * getIt(ProductID const &) const =0
virtual WrapperBase const * getThinnedProduct(ProductID const &, unsigned int &key) const =0
EDProductGetter const & operator=(EDProductGetter const &)=delete
tuple pid
Definition: sysUtil.py:22
unsigned int transitionIndex() const
virtual unsigned int transitionIndex_() const =0
static void assignEDProductGetter(EDProductGetter const *&)
static EDProductGetter const * switchProductGetter(EDProductGetter const *)
These can only be used internally by the framework.