CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/FWCore/Framework/interface/ProductRegistryHelper.h

Go to the documentation of this file.
00001 #ifndef FWCore_Framework_ProductRegistryHelper_h
00002 #define FWCore_Framework_ProductRegistryHelper_h
00003 
00004 /*----------------------------------------------------------------------
00005   
00006 ProductRegistryHelper: 
00007 
00008 ----------------------------------------------------------------------*/
00009 
00010 #include "FWCore/Utilities/interface/TypeID.h"
00011 #include "DataFormats/Provenance/interface/BranchType.h"
00012 #include <string>
00013 #include <list>
00014 
00015 namespace edm {
00016   class WrapperOwningHolder;
00017   class ModuleDescription;
00018   class ProductRegistry;
00019   class ProductRegistryHelper {
00020   public:
00021 
00022     ProductRegistryHelper() : typeLabelList_() {}
00023     ~ProductRegistryHelper();
00024  
00025     struct TypeLabelItem {
00026       TypeLabelItem (BranchType const& branchType, TypeID const& tid, std::string const& pin) :
00027         branchType_(branchType),
00028         typeID_(tid),
00029         productInstanceName_(pin),
00030         branchAlias_() {}
00031       BranchType branchType_;
00032       TypeID typeID_;
00033       std::string productInstanceName_;
00034       mutable std::string branchAlias_;
00035       void setBranchAlias(std::string const& alias) const {branchAlias_ = alias;}
00036     };
00037 
00038     typedef std::list<TypeLabelItem> TypeLabelList;
00039 
00041     TypeLabelList & typeLabelList();
00042 
00043     static
00044     void addToRegistry(TypeLabelList::const_iterator const& iBegin,
00045                              TypeLabelList::const_iterator const& iEnd,
00046                              ModuleDescription const& iDesc,
00047                              ProductRegistry& iReg,
00048                              bool iIsListener=false);
00049 
00051 
00058     template <class ProductType> 
00059     TypeLabelItem const& produces() {
00060       return produces<ProductType, InEvent>(std::string());
00061     }
00062 
00063     template <class ProductType> 
00064     TypeLabelItem const& produces(std::string const& instanceName) {
00065       return produces<ProductType, InEvent>(instanceName);
00066     }
00067 
00068     template <typename ProductType, BranchType B> 
00069     TypeLabelItem const& produces() {
00070       return produces<ProductType, B>(std::string());
00071     }
00072 
00073     template <typename ProductType, BranchType B> 
00074     TypeLabelItem const& produces(std::string const& instanceName) {
00075       TypeID tid(typeid(ProductType));
00076       return produces<B>(tid,instanceName);
00077     }
00078 
00079    
00080     TypeLabelItem const& produces(const TypeID& id, std::string const& instanceName=std::string()) {
00081        return produces<InEvent>(id,instanceName);
00082     }
00083 
00084     template <BranchType B>
00085     TypeLabelItem const& produces(const TypeID& id, std::string const& instanceName=std::string()) {
00086        typeLabelList_.emplace_back(B, id, instanceName);
00087        return *typeLabelList_.rbegin();
00088     }
00089   private:
00090     TypeLabelList typeLabelList_;
00091   };
00092 
00093 
00094 }
00095 
00096 #endif