CMS 3D CMS Logo

ProductRegistryHelper.h
Go to the documentation of this file.
1 #ifndef FWCore_Framework_ProductRegistryHelper_h
2 #define FWCore_Framework_ProductRegistryHelper_h
3 
4 /*----------------------------------------------------------------------
5 
6 ProductRegistryHelper:
7 
8 ----------------------------------------------------------------------*/
9 
14 #include <string>
15 #include <vector>
16 #include <type_traits>
17 
18 namespace edm {
19  class ModuleDescription;
20  class ProductRegistry;
21  class DoNotRecordParents;
22 
24  public:
25 
28 
29  // has_donotrecordparents<T>::value is true if we should not
30  // record parentage for type T, and false otherwise.
31  template <typename T>
33  static constexpr bool value =
35  };
36 
37  struct TypeLabelItem {
38  TypeLabelItem (Transition const& transition, TypeID const& tid, std::string pin) :
39  transition_(transition),
40  typeID_(tid),
41  productInstanceName_(std::move(pin)),
42  branchAlias_() {}
47  };
48 
51  value_(iItem), token_(std::move(iToken)) {}
52 
54  value_.branchAlias_ = std::move(alias);
55  return *this;
56  }
59 
60  operator EDPutToken() { return token_;}
61  };
62 
63  template <typename T>
66  value_(iItem), token_(std::move(iToken)) {}
67 
69  value_(iS.value_), token_(iS.token_.index()) {}
70 
72  value_.branchAlias_ = std::move(alias);
73  return *this;
74  }
77 
78  operator EDPutTokenT<T>() { return token_;}
79  operator EDPutToken() { return EDPutToken(token_.index()); }
80  };
81 
82  typedef std::vector<TypeLabelItem> TypeLabelList;
83 
85  TypeLabelList const& typeLabelList() const;
86 
87  std::vector<bool> const& recordProvenanceList() const { return recordProvenanceList_;}
88 
89  static
90  void addToRegistry(TypeLabelList::const_iterator const& iBegin,
91  TypeLabelList::const_iterator const& iEnd,
92  ModuleDescription const& iDesc,
93  ProductRegistry& iReg,
94  bool iIsListener=false);
95 
97 
104  template <class ProductType>
106  return produces<ProductType, InEvent>(std::string());
107  }
108 
109  template <class ProductType>
111  return produces<ProductType, InEvent>( std::move(instanceName));
112  }
113 
114  template <typename ProductType, BranchType B>
116  return produces<ProductType, B>(std::string());
117  }
118 
119  template <typename ProductType, BranchType B>
121  TypeID tid(typeid(ProductType));
122  return BranchAliasSetterT<ProductType>{produces<B>(tid,std::move(instanceName),
124  }
125 
126  template <typename ProductType, Transition B>
128  return produces<ProductType, B>(std::string());
129  }
130 
131  template <typename ProductType, Transition B>
133  TypeID tid(typeid(ProductType));
134  return BranchAliasSetterT<ProductType>{produces<B>(tid,std::move(instanceName),
136  }
137 
138 
139  BranchAliasSetter produces(const TypeID& id, std::string instanceName=std::string(), bool recordProvenance = true) {
140  return produces<Transition::Event>(id,std::move(instanceName),recordProvenance);
141  }
142 
143  template <BranchType B>
144  BranchAliasSetter produces(const TypeID& id, std::string instanceName=std::string(), bool recordProvenance = true) {
145  unsigned int index =typeLabelList_.size();
147  recordProvenanceList_.push_back(recordProvenance and B == InEvent);
148  return BranchAliasSetter{typeLabelList_.back(),EDPutToken{static_cast<unsigned int>(index)}};
149  }
150  template <Transition B>
151  BranchAliasSetter produces(const TypeID& id, std::string instanceName=std::string(), bool recordProvenance = true) {
152  unsigned int index =typeLabelList_.size();
153  typeLabelList_.emplace_back(B, id, std::move(instanceName));
154  recordProvenanceList_.push_back(recordProvenance and B == Transition::Event);
155  return BranchAliasSetter{typeLabelList_.back(),EDPutToken{ index }};
156  }
157 
158  private:
159  TypeLabelList typeLabelList_;
160  std::vector<bool> recordProvenanceList_;
161  };
162 
163 
164 }
165 
166 #endif
BranchAliasSetterT< ProductType > produces()
declare what type of product will make and with which optional label
value_type index() const
Definition: EDPutToken.h:75
std::vector< bool > const & recordProvenanceList() const
TypeLabelList const & typeLabelList() const
used by the fwk to register the list of products of this module
BranchAliasSetterT< T > & setBranchAlias(std::string alias)
BranchAliasSetterT< ProductType > produces(std::string instanceName)
#define constexpr
BranchAliasSetterT(TypeLabelItem &iItem, EDPutTokenT< T > iToken)
BranchAliasSetter produces(const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
TypeLabelItem(Transition const &transition, TypeID const &tid, std::string pin)
std::vector< TypeLabelItem > TypeLabelList
Transition
Definition: Transition.h:12
Definition: value.py:1
BranchAliasSetterT< ProductType > produces(std::string instanceName)
static const std::string B
BranchAliasSetter(TypeLabelItem &iItem, EDPutToken iToken)
constexpr Transition convertToTransition(BranchType iValue)
Definition: Transition.h:26
HLT enums.
BranchAliasSetterT< ProductType > produces()
BranchAliasSetter & setBranchAlias(std::string alias)
std::vector< bool > recordProvenanceList_
static void addToRegistry(TypeLabelList::const_iterator const &iBegin, TypeLabelList::const_iterator const &iEnd, ModuleDescription const &iDesc, ProductRegistry &iReg, bool iIsListener=false)
def move(src, dest)
Definition: eostools.py:510
BranchAliasSetter produces(const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)