CMS 3D CMS Logo

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 $Id: ProductRegistryHelper.h,v 1.14 2008/02/12 21:46:26 chrjones Exp $
00009 
00010 
00011 ----------------------------------------------------------------------*/
00012 
00013 #include "FWCore/Utilities/interface/TypeID.h"
00014 #include "DataFormats/Provenance/interface/BranchType.h"
00015 #include <string>
00016 #include <list>
00017 
00018 namespace edm {
00019   class EDProduct;
00020   class ModuleDescription;
00021   class ProductRegistry;
00022   class ProductRegistryHelper {
00023   public:
00024 
00025     ProductRegistryHelper() : typeLabelList_() {}
00026     ~ProductRegistryHelper();
00027  
00028     struct TypeLabelItem {
00029       TypeLabelItem (BranchType const& branchType, TypeID const& tid, std::string const& pin) :
00030         branchType_(branchType),
00031         typeID_(tid),
00032         productInstanceName_(pin),
00033         branchAlias_() {}
00034       BranchType branchType_;
00035       TypeID typeID_;
00036       std::string productInstanceName_;
00037       mutable std::string branchAlias_;
00038       void setBranchAlias(std::string const& alias) const {branchAlias_ = alias;}
00039     };
00040 
00041     typedef std::list<TypeLabelItem> TypeLabelList;
00042 
00044     TypeLabelList & typeLabelList();
00045 
00046     static
00047     void addToRegistry(TypeLabelList::const_iterator const& iBegin,
00048                              TypeLabelList::const_iterator const& iEnd,
00049                              ModuleDescription const& iDesc,
00050                              ProductRegistry& iReg,
00051                              bool iIsListener=false);
00052 
00054 
00061     template <class ProductType> 
00062     TypeLabelItem const& produces() {
00063       return produces<ProductType, InEvent>(std::string());
00064     }
00065 
00066     template <class ProductType> 
00067     TypeLabelItem const& produces(std::string const& instanceName) {
00068       return produces<ProductType, InEvent>(instanceName);
00069     }
00070 
00071     template <typename ProductType, BranchType B> 
00072     TypeLabelItem const& produces() {
00073       return produces<ProductType, B>(std::string());
00074     }
00075 
00076     template <typename ProductType, BranchType B> 
00077     TypeLabelItem const& produces(std::string const& instanceName) {
00078       TypeID tid(typeid(ProductType));
00079       return produces<B>(tid,instanceName);
00080     }
00081 
00082    
00083     TypeLabelItem const& produces(const TypeID& id, std::string const& instanceName=std::string()) {
00084        return produces<InEvent>(id,instanceName);
00085     }
00086 
00087     template <BranchType B>
00088     TypeLabelItem const& produces(const TypeID& id, std::string const& instanceName=std::string()) {
00089        TypeLabelItem tli(B, id, instanceName);
00090        typeLabelList_.push_back(tli);
00091        return *typeLabelList_.rbegin();
00092     }
00093   private:
00094     TypeLabelList typeLabelList_;
00095   };
00096 
00097 
00098 }
00099 
00100 #endif

Generated on Tue Jun 9 17:35:45 2009 for CMSSW by  doxygen 1.5.4