Go to the documentation of this file.00001 #ifndef Framework_Run_h
00002 #define Framework_Run_h
00003
00004
00005
00006
00007
00008
00016
00017
00018
00019
00020 #include "FWCore/Framework/interface/PrincipalGetAdapter.h"
00021 #include "FWCore/Framework/interface/Frameworkfwd.h"
00022 #include "FWCore/Common/interface/RunBase.h"
00023
00024 #include <memory>
00025 #include <set>
00026 #include <string>
00027 #include <typeinfo>
00028 #include <vector>
00029
00030 namespace edm {
00031
00032 class Run : public RunBase {
00033 public:
00034 Run(RunPrincipal& rp, ModuleDescription const& md);
00035 ~Run();
00036
00037 typedef PrincipalGetAdapter Base;
00038
00039 RunAuxiliary const& runAuxiliary() const {return aux_;}
00040
00041
00042
00043
00044
00045
00046 template <typename PROD>
00047 bool
00048 get(SelectorBase const&, Handle<PROD>& result) const;
00049
00050 template <typename PROD>
00051 bool
00052 getByLabel(std::string const& label, Handle<PROD>& result) const;
00053
00054 template <typename PROD>
00055 bool
00056 getByLabel(std::string const& label,
00057 std::string const& productInstanceName,
00058 Handle<PROD>& result) const;
00059
00061 template <typename PROD>
00062 bool
00063 getByLabel(InputTag const& tag, Handle<PROD>& result) const;
00064
00065 template <typename PROD>
00066 void
00067 getMany(SelectorBase const&, std::vector<Handle<PROD> >& results) const;
00068
00069 template <typename PROD>
00070 bool
00071 getByType(Handle<PROD>& result) const;
00072
00073 template <typename PROD>
00074 void
00075 getManyByType(std::vector<Handle<PROD> >& results) const;
00076
00078 template <typename PROD>
00079 void
00080 put(std::auto_ptr<PROD> product) {put<PROD>(product, std::string());}
00081
00083 template <typename PROD>
00084 void
00085 put(std::auto_ptr<PROD> product, std::string const& productInstanceName);
00086
00087 Provenance
00088 getProvenance(BranchID const& theID) const;
00089
00090 void
00091 getAllProvenance(std::vector<Provenance const*>& provenances) const;
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103 ProcessHistory const&
00104 processHistory() const;
00105
00106 private:
00107 RunPrincipal const&
00108 runPrincipal() const;
00109
00110 RunPrincipal&
00111 runPrincipal();
00112
00113
00114 virtual BasicHandle getByLabelImpl(std::type_info const& iWrapperType, std::type_info const& iProductType, InputTag const& iTag) const;
00115
00116 typedef std::vector<std::pair<EDProduct*, ConstBranchDescription const*> > ProductPtrVec;
00117 ProductPtrVec& putProducts() {return putProducts_;}
00118 ProductPtrVec const& putProducts() const {return putProducts_;}
00119
00120
00121
00122
00123
00124 friend class ConfigurableInputSource;
00125 friend class DaqSource;
00126 friend class InputSource;
00127 friend class RawInputSource;
00128 friend class EDFilter;
00129 friend class EDProducer;
00130
00131 void commit_();
00132 void addToGotBranchIDs(Provenance const& prov) const;
00133
00134 PrincipalGetAdapter provRecorder_;
00135 ProductPtrVec putProducts_;
00136 RunAuxiliary const& aux_;
00137 typedef std::set<BranchID> BranchIDSet;
00138 mutable BranchIDSet gotBranchIDs_;
00139 };
00140
00141 template <typename PROD>
00142 void
00143 Run::put(std::auto_ptr<PROD> product, std::string const& productInstanceName) {
00144 if (product.get() == 0) {
00145 TypeID typeID(typeid(PROD));
00146 principal_get_adapter_detail::throwOnPutOfNullProduct("Run", typeID, productInstanceName);
00147 }
00148
00149
00150
00151 typename boost::mpl::if_c<detail::has_postinsert<PROD>::value,
00152 DoPostInsert<PROD>,
00153 DoNotPostInsert<PROD> >::type maybe_inserter;
00154 maybe_inserter(product.get());
00155
00156 ConstBranchDescription const& desc =
00157 provRecorder_.getBranchDescription(TypeID(*product), productInstanceName);
00158
00159 Wrapper<PROD> *wp(new Wrapper<PROD>(product));
00160
00161 putProducts().push_back(std::make_pair(wp, &desc));
00162
00163
00164
00165 }
00166
00167 template <typename PROD>
00168 bool
00169 Run::get(SelectorBase const& sel, Handle<PROD>& result) const {
00170 return provRecorder_.get(sel, result);
00171 }
00172
00173 template <typename PROD>
00174 bool
00175 Run::getByLabel(std::string const& label, Handle<PROD>& result) const {
00176 return provRecorder_.getByLabel(label, result);
00177 }
00178
00179 template <typename PROD>
00180 bool
00181 Run::getByLabel(std::string const& label,
00182 std::string const& productInstanceName,
00183 Handle<PROD>& result) const {
00184 return provRecorder_.getByLabel(label, productInstanceName, result);
00185 }
00186
00188 template <typename PROD>
00189 bool
00190 Run::getByLabel(InputTag const& tag, Handle<PROD>& result) const {
00191 return provRecorder_.getByLabel(tag, result);
00192 }
00193
00194 template <typename PROD>
00195 void
00196 Run::getMany(SelectorBase const& sel, std::vector<Handle<PROD> >& results) const {
00197 return provRecorder_.getMany(sel, results);
00198 }
00199
00200 template <typename PROD>
00201 bool
00202 Run::getByType(Handle<PROD>& result) const {
00203 return provRecorder_.getByType(result);
00204 }
00205
00206 template <typename PROD>
00207 void
00208 Run::getManyByType(std::vector<Handle<PROD> >& results) const {
00209 return provRecorder_.getManyByType(results);
00210 }
00211
00212 }
00213 #endif