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  struct DoNotRecordParents;
22 
24  public:
25  virtual ~ProductRegistryHelper() noexcept(false);
27 
28  // has_donotrecordparents<T>::value is true if we should not
29  // record parentage for type T, and false otherwise.
30  template <typename T>
32  static constexpr bool value =
34  };
35 
36  struct TypeLabelItem {
37  TypeLabelItem (Transition const& transition, TypeID const& tid, std::string pin) :
38  transition_(transition),
39  typeID_(tid),
40  productInstanceName_(std::move(pin)),
41  branchAlias_() {}
46  };
47 
50  value_(iItem), token_(std::move(iToken)) {}
51 
53  value_.branchAlias_ = std::move(alias);
54  return *this;
55  }
58 
59  operator EDPutToken() { return token_;}
60  };
61 
62  template <typename T>
65  value_(iItem), token_(std::move(iToken)) {}
66 
68  value_(iS.value_), token_(iS.token_.index()) {}
69 
71  value_.branchAlias_ = std::move(alias);
72  return *this;
73  }
76 
77  operator EDPutTokenT<T>() { return token_;}
78  operator EDPutToken() { return EDPutToken(token_.index()); }
79  };
80 
81  typedef std::vector<TypeLabelItem> TypeLabelList;
82 
84  TypeLabelList const& typeLabelList() const;
85 
86  std::vector<bool> const& recordProvenanceList() const { return recordProvenanceList_;}
87 
88  static
89  void addToRegistry(TypeLabelList::const_iterator const& iBegin,
90  TypeLabelList::const_iterator const& iEnd,
91  ModuleDescription const& iDesc,
92  ProductRegistry& iReg,
93  ProductRegistryHelper* iProd,
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  virtual bool hasAbilityToProduceInRuns() const {
159  return false;
160  }
161 
162  virtual bool hasAbilityToProduceInLumis() const {
163  return false;
164  }
165 
166  private:
167  TypeLabelList typeLabelList_;
168  std::vector<bool> recordProvenanceList_;
169  };
170 
171 
172 }
173 
174 #endif
BranchAliasSetterT< ProductType > produces()
declare what type of product will make and with which optional label
value_type index() const
Definition: EDPutToken.h:79
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)
#define noexcept
virtual ~ProductRegistryHelper() noexcept(false)
static void addToRegistry(TypeLabelList::const_iterator const &iBegin, TypeLabelList::const_iterator const &iEnd, ModuleDescription const &iDesc, ProductRegistry &iReg, ProductRegistryHelper *iProd, bool iIsListener=false)
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)
virtual bool hasAbilityToProduceInRuns() const
std::vector< TypeLabelItem > TypeLabelList
Transition
Definition: Transition.h:12
Definition: value.py:1
BranchAliasSetterT< ProductType > produces(std::string instanceName)
static const std::string B
virtual bool hasAbilityToProduceInLumis() const
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_
def move(src, dest)
Definition: eostools.py:511
BranchAliasSetter produces(const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)